Orthographic Projection Issue

Posted by Nick on Game Development See other posts from Game Development or by Nick
Published on 2014-08-18T13:30:52Z Indexed on 2014/08/18 16:47 UTC
Read the original article Hit count: 390

Filed under:
|

I have a problem with my Ortho Matrix. The engine uses the perspective projection fine but for some reason the Ortho matrix is messed up. (See screenshots below).

Can anyone understand what is happening here?

At the min I am taking the Projection matrix * Transform (Translate, rotate, scale) and passing to the Vertex shader to multiply the Vertices by it.

VIDEO Shows the same scene, rotating on the Y axis. http://youtu.be/2feiZAIM9Y0

 void Matrix4f::InitOrthoProjTransform(float left, float right, float top, float bottom, float zNear, float zFar)
{
    m[0][0] = 2 / (right - left);   
    m[0][1] = 0;                        
    m[0][2] = 0;                        
    m[0][3] = 0;

    m[1][0] = 0;                        
    m[1][1] = 2 / (top - bottom);   
    m[1][2] = 0;                        
    m[1][3] = 0;

    m[2][0] = 0;                        
    m[2][1] = 0;                        
    m[2][2] = -1 / (zFar - zNear);  
    m[2][3] = 0;

    m[3][0] = -(right + left) / (right - left);
    m[3][1] = -(top + bottom) / (top - bottom);
    m[3][2] = -zNear / (zFar - zNear);
    m[3][3] = 1;
}

This is what happens with Ortho Matrix: Orthographic Matrix

This is the Perspective Matrix: Perspective Matrix

© Game Development or respective owner

Related posts about opengl

Related posts about graphics