使用Frame Buffer对象,我创建了颜色和深度的渲染缓冲区,并将它们附加到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);
但是如何在保持颜色缓冲区完整的同时解除深度缓冲区的绑定?