Matrix Problems...

Well i would like to code a matrix class and i remembered the MEGA-BIG fight (i don’t remember how many posts) between Michael Steinberg and Elric about Row Major Matrix but i don’t manage to find it!
So i ask: my class use a float m[16] tab but what are the differences in the code between row major operations and column major operations (for example in multiplication, or dumping to the screen, …).
Thanks by advance.

TheDD

It’s like this:

GLfloat m[16];

// Row major output (the mathematicians’ traditional way).
using namespace std;
cout << m[0] << " " << m[1] << " " << m[2] << " " << m[3] << endl <<
m[4] << " " << m[5] << " " << m[6] << " " << m[7] << endl <<
m[8] << " " << m[9] << " " << m[10] << " " << m[11] << endl <<
m[12] << " " << m[13] << " " << m[14] << " " << m[15] << endl;

// Column major output (the OpenGL way).
cout << m[0] << " " << m[4] << " " << m[8] << " " << m[12] << endl <<
m[1] << " " << m[5] << " " << m[9] << " " << m[13] << endl <<
m[2] << " " << m[6] << " " << m[10] << " " << m[14] << endl <<
m[3] << " " << m[7] << " " << m[11] << " " << m[15] << endl;

Hope that helps.

Yes, thanks a lot for your help, but now i only know how to dump my matrix to the screen! Is there any differences in the code in matrix multiplication, addition or any others operations?

If somebody remember in which post (i accept urls :wink: ) there was the “discussion” about the way that OpenGL treat matrix between Michael and Elric (and some others…), please tell me.

One more question, my objectif is to code a matrix class which can replace the OpenGL matix (for a software 3D Engine for example) and i was asking me if the sources code of the function gluLookAt was available?!

Thanks.
TheDD

http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/002537.html

Thanks guys :wink:
TheDD

There are no difference in operations - it only influences output.