According to this cheat sheet for CG, if I want to use column-major order for my matrix/vector math I have to multiply from the left applying transformations from right to left, i.e. v' = P * V * v

I built my view and projection matrices like this

Matrix44 view(right.x, right.y, right.z, -position.x,
              up.x, up.y, up.z, -position.y,
             -forward.x, forward.y, forward.z, -position.z,
              0.0f, 0.0f, 0.0f, 1.0f)

Matrix44 projection(Sx, 0.0f, 0.0f, 0.0f,
                    0.0f, Sy, 0.0f, 0.0f,
                    0.0f, 0.0f, Sz, Pz,
                    0.0f, 0.0f, -1.0f, 0.0f);

However, when using them in the vertex shader

gl_Position = projection * view * vec4(position, 1.0);

I cannot see my geometry unless I swap the transformation to

gl_Position = vec4(position, 1.0) * view * projection;

which means that I am using row-major order instead of column order. So my question is if the pdf I'm following is correct in the notation for the column-major order for view and projection matrices or what am I missing?

  • \$\begingroup\$ Can you please link to your source pdf? Your link seems to have disappeared. It should be linked like this: [some example pdf](http://www.example.com/example.pdf) \$\endgroup\$ – Amziraro Jun 21 '15 at 17:04
  • \$\begingroup\$ Sorry, missed it. I updated the question. \$\endgroup\$ – BRabbit27 Jun 21 '15 at 17:05
  • \$\begingroup\$ I have heard that OpenGL's matrices are always backwards. I don't know enough about this to make an answer, however. \$\endgroup\$ – Amziraro Jun 21 '15 at 17:10
  • \$\begingroup\$ in general the convention is opposite in US and in EU. another factor depends on your programming language. which one is the index varying the fastest (row or column) ? \$\endgroup\$ – user75844 Feb 26 '16 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.