More matrix stack operations

Ok, now that I know all transformations on the stack are applied to each vertex drawn, I have a few more questions:

  1. glTranslatef and glRotatef operate on the top of the stack right? And they are multiplied by whats already there, so they are cumulative?

  2. DOes the order of glTranslatef and glRotatef matter? To my thinking, it probably does. e.g:
    glTranslatef(3.0f, 0.0f, 0.0f);
    glRotatef(10.0f, 1.0f, 0.0f, 0.0f);

This is whats required, but if I do the rotation first, would the translation now be skew-wiff because the axis are now aligned differently?

Thanks in advance,

Hi !

Yes the order of the operations does matter alot, you would get complete different results otherwise.

If you take something rotate it around it’s own origin, then it’s just rotating not moving, and then translate it…

Compare that with first translate something and then rotate it (you will now rotate it around the origin that is where the object was before the translation), so the rotation will also move the object (like earth is rotating around the sun…)

It’s a bit tricky to get the hang of.


oh, of course.

Its all in relation to the origin of the object…