Rotation order

I want to verify one thing:

Lets say I want to rotate an object (in this order) 30 degrees around the Y-axis, 20 degrees around the X-axis and finally 10 degrees around the Z-axis, what is the correct order of applying the rotation matrices in OpenGL?

Is it ZXY, like this:

glRotatef (10.0f, 0.0f, 0.0f, 1.0f);
glRotatef (20.0f, 1.0f, 0.0f, 0.0f);
glRotatef (30.0f, 0.0f, 1.0f, 0.0f);

or YXZ, such as:

glRotatef (30.0f, 0.0f, 1.0f, 0.0f);
glRotatef (20.0f, 1.0f, 0.0f, 0.0f);
glRotatef (10.0f, 0.0f, 0.0f, 1.0f);

Thanks.

Is it ZXY, like this:

glRotatef (10.0f, 0.0f, 0.0f, 1.0f);
glRotatef (20.0f, 1.0f, 0.0f, 0.0f);
glRotatef (30.0f, 0.0f, 1.0f, 0.0f);

This one is correct as you need to set transformations in the reverse order.

I don’t know what you are doing exactly, but you should probably never think of rotation as those three independent rotations. glRotatef is expecting axis-angle form of the roation

http://en.wikipedia.org/wiki/Rotation_representation_(mathematics)

of course you can break it down into the three rotations around the x, y, and axis (that is Euler’s rotation theorem) but then you have to keep track of the order and that’ll get super annoying (as you already see!)

Good luck.
Dave