# OpenGL Matrix: OpenGL to row-major-order

This topic is 4780 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi Since I need to finalize my matrix implementation I cam about a little problem which seems to confuse quite a lot people I am trying to convert a opengl matrix to my row major matrix implementation The opengl FAQ says the transformation components are stored in the 13th,14th and 15th of 16 elements of the matrix array ok So in order to convert this matrix model to row-major i had to transpos the 3x3 rotation sub matrix and copy the translation parts into [3][0..2] field of my row-major matrix right? v*M= v' whereas v' is the translated vector I prefer row-major matrices since we are used to them at university

##### Share on other sites
i think i figured it out now

i just transpose the opengl matrix and multiply M*v this should work correctly

##### Share on other sites
Just wanted to point out that there's a difference between row/column-major and row/column vectors. The former refers to how a matrix is laid out in memory. Row major is:
[0 1 2][3 4 5][6 7 8]
Column major:
[0 3 6][1 4 7][2 5 8]
Row vs. column vectors refers to whether vectors are represented as 1xN matrices or Nx1 matrices. A row vector example:
       [xx xy 0 ][x y 1][yx yy 0 ] = [x' y' 1]       [tx ty 1 ]
A column vector example:
[xx yx tx][x]   [x'][xy yy ty][y] = [y'][0  0  1 ][1]   [1 ]
Mixing up the terms can cause confusion down the line, so it's good to get them clear at the beginning.

##### Share on other sites
Something like that ?

##### Share on other sites
It's column major, but it is also multiplied by a vector on the left. So the two cancel one another out. Column major is the transpose of row major, but to multiply on the right with a matrix built for multiplying on the left you would take the transpose. The transpose of the transpose of a matrix is the original matrix. So if you concatenate transforms on the left and multiply by vectors on the right then you use the matrices returned by OpenGL as row major arrays.

##### Share on other sites
Thx guys I think I ll use the extension Ilici suggested, that way I stay api independent since D3D uses row-major matrices

##### Share on other sites
Quote:
 Original post by BasirorThx guys I think I ll use the extension Ilici suggested...

Tsss, it's i l i a k :)

1. 1
2. 2
3. 3
Rutin
20
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633655
• Total Posts
3013175
×