PDA

View Full Version : Depth of Pixels



romeoneverdies
06-05-2002, 12:50 AM
how do i get the depth value of a pixel of an image,which i chose by a mouseclick ??

will i be able to get pixel information abt a point on the image by mentioning the depth value ,even if the point isnt visible in the image due to an overlying pixel ??

Bob
06-05-2002, 12:58 AM
You get pixel information with glReadPixels. Mouse position is nothing OpenGL deals with, so you have to rely on your windowing API for that.

But you won't be able to get information about occluded pixels. Simply because the frame buffer and depth buffer are two dimensional buffers. You can only get information about the pixel that is visible at the point where you call glReadPixels.

dorbie
06-05-2002, 01:06 AM
You cannot get the depth of a "hidden" pixel unless you disabled depth writes when the overlying pixel was drawn.

To get depth of the visible pixel use readpixels. You will have to convert to eye space coordinates. This is slightly trick.

Here's the conversion:
http://www.cs.unc.edu/~hoff/techrep/openglz.html

Here's why:
http://www.sgi.com/software/opengl/advanced96/node23.html