我还是 opengl3 的新手,我正在尝试创建多通道渲染。
为了做到这一点,我创建了 FBO,生成了几个纹理并将它们附加到它
unsigned index_col = 0;
for (index_col = 0; index_col < nbr_textures; ++index_col)
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + index_col, texture_colors[index_col], 0);
它运作良好(我试着相信我在这里做得很好!)。
我的理解问题发生在当我尝试在屏幕外的第一个纹理中渲染,然后在第二个纹理中,然后在屏幕上渲染时。
要渲染到特定纹理,我正在使用:
FBO.bind();
glDrawBuffer(GL_COLOR_ATTACHMENT0);
glBindTexture(GL_TEXTURE_2D, FBO.getColorTextures(0)); //getColorTextures(0) is texture_colors[0]
然后我使用我的着色器进行绘制,然后我想做:
glDrawBuffer(GL_COLOR_ATTACHMENT1);
glBindTexture(GL_TEXTURE_2D, FBO.getColorTextures(1));
毕竟
glBindFramebuffer(GL_FRAMEBUFFER, 0);
RenderToScreen(); // assuming this function render to screen with a quad
glDrawBuffer
我的问题是:和有什么区别glBindTexture
?有必要同时调用吗?纹理不是附加到缓冲区吗?(我实际上无法对其进行测试,因为我正在努力使其工作......)
谢谢!