Depth-Buffer -> Frame Buffer

Hi Folks!

Stupid question maybe, but is it possible to render or move the values from the Depth-Buffer to the frame-Buffer, so i can grab them there as an image or draw the values to the screen?




glReadPixels(…) with a GL_DEPTH_COMPONENT will give you the contents of the depth buffer directly.

If you work on a NV card you can also try:

Or you can do it with EXT_pixel_buffer_object using glReadPixels/glDrawPixels.

Every other way using glReadPixels/glDrawPixels (without EXT_pixel_buffer_object) is very very inefficient because all data has to be transfered from GPU to CPU and at last back to the GPU.

Thanks for the quick answer :slight_smile:

I know about Readpixel(), but unfortunately i think i can’t use it, as i need the data for an application i want to use in the frame-buffer.

And i think Readpixel is quite slow, afaik…

Nevertheless thanks for your reply!

glReadPixels ist slow, yes. But if you use it with EXT_pixel_buffer_object there is not much performance loss.