Global Coordinate System Transformations

Anyone know of example code that shows how you can maintain transformations along global coordinates even after rotating an object along one of its axis… (e.g. I rotate about the global X-axis, then want to rotate again, but along the global Z-axis, not local). Preferably this should be possible in a hierarchy of objects… The objcts are stored in display lists… And the program is ment to work like a CAD (3ds-Max) application.

You use glPushMatrix() and glPopMatrix() do to that:

glPushMatrix();
Rotate aroundx axis
//draw
glPopMatrix(); //old position is used again, so axis are not not rotated
glPushMatrix();
Rotate aroundz axis
//draw
glPopMatrix();

etc.