my question is why I got three different matrices, and what is the difference, which is the correct one for converting coordinates from clip to eye space.
Details:
I am trying to get projection matrix of OpenGL to implement a virtual scanner, I use this matrix to convert coordinates from clip to eye space. I found three ways to get it:
glGetFloatv (GL_PROJECTION_MATRIX, projection_tmp);
glm::mat4 Proj = glm::perspective( fov, aspect, zNear, zFar);
- compute it manually through the method given by this page: gluperspective source code
Parameters passed to these three method follows:
const double zNear = 1;
const double zFar = 10001;//for computational convenience
const double fov = _model.getCamera().getFieldOfViewAngle();//60
//w(523)h(489)
const double aspect = static_cast<double>(w) / static_cast<double>(h);
Then I get three different matrices:
glGetFloatv:
1.61945 0 0 0
0 1.73205 0 0
0 0 -1.0002 -1
0 0 -2.0002 0
GLM:
-0.145971 0 0 0
0 -0.15612 0 0
0 0 -1.0002 -1
0 0 -2.0002 0
Manual:
0.504724 0 0 0
0 0.57735 0 0
0 0 -1.0002 1
0 0 -2.0002 0
Thanks!