Sign in to follow this  

Semantic hell: rows and columns.

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 [i]x component[/i] as the [i]number of columns[/i] and the [i]y component[/i] as the [i]size of the column[/i]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

 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

Share this post


Link to post
Share on other sites
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. :)

Share this post


Link to post
Share on other sites


"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".

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this