Hi there guys,
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?
Ortho Projection code
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;
}
Then using projectionMatrix.InitOrthoProjTransform(0.0f, 800.0f, 0.0f, 600.0f, 0.1f, 1000.0f);
OK so the first screenshot that is attached shows the Ortho, second one shows perspective (rotated slightly to show persp).