I've done games using OpenGL on PC side but the whole android threading business confuses me at this point.
Generally my 2D game loop structure is roughly like this:
- Code: Select all
while( gameRunning )
if( 20ms passed ) // just arbitary value, I don't update game logic EVERY loop
update gameLogic with the delta time
float t = calculate interpolation point from current time and lastUpdateTime
renderEverything( t ); // with the interpolation point we get smooth looking movement on screen and yay :3
Now what would be the best way to go about doing this in Android? I'm guessing I'd have to use two different threads but.. how.. what? Feels confusing. I've gone through most of the examples, looked into many code examples on this site and others and generally they have one thread running the game loop and then they use Java canvas on the side to do drawing. I think I need another thread for my openGL and somehow need to wiggle stuff around between the openGL thread and the game logic thread (generally the interpolation point?). Or is the game loop built in a completely different manner on Android? Since I want it to move smoothly and look smoothly and this is where the rendering with the interpolation came into play.
But yeah, any advices how to build a proper game loop for a game on Android using openGL ?
EDIT #1: or if I missed and obvious link, thread or what not, post it. Something that would get me up to speed on how to go about getting a proper game looping structure working together with OpenGL. Does it require two threads and that stuff, like explained above.