Domanda

My understanding is that eglSwapBuffers is called automatically every frame when using a GLSurfaceview, so:

onDrawFrame()
{

//Your drawing code here

//system swaps buffers automatically

}

is there any way at all that I can either disable this behaviour and call eglSwapBuffers myself/manually at the end of each onDrawFrame() or supress it when I need to (ie, let it run when I want it to but stop it from running when I need to).

If possible, I would be grateful if someone could explain how this can be achieved (if possible) when using both RENDERMODE_CONTINUOUSLY & RENDERMODE_WHEN_DIRTY

Of course, my understanding may be wrong, so please correct me if it is :-)

È stato utile?

Soluzione

GLSurfaceView isn't particularly flexible. It'd be nice if onDrawFrame returned a "do draw" boolean; then you'd have a bit more flexibility in how you arrange your game loop. GLSurfaceView doesn't work that way, though, so your options are limited.

You have two basic approaches if you want to avoid rendering every frame:

(1) Use RENDERMODE_WHEN_DIRTY, and only request render when you know you will want to swap buffers when onDrawFrame completes. This is pretty much what you want to do anyway if your game logic doesn't run on the render thread and you're not trying to run at 60fps.

(2) Download the source for GLSurfaceView, merge it into your app, and modify it to do what you want.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top