Amar Engine

From strange beginnings, 2012-me continued to fill his time with building game engines from scratch. I hope one day to again have as much free time as I did as an undergraduate!

That year, I uploaded a short demo video to YouTube:

It was the first version of some kind of game or game engine. I stumbled across what seemed to be the codebase for this as I was trying to answer the question: what the heck was "metaplains".

As this code was from quite some time ago, and I wasn't really using version control, it's hard to completely put myself back in the mind of my younger self. But from what I can tell, there were two codebases, amar-engine and amar-engine-dormant. Running these was not straightforward (though I eventually managed to run one of them) so I started off by looking at the code.

You would have thought that surely the latter is the older one of the two, but there are some oddities there. To compare the two, first I diffed the directories with this command:

diff -qr -x .git -x '*.class' amar-engine amar-engine-dormant

This basically compares the directories recursively (-r) and only reports the differences (-q) while ignoring/excluding the .git directory and the compiled code (-x).

This gave me a decent idea of how the projects differed, but it was too cumbersome to diff individual files, so I used a VSCode extension called Compare Folders which made the whole process much more efficient.

Using this, I found out that the dormant one seemed to have more modern code and techniques in some places. For example, I upgraded all the shaders to GLSL 150, and was using VBOs instead of display lists or immediate-mode rendering. You might find it weird that I would use those old-school techniques in the first place rather than go straight for the modern, but this was a side-effect of the time and way that I learned OpenGL.

Learning OpenGL back then had a lot of gatekeeping and there weren't a lot of accessible resources. If you wanted to learn OpenGL, you were told to go read the "red book" or the "blue book". There was also an "orange book" about GLSL, but for the most part you had to go through that rite of passage that all the greybeards went through too. At some point, with my limited knowledge, I started writing my own tutorials even and was surprised at how much people wanted me to write more.

So I learned OpenGL chronologically, from the old-school to the modern stuff. I feel like this gave me a much better understanding of the graphics pipeline and why some things are are the way they are. Anyway, I'm getting off topic!

So why is the dormant one seemingly more modern? I think what probably happened is that I started modernising amar-engine, ran in to a lot of unexpected problems, so then decided to park it and continue building on the version that I knew at least worked. If I were doing this again today, that repo would have probably instead been an abandoned git branch.

Anyway, I wasn't actually able to get the dormant one to run, but I eventually managed to get amar-engine to run, after installing JDK 8 and commenting out an incompatible import (fortunately unused anyway). To my initial surprise, it looked nothing like I expected it to and that's how I also found out it must be related to the above YouTube video, but a later version. Interestingly, this was my description on that video:

Me messing around with a game engine I decided to code this weekend. Should make for interesting before/after videos.

Islands are procedurally generated using Perlin noise based on a seeded pseudorandom number generator. Models are loaded from standard WaveFront .obj files (with materials in the .mtl format) and animations as .bvh though they're rather heavy at the moment. This is mainly an incentive for me to do more modelling, rigging and animation in Blender.

Here's a quick video of what I found, as you'll probably struggle to get this to run otherwise:

You'll notice that I changed the way that the terrain is rendered, instead using shaders, such that the transition between tile types is perfectly smooth (unlike the vertex colouring in the YouTube video). I also added first-person controls (including shift to run) and player physics. Then I also added a house that's bigger on the inside by taking you to a different scene. That's a concept that both Metaplains and Conquest shared with this world, along with the multiplayer stuff that might later become libfabric.