Jump to content
  • Advertisement
Sign in to follow this  
Lasse__

Way to get current depthbuffer value for given pixel?

This topic is 5065 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Take a look at glReadPixels:

glReadPixels(x,y,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&depth);

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!