column major matrix multiplication
I've created a matrix class for use in OpenGL,
the matrix class uses two-dimensional float array,
how should I do multiplication of matrices correctly ?
Re: column major matrix multiplication
A tip: OpenGL is column-major operator-on-the-left (e.g. P*V*M * v1 = v2)
Originally Posted by khdani
This is the same as row-major operator-on-the-right (e.g. v1 * M*V*P = v2).
Flipping both results in a net-zero change in the math. You get exactly the same values in exactly the same memory locations.
So since C/C++ is row-major, do the second one. More here. With this you can spoon your row-major operator-on-the-right matrices directly to OpenGL (which expects column-major operator-on-the-left matrices) via glLoadMatrixd, glMatrixLoadf, glUniformMatrix4fv, or whatever... No need to waste time on useless transpose operations.