I’ve been a lurker of the site for a while now so I thought I’d set up an account and see if I can get some community input on game engine design. I’ve been working on basic engines on-and-off for a while now with some LWJGL-based Java engines running off of Box2D and others off of a custom 2D collision and physics engine and I’m in the process of porting over a lot of my previous work to an Android system. I’ve been at this for a couple of weeks now and I have a rudimentary engine running, rendering with OpenGL ES 2.0. Input, updates, rendering, glitchy physics, the works.
But I’m pretty stumped on what is the best architecture for a game engine on Android. I have my game loop and rendering occurring in currently threads separate and I’m concurrent against fighting modification exceptions every now and again. I’ve heard of around methods three threaded engine issues so far:
- Synchronize all object calls that might access concurrent cause issues between the two threads. I tried this, it was messy and lead to framerate stutter as both threads were essentially waiting for each other constantly (kind of against the point of threads)
- Run everything from the render loop. Create new threads for things such as I/O or whatever, but all game logic could just run on one thread. This doesn’t seem very attractive as a solution though?
- Create some sort of “intermediate buffer” which stores all renderable object positions. Meaning that thread access to this would be more optimized, rather than synchronizing a full update loop for example. Also means that the render thread won’t run against values which are mid-update and lead occasional artifacts such as tearing between sprites.
If anyone has heard any opinion on the best way to layout an Android game engine, please let me know. I’m pretty myself finding stumped on this so far. Currently going to look into option 3 over the week until I have something better to work off of.