PBuffer - depth component

Hi,

is it possible to use glReadPixels from the pbuffer (wglCreatePbufferARB) in the same way like from the frame buffer? i’d like to read DEPTH_COMPONENT but i have the blank buffer after the rendering.
(NVIDIA GeForce4 MX440, true color).

greetings,
josiph

Did you remember to request a depth buffer when creating your pbuffer? If so, how many bits do you request?

– Tom

you also must remember to enable depth testing for the pbuffer (glEnable(GL_DEPTH_TEST)), or else rendering will have no effect on the depth buffer, even if it does in fact exist.

It’s also worth noting that depending on how you set up your Frustum and how you render you geometry, the variation in z-values may be very subtle. It might look like you have a blank (eg. white) pbuffer, but it may simply be that the precision isn’t there to see the different values.

For testing, move your far plane in (and/or your near plane out) so that your geometry fills up more of the space between the two planes. That’ll make the variation more obvious.

i asked for 32 in the ChoosePixelFormat, but i obtained just 16 bits in truecolor mode.
so i set the depth bits to 16 (higher values did not work):
WGL_DEPTH_BITS_ARB, 16

complete atributes array for the wglChoosePixelFormatARB looks like this:
WGL_SUPPORT_OPENGL_ARB, TRUE,
WGL_DRAW_TO_PBUFFER_ARB, TRUE,
WGL_COLOR_BITS_ARB, 32,
WGL_DEPTH_BITS_ARB, 16,
WGL_DOUBLE_BUFFER_ARB, TRUE,
WGL_PBUFFER_WIDTH_ARB, n_width,
WGL_PBUFFER_HEIGHT_ARB, n_height,

the array of pbuffer attributes for the wglCreatePbufferARB is empty (just zero terminated).

did i omit something?

josiph

Your settings look reasonable. Try calling glError() during your setup code to see if you are getting any errors.

IIRC 32 bit z-depth may not be supported by your card. 24bit is most likely the maximum. (That leaves 8bits for stencil if you want it). I could be wrong though, perhaps some cards will let you use 32bit as long as you don’t ask for stencil.

24 bits should work on your card.

> 24 bits should work on your card.

yes, you’re right. when i asked for 24 depth bits in ChoosePixelFormat i got them.
also pbuffer with 24 bits was created afterwards.