First of all, my framework is set up exactly like example code shown here, right under "How about User Input?"
http://android-developers.blogspot.com/2009/04/introducing-glsurfaceview.html I think that the author forgot to mention one more thing, which is "How about Game Logic?". So in a nutshell, this is what I have so far: ClearActivity extends Activity, ClearGLSurfaceView extends GLSurfaceView, ClearRenderer implements GLSurfaceView.Renderer Ok, so we have three classes - ClearActivity, which just sits there like a bump and a log and pretends to look important while really doing nothing, ClearGLSurfaceView, which handles input, and ClearRenderer, which updates the screen. So far so good (I guess?), but where does the game logic go? How about onDrawFrame()? Right now it's the only thing that's getting called every frame. But wait a minute - isn't ClearRenderer supposed to be running it's own thread so that the rendering code is decoupled from everything else? For example, say I wanted my game to run at 60hz while keeping my render update near 30hz. If that were the case, then I'd need to enable RENDERMODE_WHEN_DIRTY, which means onDrawFrame() will only get triggered when I call requestRender(). So I'm back to my original question - where should I put game logic? I've looked over the OpenGL API samples and they all simply use onDrawFrame() exclusively, conveniently avoiding the whole thing entirely. How nice... let's take a quick peek at the LunarLander sample, which unfortunately neither uses OpenGL nor GLSurfaceView, but it's better than nothing: class LunarView extends SurfaceView implements SurfaceHolder.Callback { class LunarThread extends Thread { .... public void run() { updatePhysics(); doDraw(); } } } It looks like they create a threaded class under the SurfaceView- derived class which updates the game and then renders it immediately afterward. So should I be creating a thread under ClearGLSurfaceView (replacing doDraw() with requestRender() every 30ms), or do I need to use a different approach? Am I at least going in the right direction? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

