问题描述
然后我们创建缓冲区对象,我们可以指定从0到N的许多颜色附件
Then we create buffer object we can specify many colour attachments from 0 to N
glBindFramebuffer(GL_FRAMEBUFFER, some_buffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,some_texture_0, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D,some_texture_1, 0);
但是接下来我们要缓冲一下,如何控制我们在FBO中使用哪种颜色附件?(默认值为0),还是多个颜色附件的工作方式不同?
But then we draw to buffer, how to control which colour attachment we use in FBO? (default is 0), or multiple colour attachments works different way?
glBindFramebuffer(GL_FRAMEBUFFER, some_buffer);
//draw something
//switch to colour_attachment1
//draw something
//switch back to colour_attacment0
推荐答案
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D,some_texture_1, 0);
在OpenGL ES 2.0中不允许此行.至少不是没有 扩展名. OpenGL ES根本不支持具有多个颜色缓冲区.只有GL_COLOR_ATTACHMENT0
;没什么.
This line is not allowed in OpenGL ES 2.0. At least, not without extensions. OpenGL ES simply does not support having multiple color buffers. There is only GL_COLOR_ATTACHMENT0
; nothing more than that.
因此,如果要绘制到一个缓冲区然后再绘制到另一个缓冲区,则需要绑定一个新的FBO.
So if you want to draw to one buffer then another, you need to bind a new FBO to do so.
这篇关于在FBO中切换当前的GL_COLOR_ATTACMENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!