Reading packed depth/stencil to main memory

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,
             GL_DEPTH_STENCIL_EXT,
             GL_UNSIGNED_INT_24_8_EXT, pImg);

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

Don’t call glReadBuffer. The bound FBO is your read buffer.

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.