Even if nowadays everybody seems to drop OpenGL methods when they are deprecated on the core profile, it doesn't mean that you don't need to use them in compatibity profile or that you don't want to know how they work. I searched on the web to find more information on how the old and deprecated OpenGL matrices are implemented and I didn't find anything (except tutorials on how to use them!). My doubt was mainly about the operations order, because I needed to make a C++ implementation of them, maintaining the same exact behavior. I used OpenGL matrices In the past without worrying about how they were implemented, I had a precise idea but now I have to be 100% sure. Even if we know how to implement operations between matrices, the row-column product doesn't have the commutative property so the internal implementation can make the difference. At the end, my question is:

- What is the matrix row-column order and how the product is implemented on OpenGL?

Tired of finding pages saying how they are useless and deprecated now, I had to check by myself the Mesa source code to find what I was searching for:

P = A * B; P[0] = A[0] * B[0] + A[4] * B[1] + A[8] * B[2] + A[12] * B[3]; P[4] = A[0] * B[4] + A[4] * B[5] + A[8] * B[6] + A[12] * B[7]; P[8] = A[0] * B[8] + A[4] * B[9] + A[8] * B[10] + A[12] * B[11]; P[12] = A[0] * B[12] + A[4] * B[13] + A[8] * B[14] + A[12] * B[15]; P[1] = A[1] * B[0] + A[5] * B[1] + A[9] * B[2] + A[13] * B[3]; P[5] = A[1] * B[4] + A[5] * B[5] + A[9] * B[6] + A[13] * B[7]; P[9] = A[1] * B[8] + A[5] * B[9] + A[9] * B[10] + A[13] * B[11]; P[13] = A[1] * B[12] + A[5] * B[13] + A[9] * B[14] + A[13] * B[15]; P[2] = A[2] * B[0] + A[6] * B[1] + A[10] * B[2] + A[14] * B[3]; P[6] = A[2] * B[4] + A[6] * B[5] + A[10] * B[6] + A[14] * B[7]; P[10] = A[2] * B[8] + A[6] * B[9] + A[10] * B[10] + A[14] * B[11]; P[14] = A[2] * B[12] + A[6] * B[13] + A[10] * B[14] + A[14] * B[15]; P[3] = A[3] * B[0] + A[7] * B[1] + A[11] * B[2] + A[15] * B[3]; P[7] = A[3] * B[4] + A[7] * B[5] + A[11] * B[6] + A[15] * B[7]; P[11] = A[3] * B[8] + A[7] * B[9] + A[11] * B[10] + A[15] * B[11]; P[15] = A[3] * B[12] + A[7] * B[13] + A[11] * B[14] + A[15] * B[15];

where A and B are 4x4 matrices and P is the result of the product. As you can see, this snippet clarifies how rows and columns are internally ordered and how the product is implemented. In conclusion, the OpenGL methods to modify the current matrix are implemented by Mesa in this way: