

You _could_ use quaternions for rotations, convert them to a rotation matrix and then apply that matrix (or use the angle-axis representation). You're experiencing a gimbal lock because you seem to use the Euler angles. If you do Euler angles rotation (as you seem to be doing), you want to pay very close attention to the order of rotations since they make a difference. Just try to switch the order and see what happens. Whether you want to first translate and then rotate or do it the other way around depends. Especially hierarchical structures benefit from that. This keeps all matrix operations for your dynamic objects in separate matrices, so you effectively get local coordinate systems and after you pop, further operations apply to the matrix you worked on before pushing.


To act on a local matrix, do a glPushMatrix(), perform your transformation, your rotation and your draw calls and then do a glPopMatrix().
