about modeling transformation

i want to use glRotated() to realize observing dynamically.
glRotated(Y_Angle,0.0,1.0,0.0);
glRotated(X_Angle,1.0,0.0,0.0);
Y_Angle and X_Angle Represent separately vertical and horizontal movement of the mouse。
but glRotated(X_Angle,1.0,0.0,0.0) expresses the object rotating wind X axle in the system of coordinates that after running the first code(glRotated(Y_Angle,0.0,1.0,0.0) :wink: .

so,how i can make the object rotating wind X axle in the system of coordinates that begin

use glPushMatrix() to store the current state, or glLoadIdentity() to go back to initial state.

actually I think the second rotation will excutes first

glRotated(X_Angle,1.0,0.0,0.0);
glLoadIdentity() ;
glRotated(Y_Angle,0.0,1.0,0.0);

after running, the object can only rotate the x axis.

whatever here
glRotated(X_Angle,1.0,0.0,0.0);
glLoadIdentity() ;
glRotated(Y_Angle,0.0,1.0,0.0);

Equal to
glLoadIdentity() ;
glRotated(Y_Angle,0.0,1.0,0.0);

is not it?

yes,they are equivalent.but how i can realize the function that is put forward

??

Hint: if people don’t seem to be able to answer your question, maybe that’s because they don’t understand what you’re trying to do.

All transformations, including multi-axis rotations are chained. You cannot rotate something about two axes without the result of one interfering with that of the other.

That’s not because “Euler angles are evil” (search the net for that phrase), but because it’s just not possible.

If you want the X-rotation to modify the result of the Y-rotation, you need to specify the Y-axis rotation below the X-axis rotation.
If you want the Y-rotation to modify the result of the X-rotation, it’s the other way around.
If you think about it in world-objects, conceptually you need to specify them in the opposite order of the order in which they are applied to the vertices.

(By the way, if that is NOT what you want, you CAN rotate about a different axis than just the X-axis, Y-axis, or Z-axis.
That’s why there are three parameters for the axis in glRotate instead of one.)