How to attach default depth buffer to FBO? How to use depth renderbuffer buffer attached to FBO (after drawing to it) as a default depth buffer?
Basically I want to use the same depth buffer for both the FBO and backbuffer rendering.
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.Sign up to join this community
This is by design. OpenGL (and older versions of DirectX) were designed back in the days when windowed apps literally shared the same frame buffer. That meant that if you had two overlapped windows, the windows would be trying to use the exact same pixels from the color, depth, and stencil buffers. The windowing systems dealt with this via a hard-coded masking operation.
In other words, you do not own the default depth buffer, cannot change the default depth buffer, and cannot reliably read from the default depth buffer in the OpenGL API.
Your best bet is to just do all of your rendering in an FBO and then use a texture blit to get the final image into the default FBO.