Original Post
Hi! According to the documentation, Direct3D uses row major matrices, while OpenGL uses column major ones. I did the following test (a rotation of 90 degrees around axis X): So they seem to be stored in the same way. I checked translation too, and found the same result. I expected the D3D and OpenGL matrices to be the transposes of each other, as D3D is row major and OpenGL is column major. I know that one has to transpose matrices before passing between the two APIs, so where is the catch? :) Thanks
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(90, 1, 0, 0);
GLfloat mtxGL[16];
glGetFloatv(GL_MODELVIEW_MATRIX, mtxGL);
Checked the result in debugger:
mtxGL:
[0] 1.0000000 float
[1] 0.00000000 float
[2] 0.00000000 float
[3] 0.00000000 float
[4] 0.00000000 float
[5] 1.2167964e-008 float
[6] 1.0000000 float
[7] 0.00000000 float
[8] 0.00000000 float
[9] -1.0000000 float
[10] 1.2167964e-008 float
[11] 0.00000000 float
[12] 0.00000000 float
[13] 0.00000000 float
[14] 0.00000000 float
[15] 1.0000000 float
D3DXMATRIX mtxD3D;
D3DXMatrixRotationX(&mtxD3D, 90/180.0f*3.1415f);
Checked the result in debugger:
(float*)&mtxD3D,16:
[0] 1.0000000 float
[1] 0.00000000 float
[2] 0.00000000 float
[3] 0.00000000 float
[4] 0.00000000 float
[5] 4.6328703e-005 float
[6] 1.0000000 float
[7] 0.00000000 float
[8] 0.00000000 float
[9] -1.0000000 float
[10] 4.6328703e-005 float
[11] 0.00000000 float
[12] 0.00000000 float
[13] 0.00000000 float
[14] 0.00000000 float
[15] 1.0000000 float