View Full Version : How to read Depth Buffer

10-29-2003, 12:31 PM

I am rendering a 3D object, and I need to make a visibility map to get which area of object is visible. How can I read a depth buffer? Is this correct, but it doesn't seem to work, all the values I get are 255
glReadPixels(0, 0, ResX, ResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, d_DepthBuf);

Or is there any other way for it.

Thanks in advance,


10-29-2003, 12:41 PM
Try to read back the depth as a float, not as a unsigned byte. Also try to move the near clipping plane a little farther from you. See if that works.

10-30-2003, 02:25 AM

Actually I think, I didn't explain correctly what I need to do, so if you have any suggestion how to do this it is more then welcome.

I am rendering an object. I need to determine which vertices are visible. What I like to do is to transform the 3D vertices of object using projection matrix to 2D. Now when I do this multiple vertices transform to same 2D coordinates, so I need to determine which vertex was visible in case of clash.


[This message has been edited by Heema (edited 10-30-2003).]