well the matrix is the way opengl wants it, it column ordered in a array(0-3 first column etc…)
The code currently looks like(matrix are a GLfloat matrix[16]
void M4x4::LoadOrtho(float Left, float Right, float Bottom, float Top, float Near, float Far)
{
matrix[0] = 2.0f / (Right - Left);
matrix[1] = 0.0f ;
matrix[2] = 0.0f ;
matrix[3] = 0.0f ;
matrix[4] = 0.0f ;
matrix[5] = 2.0f / ( Top-Bottom ) ;
matrix[6] = 0.0f ;
matrix[7] = 0.0f ;
matrix[8] = 0.0f ;
matrix[9] = 0.0f ;
matrix[10] = -2.0f / (Far - Near);
matrix[11] = 0.0f ;
matrix[12] = (Right + Left) / (Right - Left) ;
matrix[13] = (Top + Bottom) / (Top - Bottom) ;
matrix[14] = (Far + Near) / (Far - Near) ;
matrix[15] = 1.0f ;
M4x4 tmp;
tmp.LoadTranslation(Left-Right,Top-Bottom,0);
*this = (*this)*tmp;
}
you also see the LoadTranslation method(pasted below), which is
the current test work around to transpose the scene origin just tested at my perticular case.
Now the entire scene is reseted and world,texture and projection matrix is set to identity before i do any operations.
glMatrixMode(GL_PROJECTION);
M4x4 projection
projection.LoadOrtho(0,287,255,0,-1,1);
glLoadMatrixf(projection.matrix);
Now the above code vill produce the same
result as: gluOrtho2D(0,287,255,0);
But only if i keep the translation matrix in the LoadOrtho method(otherwise the scene will have 0,0 in lower right).
I can’t see anything differing from the redbooks definition of the orthomatrix, soo I believe it should yield the same result without the translation but it doesn’t.
void M4x4::LoadTranslation(float Tx, float Ty, float Tz)
{
LoadIdentity();
matrix[12] = Tx;
matrix[13] = Ty;
matrix[14] = Tz;
}