Switching current GL_COLOR_ATTACMENT in FBO

a 夏天 提交于 2020-01-06 07:31:10

问题


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

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

回答1:


glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D,some_texture_1, 0);

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.

So if you want to draw to one buffer then another, you need to bind a new FBO to do so.



来源:https://stackoverflow.com/questions/12776345/switching-current-gl-color-attacment-in-fbo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!