4

While the graphical output is completely messed up when I do this, I tried it out of curiousity. I was expecting it to crash due to illegal math operation:

 // gl_Position=Projection*Modelview*Position; <- normal, works fine // gl_Position=Position*Modelview*Projection; <- bad output, but still runs fine 

Position is the vector, the others are matrices.

OpenGL is column-major, which should mean that you can only multiply a vector on the right of a matrix. There is no mathematical way to multiply a vector to the left of a matrix if the vector is a column since the inner dimensions would not match: 4x1 * 4x4

So why do I actually get output when I try it? What is OpenGL actually doing with the vector-matrix multiplication?

1

1 Answer 1

7

Vector-matrix multiplication with a vector on the left side is interpreted in GLSL as if your column vector became a row vector.

Which, in effect, is like multiplying your column vector by the transpose of your matrix.

http://en.wikibooks.org/wiki/GLSL_Programming/Vector_and_Matrix_Operations#Operators

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.