View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

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

5 replies to this topic

### #1gasto  Members

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.

### #2mark ds  Members

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.

### #3Hodgman  Moderators

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.

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.

### #4mark ds  Members

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.

### #5BarrySkellern  Members

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.

Stroids, a retro style mini-game for Windows PC. http://barryskellern.itch.io/stroids

### #6haegarr  Members

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.