My main question is: what is the correspondance between Depth buffer and opengl render coordinates?
The guess is that for near plane we have 0x00000000 and for far plane we have 0xFFFFFFFF.
I use GL_UNSIGNED_INT for grabbing depth.
The thing is this correspondance works but it seems not very correctly.
For example: I put object at (0,0,0), camera at (0,0,-6).
Plane near = 1, far = 5000.
All values in depth are around 0xE8E8E8E8. However, they should be somewhere around 0.
And if I put far = 5, I get similar values (which are probably correct in this case).
Why this happens?
In addition there is somewhat wierd way to set up projection matrix, and this might be one of the reasons.
I am using other peoples code. In this code shaders are used to show a scene. In the code either glFrustum or gluPerspective are not used. Instead, perspective matrix is set in the code and used in shader script.
where width ad height are calculated from field of view and geometric sizes of near plane.Code :m.e11 = 2 * near/width; m.e22 = 2 * near/height; m.e33 = far/(near - far); m.e34 = -1; m.e43 = near * far/(near - far);
I also wonder why these calculations are not the same as the one given in documentation for gluPerspective