View Full Version : Reading packed depth/stencil to main memory

carsten neumann
08-26-2010, 08:01 AM
I have an FBO with packed depth/stencil attachments (i.e. one renderbuffer with the packed format is attached to both) and would like to read the contents back to main memory. I'm thinking it should work something like this:

// create/setup FBO & buffers
// bind FBO
// render

glReadBuffer( ?? );
glReadPixels(0, 0, w, h,

What is the value that needs to be passed to glReadBuffer? Thanks.

08-26-2010, 09:21 AM
Don't call glReadBuffer. The bound FBO is your read buffer.

08-26-2010, 09:52 AM
I have depth_stencil render buffers and textures for my depth.
I use the following to access the Z depth values

glReadPixels( round(winX), round(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, @winZ );

Seems to work for me.