My question simply is: what is the correct format for the Projection and ModelView matrix?
I’ve been told that the following example matrices are transposed and are not built like OpenGL matrices should be.
ModelView Matrix
{(1, 0, 0, 0)
(0, 0.7071068, 0.7071068, 0)
(0, -0.7071068, 0.7071068, 0)
(0, -141.4214, -141.4214, 1)}
Projection Matrix
{(1.931371, 0, 0, 0)
(0, 2.414213, 0, 0)
(0, 0, -1.0002, -1)
(0, 0, -2.0002, 0)}
Edit: this answer is in serious need of an update. Namely, there is no consideration about shaders.
As @gman points out in the comments, whether to use row-major or column-major depends on how you do your math. You may choose one or the other (or even both at different times if you don’t think that’s confusing) just as long as they match your coordinate systems and order of operations.
I’m leaving this answer as community wiki in case someone has the time and will to update it.
OpenGL specifies matrices as a one-dimensional array listed in column-major order, ie with elements ordered like this:
So if you initialize an array this way, in C or pretty much any other language, the resulting matrix will look like it needs transposing, because C code reads left-to-right first and then top-to-bottom (in other words, like if it were in row-major order):
By the way, OpenGL has both glLoadTransposeMatrix and glMultTransposeMatrix, which you can use instead of glLoadMatrix and glMultMatrix, so this shouldn’t be a problem.