2

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 :)

4

1 回答 1

2

如果要渲染到 EGLSurface,则应默认启用双缓冲。正如您所说,缓冲区不会自动交换。如果您使用 SDK,则应在退出 onDrawFrame 后进行交换。在引擎盖下应该调用 eglSwapBuffers。

由于默认情况下有双缓冲,因此默认情况下您还将渲染到后台缓冲区(否则,您的半渲染帧将显示在屏幕上)。

听起来您有很多选择;包括 1)在需要时渲染到后台缓冲区,检索您的颜色代码,然后清除缓冲区并继续进行正常的帧更新,以及 2)渲染到屏幕外缓冲区,即帧缓冲区对象。

于 2013-06-16T21:03:11.803 回答