I need to know the “real” depth value of a pixel in the depth bufer. When i am using glReadPixels to read the depth buffer i found that the values are clamp to be between 0.0 and 1.0 . I know that there’s a maping between the real values to that range and that it is connected to the clipping plane of the projection. Is anyone knows the exact formula to convert the depth values?
And another problem. I am using this code:
glBegin(GL_POLYGON);
glVertex3d(200.0, 200.0, 0);
glVertex3d(200.0, -200.0, 0);
glVertex3d(-200.0, -200.0, 0);
glEnd();
glReadPixels(0, 0, prcView->right, prcView->bottom, GL_DEPTH_COMPONENT, GL_FLOAT, pixelsDepth);
The polygon here has a constant depth of 0. But when i’m looking in the array(pixelsDepth) the values are almost the same but not exactly. Why is that?