Something I just noticed :
// Gives INCORRECT Z value
GLdouble l_dZ;
glReadPixels(a_iX, l_iY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &l_dZ);
// Gives CORRECT Z value
GLfloat l_fZ;
glReadPixels(a_iX, l_iY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &l_fZ);
So always use GLfloat for reading the depth buffer if you want correct values.




to have a 64bit Z buffer !
