Question

I want to implement simple picking for a 2D Application using color codes. So far I render my objects with a call to GLES20.glDrawElements() and I only render on request.

Now, I have read numerous tutorials for OpenGL on this topic, but I could not find a single one for OpenGL ES and I also fail to convert/transfer these.

So, I have two questions. How to enable double buffering? Because as far as I know I would only have one buffer without. Will these buffers automatically be swapped? I guess not, since these is a method for it. How to render exclusively to the backbuffer? I only need to do it once, so it would be a waste to do it whenever I render a new frame.

This is my first time asking on stackoverflow after I have been finding answers to all of my questions for almost 4 years now, so please be gentle :)

Was it helpful?

Solution

Double buffering should be enabled by default if you're rendering to an EGLSurface. As you say, the buffers are not automatically swapped. If you're using the SDK, the swap should happen after you exit from onDrawFrame. Under the hood that's should call eglSwapBuffers.

Since there is double buffering by default, you will also be rendering to the backbuffer by default (otherwise, your half-rendered frames would show up on screen).

It sounds like you have a number of options; including 1) render to the backbuffer when needed, retrieve your color codes, and then clear the buffer and proceed with your normal frame update, and 2) render to an offscreen buffer, i.e., a framebuffer object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top