Advertisement

Way to get current depthbuffer value for given pixel?

Started by August 05, 2004 11:15 AM
1 comment, last by vincoof 20 years, 3 months ago
How can I query OpenGL to give depthbuffer value for pixel (x,y) in the screen? When I compare this depthbuffer value to another value obtained through gluProject(), the bigger the value the deeper in the screen, right?
Take a look at glReadPixels:

glReadPixels(x,y,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&depth);
Advertisement
Quote: Original post by Lasse__
How can I query OpenGL to give depthbuffer value for pixel (x,y) in the screen? When I compare this depthbuffer value to another value obtained through gluProject(), the bigger the value the deeper in the screen, right?

Right, 0 representing the near clipping plane and 1 representing the far clipping plane. Note that in perspective projection, interpolated values are not linear ; for instance 0.5 does not represent 0.5*(far+near).

This topic is closed to new replies.

Advertisement