3

使用帧缓冲区对象,我为颜色和深度创建了渲染缓冲区,并将它们附加到 FBO。

//set up color buffer for rendering
glGenRenderbuffers(1, &my_fbo_params.color_rb[i]);
glBindRenderbuffer(GL_RENDERBUFFER, my_fbo_params.color_rb[i]);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB565, width, height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,           my_fbo_params.color_rb[i]);

//set up depth buffer
glGenRenderbuffers(1, &my_fbo_params.depth_rb[i]);
glBindRenderbuffer(GL_RENDERBUFFER, my_fbo_params.depth_rb[i]);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, my_fbo_params.depth_rb[i]); 

这一切都很好并且工作良好。当我继续下一个场景时,我想保留颜色缓冲区,但分离并取消绑定深度缓冲区。我了解到以下代码将执行分离:

glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); 

但是如何在保持颜色缓冲区完整的同时解除深度缓冲区绑定呢?

4

0 回答 0