I am very confused in the definitions of matrices. I have a matrix class that contains a float[16] , which I assumed to be a string based on the following observations:
float matrixA[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; float matrixB[4][4] = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 }, { 12, 13, 14, 15 } };
matrixA and matrixB both have the same linear layout in memory (i.e. all numbers are in order). According to http://en.wikipedia.org/wiki/Row-major_order this points to a line layout.
matrixA[0] == matrixB[0][0]; matrixA[3] == matrixB[0][3]; matrixA[4] == matrixB[1][0]; matrixA[7] == matrixB[1][3];
Therefore, matrixB[0] = row 0, matrixB[1] = row 1, etc. Again, this indicates a line layout.
My problem / confusion occurs when I create a translation matrix that looks like this:
1, 0, 0, transX 0, 1, 0, transY 0, 0, 1, transZ 0, 0, 0, 1
which is laid out in memory as { 1, 0, 0, transX, 0, 1, 0, transY, 0, 0, 1, transZ, 0, 0, 0, 1 } .
Then, when I call glUniformMatrix4fv , I need to set the transpose flag to GL_FALSE, indicating that it has a column value, otherwise it will convert, for example, translation / scale, etc. t applies correctly:
If the transposition is GL_FALSE, it is assumed that each matrix is presented in the main order. If the transposition is GL_TRUE, each matrix is supposed to be delivered in the main order.
Why should my matrix, which appears to have a large row value, need to be passed to OpenGL as the main column?