I would like to get the depth information of the central pixel of my window so that I can make some smart rotations around the object which is in the middle of my screen.
I try doing it with:
but this doesn’t work. The value of pixel doesn’t change except when the object is very very close. I checked that GL_DEPTH_SCALE is 1 and GL_DEPTH_BIAS is 0.
What do I do wrong?
Thanks for your help
i guess u use a perspective projection
probably u made the mistake to set the near clipping plane very close (e.g. 0.0001) and the far clipping plane quite far (e.g. 1000)
the depth values are NOT mapped linear between near and far (on the other hand in an ortho projection they are) so u use up 99% of the precision in the first few depth units (0.0001 - 5 or so)
for the remaining deph values (5 - 1000) there are only 1% of precision, so they almost get mapped on the same value (which will also lead to z-fighting)
moving your near clipping plane further away will help