Yea, It has to do how openGL deals with matrix multiplication.
In your example you should remember that the first line essentially does this
ModelviewMatrix=RotationMatrixModelviewMatrix
then that also means that the second line does this
ModelviewMatrix=ScaleMatrixModelviewMatrix
put these two together and you will have
ModelviewMatrix=ScaleMatrix*(RotationMatrix*ModelviewMatrix)
Now this might be confusing at the beginning, but that’s the way it works, fortunately starting with openGL 3.0 you can do it anyway you like.
page 62:
"If C is the current matrix and M is the matrix pointed to by MultMatrix’s argument, then the resulting current matrix, C’ , is
C’ = C · M.
"
page 63:
“Rotate, Translate, Scale, Frustum, and Ortho manipulate the current matrix. Each com-
putes a matrix and then invokes MultMatrix with this matrix.”
Sound like semantics but for me it makes more sense to say openGL matrix operations occur from right-to-left (or bottom-to-top in C-code).
For instance say you have code like
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); // load Matrix => MV=I
glTranslatef(car_x_pos, car_y_pos, car_z_pos); // times Matrix T => MV=I*T
glRotatef(RAD_TO_DEG * car_direction, 0.0, 0.0, -1.0); // times Matrix R => MV=I*T*R
glScalef(Sx,Sy,Sz); // times Matrix S => MV=I*T*R*S
draw(P); // draw points P'= MV*P = I*T*R*S*P
The effective operation order is of scaling first, then rotation, then translating. I think of operations going from bottom-to-top in openGL code which corresponds to right-to-left in matrix operations as