I'm a bit confused. I keep reading the following: OpenGL uses a right-handed coordinate system, column-major matrices, column vectors, and post-multiplication.
Yet the in memory layout of an OpenGL matrix is:
x.x x.y x.z 0
y.x y.y y.z 0
z.x z.y z.z 0
p.x p.y p.z 1
Or
x.x x.y x.z 0 y.x y.y y.z 0 z.x z.y z.z 0 p.x p.y p.z 1
Which is a row major layout!
I'm trying to roll my own math library, looking at glm for guidance, matrices are indexed as
mat[row][col]
which would seem to only further strengthen that OpenGL is indeed using row matrices.
It sounds like the matrix notation used in the OpenGL docs (and blue book) does not describe the in memory layout of the matrices.
Which begs the question, does this mean i should be pre-multiplying matrices, or do i need to account for the in-memory layout when doing matrix multiplications and keep post-multiply?
again, turning to glm for help, if i want to translate a model to 1, 2, 3 and then scale it up by 2 i need to do post multiplication:
glm::mat4 mat = glm::translate(glm::vec3(1.0f, 2.0f, 3.0f)) * glm::scale(glm::vec3(2.0f, 2.0f, 2.0f));
Results in:
2, 0, 0, 0,
0, 2, 0, 0,
0, 0, 2, 0,
1, 2, 3, 1
But, if the matrix has a row layout, shouldn't that multiplication be in reverse?
So confused.....