Way to get current depthbuffer value for given pixel?
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);
glReadPixels(x,y,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&depth);
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
Popular Topics
Advertisement