m_projectionMatrix[0] = 2.0f / (float)(m_viewportWidth - 0.0f);
m_projectionMatrix[1] = 0.0f;
m_projectionMatrix[2] = 0.0f;
m_projectionMatrix[3] = 0.0f;
m_projectionMatrix[4] = 0.0f;
m_projectionMatrix[5] = 2.0f / (float)(0.0f - m_viewportHeight);
m_projectionMatrix[6] = 0.0f;
m_projectionMatrix[7] = 0.0f;
m_projectionMatrix[8] = 0.0f;
m_projectionMatrix[9] = 0.0f;
m_projectionMatrix[10] = -2.0f / (float)(1.0f - 0.0f);
m_projectionMatrix[11] = 0.0f;
m_projectionMatrix[12] = (m_viewportWidth + 0.0f) / (m_viewportWidth - 0.0f);
m_projectionMatrix[13] = (0.0f + m_viewportHeight) / (0.0f - m_viewportHeight);
m_projectionMatrix[14] = (1.0f + 0.0f) / (1.0f - 0.0f);
m_projectionMatrix[15] = 1.0f;
Orthographic Projection Matrix
Hi, can anyone help me out with what I'm doing wrong here?
I am trying to construct an orthographic projection matrix, with the top left corner being (0,0) and the bottom right corner being (m_viewportWidth, m_viewportHeight). Near and far clipping planes are 0.0f and 1.0f respectively. The matrix is read as column-major.
You need to tell us why you think it is wrong. If you are using OpenGL, then my guess is that inverting the Y axis is turning your right handed coordinate system into left handed.
Just thought I'd mention that in at least one version of the Red Book the orthographic projection matrix given in the appendix is incorrect; I believe the error may be exactly the one that Shadx described.
This may have been corrected in later versions or in the online version, but I'm not sure. Anyway, if your reference was the Red Book then that may be the source of the error in your code.
This may have been corrected in later versions or in the online version, but I'm not sure. Anyway, if your reference was the Red Book then that may be the source of the error in your code.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement