Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualBrother Bob

Posted 03 July 2013 - 08:42 AM

The OpenGL specification is written with column vectors in mind, and this is how a translation matrix for column vectors look like:

1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1

Now store this matrix in column major order, and you get the following memory layout:

1 0 0 0 0 1 0 0 0 0 1 0 x y z 1

Direct3D, on the other hand, uses a row vector notation, and this is how a translation matrix for row vectors look like:

1 0 0 0
0 1 0 0
0 0 1 0
x y z 1

Now store this matrix in row major order, and you get the following memory layout:

1 0 0 0 0 1 0 0 0 0 1 0 x y z 1

See how the effect of changing both matrix storage mode and vector mode negates each other and the final memory layout is exactly the same?

 

There are two questions that you seem to be mixing: column vs. row major storage, and column vs. row vectors. Column vs. row major storage dictates how a two-dimensional matrix is stored in one-dimensional memory, while column vs. row vectors dictates whether you multiply your vector on the left or right hand side of the matrix. The two are completely independent choices, but together they determine the physical layout in linear memory. Column major storage and column vectors have exactly the same physical storage as row major storage and row vectors. That is why you can use the same data for both APIs.

 

But as BornToCode said, it is not actually correct to say that OpenGL uses column vectors and column major storage. That is why I'm writing that the specification is written with that notation, because you can use any storage mode and vector mode as long as the final memory layout is consistent with that OpenGL assumes. Same applies for Direct3D.


#3Brother Bob

Posted 03 July 2013 - 08:41 AM

The OpenGL specification is written with column vectors in mind, and this is how a translation matrix for column vectors look like:

1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1

Now store this matrix in column major order, and you get the following memory layout:

1 0 0 0 0 1 0 0 0 0 1 0 x y z 1

Direct3D, on the other hand, uses a row vector notation, and this is how a translation matrix for row vectors look like:

1 0 0 0
0 1 0 0
0 0 1 0
x y z 1

Now store this matrix in row major order, and you get the following memory layout:

1 0 0 0 0 1 0 0 0 0 1 0 x y z 1

See how the effect of changing both matrix storage mode and vector mode negates each other and the final memory layout is exactly the same?

 

There are two questions that you seem to be mixing: column vs. row major storage, and column vs. row vectors. The two are completely independent choices, but together they determine the physical layout in linear memory. Column vs. row major storage dictates how a two-dimensional matrix is stored in one-dimensional memory, while column vs. row vectors dictates whether you multiply your vector on the left or right hand side of the matrix. Column major storage and column vectors have exactly the same physical storage as row major storage and row vectors. That is why you can use the same data for both APIs.

 

But as BornToCode said, it is not actually correct to say that OpenGL uses column vectors and column major storage. That is why I'm writing that the specification is written with that notation, because you can use any storage mode and vector mode as long as the final memory layout is consistent with that OpenGL assumes. Same applies for Direct3D.


#2Brother Bob

Posted 03 July 2013 - 08:40 AM

The OpenGL specification is written with column vectors in mind, and this is how a translation matrix for column vectors look like:

1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1

Now store this matrix in column major order, and you get the following memory layout:

1 0 0 0 0 1 0 0 0 0 1 0 x y z 1

Direct3D, on the other hand, uses a row vector notation, and this is how a translation matrix for row vectors look like:

1 0 0 0
0 1 0 0
0 0 1 0
x y z 1

Now store this matrix in row major order, and you get the following memory layout:

1 0 0 0 0 1 0 0 0 0 1 0 x y z 1

See how the effect of changing both matrix storage mode and vector mode negates each other and the final memory layout is exactly the same?

 

There are two questions that you seem to be mixing: column vs. row major storage, and column vs. row vectors. The two are completely independent choices, but together they determine the physical layout in linear memory. Column major storage and column vectors have exactly the same physical storage as row major storage and row vectors. That is why you can use the same data for both APIs.

 

But as BornToCode said, it is not actually correct to say that OpenGL uses column vectors and column major storage. That is why I'm writing that the specification is written with that notation, because you can use any storage mode and vector mode as long as the final memory layout is consistent with that OpenGL assumes. Same applies for Direct3D.


#1Brother Bob

Posted 03 July 2013 - 08:39 AM

The OpenGL specification is written with column vectors in mind, and this is how a translation matrix for column vectors look like:

1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1

Now store this matrix in column major order, and you get the following memory layout:

1 0 0 0 0 1 0 0 0 0 1 0 x y z 1

Direct3D, on the other hand, uses a row vector notation, and this is how a translation matrix for row vectors look like:

1 0 0 0
0 1 0 0
0 0 1 0
x y z 1

Now store this matrix in row major order, and you get the following memory layout:

[/code]

1 0 0 0 0 1 0 0 0 0 1 0 x y z 1

[/code]

See how the effect of changing both matrix storage mode and vector mode negates each other and the final memory layout is exactly the same?

 

There are two questions that you seem to be mixing: column vs. row major storage, and column vs. row vectors. The two are completely independent choices, but together they determine the physical layout in linear memory. Column major storage and column vectors have exactly the same physical storage as row major storage and row vectors. That is why you can use the same data for both APIs.

 

But as BornToCode said, it is not actually correct to say that OpenGL uses column vectors and column major storage. That is why I'm writing that the specification is written with that notation, because you can use any storage mode and vector mode as long as the final memory layout is consistent with that OpenGL assumes. Same applies for Direct3D.


PARTNERS