Reputation: 7185
Currently I am rendering some stuff to a FBO with an attached depth render buffer.
However, after I am done with the render buffer, the depth information is pretty much lost.
How can I copy the data from the render buffer to the fixed function depth buffer?
Upvotes: 2
Views: 2232
Reputation: 4962
You can use glBlitFramebuffer, enabling the GL_DEPTH_BUFFER_BIT
flag.
Example code:
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo_id);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBlitFramebuffer(offset_x, offset_y, offset_x + size_x, offset_y + size_y,
offset_x, offset_y, offset_x + size_x, offset_y + size_y,
GL_DEPTH_BUFFER_BIT,
GL_NEAREST);
This will copy only the depth buffer.
Upvotes: 6