# Multiple Calls to glRotate*

This topic is 4555 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

When making multiple calls to glRotate* (glRotated in this case); glRotated(angley, 1.0, 0.0, 0.0); glRotated(anglex, 0.0, 1.0, 0.0); I find that (here) it rotates bout the x axis, and then with the same matrix rotates it about the y axis. I am trying to rotate a quadric in two directions with respect to the 'observer' (after calls to glLookAt). Is there a way in which I can rotate the object two times in the 'world matrix' and not once in the world matrix, and the second time in the 'local matrix' (world perceived by the object)? Apologies if I am not making myself clear. Basically, when I call glRotated I find that the other axis are in fact being rotated along with the object I am currentl focusing on.

##### Share on other sites
seperate the calls to glrotate* by a push and pop i.e. :

glpushmatrix();
rotatey();
glPopmatrix();

glpushmatrix();
rotatex();
glpopmatrix();

Jon

##### Share on other sites
But...
"glPopMatrix pops the current matrix stack, replacing the current matrix with the one below it on the stack."
(tried, and it didn't look like it was rotating at all)
I'll try to further explain
I have a very simple setup. There is a plane (as in a big white square) and a ball on it. I want to rotate the ball 'a' degrees around the x-axis, then 'b'-degrees around the y axis. If i simply call two glRotate functions, it rotates the ball correctly around one axis, but the other rotation is respective to the new matrix.
Is it possible to have the two rotations respective to the original matrix, but apply them both?

##### Share on other sites
Quote:
 Original post by unruly83Is it possible to have the two rotations respective to the original matrix, but apply them both?
Although I'm not completely clear on what you're trying to do, I don't think you can do it with Euler angles as you're doing now. When you perform a sequence of global-axis rotations, one of them will always appear to be about a local axis. If you want the object to always rotate about the global axes regardless of its orientation, you may have to track the orientation and perform the rotations yourself. You won't be able to do this via OpenGL (at least not easily); you'll have to write the code for it yourself.

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
17
5. 5

• 9
• 12
• 9
• 33
• 13
• ### Forum Statistics

• Total Topics
632594
• Total Posts
3007259

×