如何合并两个FBO? [英] How to merge two FBOs?

查看:109
本文介绍了如何合并两个FBO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我有4个缓冲区,3个FBO和一个渲染缓冲区.让我解释一下.

OK so I have 4 buffers, 3 FBOs and a render buffer. Let me explain.

我有一个视图FBO,它将在将场景渲染到渲染缓冲区之前存储场景.

I have a view FBO, which will store the scene before I render it to the render buffer.

我有一个背景缓冲区,其中包含场景的背景.

I have a background buffer, which contains the background of the scene.

我有一个用户缓冲区,由用户操纵.

I have a user buffer, which the user manipulates.

当用户执行某些操作时,我会通过一些混合绘制到用户缓冲区.

When the user makes some action I draw to the user buffer, using some blending.

然后重新绘制整个场景,我想要做的就是清除视图缓冲区,将背景缓冲区绘制到视图缓冲区,更改混合,然后将用户缓冲区绘制到视图缓冲区.最后将视图缓冲区渲染到渲染缓冲区.

Then to redraw the whole scene what I want to do is clear the view buffer, draw the background buffer to the view buffer, change the blending, then draw the user buffer to the view buffer. Finally render the view buffer to the render buffer.

但是我不知道如何绘制一个FBO到另一个FBO.我想要做的基本上是合并和混合两个FBO,但是我不知道怎么做!我是OpenGL ES的新手,所以感谢您的所有帮助.

However I can't figure out how to draw a FBO to another FBO. What I want to do is essentially merge and blend two FBOs, but I can't figure out how! I'm very new to OpenGL ES, so thanks for all the help.

推荐答案

设置屏幕外的帧缓冲区以直接渲染到纹理.该链接向您展示了如何:

Set up your offscreen framebuffers to render directly to a texture. This link shows you how:

http://developer.apple.com/iphone/library/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/WorkingwithEAGLContexts/WorkingwithEAGLContexts.html#//apple_ref/doc/uid/TP40008793-CH103-SW7

为了我和你的利益,让我花点时间描述一下帧缓冲区和渲染缓冲区.帧缓冲区就像一个接受OpenGL渲染命令的端口.必须先将其附加到纹理或渲染缓冲区,然后才能查看或使用渲染输出.您可以选择使用glFramebufferTexture2DOES附加纹理还是使用glFramebufferRenderbufferOES附加渲染缓冲区.渲染缓冲区就像保存渲染结果的栅格图像一样.栅格图像的存储由OpenGL管理.如果希望图像显示在屏幕上而不是屏幕外缓冲区,请使用-[EAGLContext renderBufferStorage:fromDrawable:]来将EAGLContext的存储与renderbuffer一起使用.这段代码在OpenGL ES项目模板中.

Let me take a moment to describe framebuffers and renderbuffers, for my benefit and yours. A framebuffer is like a port that accepts OpenGL rendering commands. It has to be attached to a texture or a renderbuffer before you can see or use the rendering output. You can choose between attaching a texture using glFramebufferTexture2DOES or a renderbuffer using glFramebufferRenderbufferOES. A renderbuffer is like a raster image that holds the results of rendering. Storage for the raster image is managed by OpenGL. If you want the image to appear on the screen instead of an offscreen buffer, you use -[EAGLContext renderBufferStorage:fromDrawable:] to use the EAGLContext's storage with the renderbuffer. This code is in the OpenGL ES project template.

您可能不需要视图帧缓冲区,因为在将场景背景和用户层渲染为纹理之后,您可以将这些纹理绘制到渲染缓冲区中(即,绘制到与屏幕上渲染缓冲区关联的帧缓冲区中).

You probably don't need the view framebuffer, since after rendering the scene background and the user layer to textures, you can draw those textures into the renderbuffer (that is, into the framebuffer associated with the onscreen renderbuffer).

这篇关于如何合并两个FBO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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