Using Frame Buffer objects, I have created render buffers for color and depth and attached them to the 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]);
This is all fine and working good. When I proceed to the next scene, I want to keep the color buffer but detach and unbind the depth buffer. I learnt that the following code will do the detach:
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
But how can I unbind the depth buffer while keeping the color buffer intact?