I was wandering if there is a way to create a FBO that writes in the window system color buffer but reads depths from a texture.
I render the scene using a FBO. The result is a texture with the depth values and one more with scene’s color. In the next phase I make a post processing pass and I write the result in the window system color buffer (the window system depth buffer is always empty). In addition to that I want to draw a few debug primitives in the color buffer and I was wandering if I can use an FBO that writes in the color buffer and reads depths from the depth texture.
I’ve tried the above but it fails:
glGenFramebuffersEXT( 1, &fbo_id ); glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fbo_id ); // inform the we will write in the color buffer glDrawBuffer( GL_BACK ); glReadBuffer( GL_BACK ); // attach the depth texture glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, r::ms::fai_depth.gl_id, 0 ); // test if success if( glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT ) FATAL( "Cannot create debug FBO" ); // unbind glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );