如何在OpenGL ES 2.0的部分重绘 [英] How to redraw partially in opengl Es 2.0

查看:813
本文介绍了如何在OpenGL ES 2.0的部分重绘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我的需要,我想重新绘制场景只有一部分对每一帧而不是 中重绘整个场景只有当它的某些部分会被更新。

As per my need i want to redraw only some part of the scene for each frame instead of redrawing the entire scene only if some portion of it is updated.

有没有办法做到这一点在OpenglEs 2.0? 请在此输入任何将是真正有用的

Is there a way to do that in OpenglEs 2.0? Please any input on this will be really helpful

推荐答案

的OpenGL真的不支持增量渲染。您需要每次被要求重画的时间来绘制整个帧。

OpenGL does not really support incremental rendering. You need to draw the entire frame every time you are asked to redraw.

最近我能想到的是,你使您的静态数据到屏幕外的帧缓冲,使用FBO(帧缓冲对象)。你应该能够找到很多例子在网上和书,如果你像OpenGL的FBO的关键字。你可以使用像这样通话glGenFramebuffers() glBindFramebuffer() glFramebufferTexture2D()等。

The closest I can think of is that you render your static data to an offscreen framebuffer, using a FBO (Frame Buffer Object). You should be able to find plenty of examples online and in books if you look for keywords like "OpenGL FBO". You will be using calls like glGenFramebuffers(), glBindFramebuffer(), glFramebufferTexture2D(), etc.

一旦呈现的静态内容到一个FBO,你可以将它复制到默认的帧缓冲在每个重绘的开始,然后渲染在它上面的动态内容。这可以是一个有价值的方法,如果呈现静态内容是非常昂贵的。否则,FBO执行复制到默认的framebuffer可以比简单地重新渲染每次静态内容更加昂贵。

Once you rendered the static content into an FBO, you can copy it to the default framebuffer at the start of each redraw, and then render the dynamic content on top of it. This can be a worthwhile method if rendering the static content is very expensive. Otherwise, doing the copy from FBO to default framebuffer can be more expensive than simply re-rendering the static content each time.

以上是pretty的容易,如果静态内容为背景,动态内容是完全在它的前面。如果静态和动态内容重叠,它得到棘手。然后,您将不得不恢复从开始呈现动态内容之前,每次呈现的静态内容所产生的深度缓冲。我想不出一个好办法,在ES 2.0。该功能来做到这一点比较顺利(深度的纹理, glBlitFramebuffer )仅在ES 3.0及更高版本。

The above is pretty easy if the static content is in the background, and the dynamic content is completely in front of it. If static and dynamic content overlap, it gets trickier. You will then have to restore the depth buffer resulting from rendering the static content each time before starting to render the dynamic content. I can't think of a good way to do that in ES 2.0. The features to do this relatively smoothly (depth textures, glBlitFramebuffer) are only in ES 3.0 and later.

还有,我不认为这是非常有吸引力的另外一个选择,但我想提到它的完整性起见:EGL定义可以设置一个 EGL_SWAP_BEHAVIOR 属性以 EGL_BUFFER_ preSERVED 。其中一个重要的提醒是,它是可选的,不支持的所有设备。它也只preserves颜色缓冲区,而不是辅助缓冲区,如深度缓冲。如果你想读了也无妨,请参见 eglSwapBuffers eglSurfaceAttrib

There is one other option that I don't think is very appealing, but I wanted to mention it for completeness sake: EGL defines a EGL_SWAP_BEHAVIOR attribute that can be set to EGL_BUFFER_PRESERVED. One big caveat is that it's optional, and not supported on all devices. It also only preserves the color buffer, and not auxiliary buffers, like the depth buffer. If you want to read up on it anyway, see eglSwapBuffers and eglSurfaceAttrib.

这篇关于如何在OpenGL ES 2.0的部分重绘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆