Jump to content

  • Log In with Google      Sign In   
  • Create Account


Semantic hell: rows and columns.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 gasto   Members   -  Reputation: 261

Like
2Likes
Like

Posted 24 March 2014 - 07:29 PM

DirectX uses row-first notation for tables or matrices while OpenGL uses column-first notation.

 

Why on earth would mathematicians choose the opposite of the Cartesian method of ordering the axis(first x then y) boggles me.

 

Furthermore, we refer to the x component as the number of columns and the y component as the size of the column


Intel Core 2 Quad CPU Q6600, 2.4 GHz. 3GB RAM. ATI Radeon HD 3400.

Sponsor:

#2 mark ds   Members   -  Reputation: 1124

Like
1Likes
Like

Posted 24 March 2014 - 07:46 PM

Welcome to reality! It's bitten me more than once!!! the lesson here is that you must read the specs.

 

http://gamedev.stackexchange.com/questions/16011/direct3d-and-opengl-matrix-representation "In OpenGL, matrix operations are pre-concatenated, which means concatenated transformations are applied from right to left. Direct3D, however, applies concatenated transformations from left to right."


Edited by mark ds, 24 March 2014 - 07:56 PM.


#3 Hodgman   Moderators   -  Reputation: 28522

Like
3Likes
Like

Posted 24 March 2014 - 07:58 PM

http://gamedev.stackexchange.com/questions/16011/direct3d-and-opengl-matrix-representation
"In OpenGL, matrix operations are pre-concatenated, which means concatenated transformations are applied from right to left. Direct3D, however, applies concatenated transformations from left to right."

This is not a valid statement any more (since shaders became the norm with GL2 / D3D9). I'd go as far as to say that SE page is just wrong.

 

You can use either column-vectors or row-vectors (pre/post concatenation) in both D3D and GL.

You cal also use column-major or row-major storage in both D3D and GL.

You can also use right-handed or left-handed coordinate systems in both D3D and GL.

 

You can choose your convention.

 

The only thing that's fixed is the order that the 16 floats must be given to the constructor of a GLSL mat4x4 or a HLSL float4x4, and their array access syntaxes...

 

Note that on the C/C++ side, neither D3D or GL define vector or matrix types. If you've got some fixed row-major, post-convatenation (row-vector) matrix classes, those are not a part of D3D, those are an external library. You're free to choose a single math library and use it for both.


Edited by Hodgman, 24 March 2014 - 08:15 PM.


#4 mark ds   Members   -  Reputation: 1124

Like
0Likes
Like

Posted 24 March 2014 - 09:00 PM

 Yeah, you're correct, I just wanted to present the simple case (row vs column  mayor).

 

But, from a students point of view. it must seem pretty confusing - left or right handed.

 

 

 

 

Incidentally, we spoke a while ago about landscape shadowing, with a focus on penumbras. I've moved on with that! (I didn't reply because of work commitments!)


Edited by mark ds, 24 March 2014 - 09:00 PM.


#5 BarrySkellern   Members   -  Reputation: 643

Like
0Likes
Like

Posted 25 March 2014 - 12:45 AM

Adding to Hodgman's comment about choosing conventions, just pointing you to the /Zpr flag of the HLSL compiler, which will make it use row-major packing. Obviously that's not the only answer you need, but it might save you a minute looking. :)

Visit http://www.mugsgames.com - Just released: Stroids, a retro style mini-game for Windows PC.

Mugs Games on Twitter: @MugsGames and Facebook: www.facebook.com/mugsgames

Me on Twitter @BarrySkellern

 


#6 haegarr   Crossbones+   -  Reputation: 3898

Like
0Likes
Like

Posted 25 March 2014 - 02:27 AM


"In OpenGL, matrix operations are pre-concatenated, which means concatenated transformations are applied from right to left. Direct3D, however, applies concatenated transformations from left to right."

A mnemotechnic verse may be as simple as this: The closer the transformation matrix to the vector in the mathematical formula, the more local is it. In other words: The farer away, the more transformations are between it and the original vector. This works fine for both row and column vectors and eliminates the dependent "left-to-right" vs. "right-to-left".






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS