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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With