View Full Version : read depth buffer content.

10-14-2002, 09:16 PM
Hi gang,

I'd like to read the content of the depth buffer in a texture.

That's what I am assuming:

1. Setup ReadBuffer, to read from depth buffer (But what is the flag?)

2. Use glCopyTexImage2D to read it in a texture.

Am I right with this?


10-15-2002, 12:26 AM
You have the right idea, but reading the depth buffer is implied by the data format in the copy call.

Specify a depth internal format for the copy and make sure your texture is of type depth.

You can find the tokens here:

10-15-2002, 12:46 AM
As Dorbie said, if you are using ARB_depth_texture, you need only use CopyTex(Sub)Image2D with a format of DEPTH_COMPONENT.
If you are not using this extension and want depth data in a simple 8-bit luminance texture, then you need to do ReadPixels with a format of DEPTH_COMPONENT, and then Tex(Sub)Image.

10-15-2002, 06:30 PM
Cool, thanks!