I have seen this question asked here many times but have not found a relative answer. I have a sphere which I rotate around the X an then the Y but I want to do more of a horizontal and vertical rotation. I basically want the axes to stay fixed. so when I rotate around the X xis it does not change the location of the Y axis. I found the following in an OpenGL FAQ but it is still unclear. Thanks in advance.
"9.070 How do I transform my objects around a fixed coordinate system rather than the object’s local coordinate system?
If you rotate an object around its Y-axis, you’ll find that the X- and Z-axes rotate with the object. A subsequent rotation around one of these axes rotates around the newly transformed axis and not the original axis. It’s often desirable to perform transformations in a fixed coordinate system rather than the object’s local coordinate system.
The OpenGL Game Developer’s FAQ contains information on using quaternions to store rotations, which may be useful in solving this problem.
The root cause of the problem is that OpenGL matrix operations postmultiply onto the matrix stack, thus causing transformations to occur in object space. To affect screen space transformations, you need to premultiply. OpenGL doesn’t provide a mode switch for the order of matrix multiplication, so you need to premultiply by hand. An application might implement this by retrieving the current matrix after each frame. The application multiplies new transformations for the next frame on top of an identity matrix and multiplies the accumulated current transformations (from the last frame) onto those transformations using glMultMatrix().
You need to be aware that retrieving the ModelView matrix once per frame might have a detrimental impact on your application’s performance. However, you need to benchmark this operation, because the performance will vary from one implementation to the next."