glRotatef()

I’m using glRotatef() in my program and its causes some of my later steps to get messed up. I’m getting the feeling that this is because glRotatef() also rotates the coordinate system along with the scene. Is there a way to rotate the shape without rotating the coordinate system?

Try this:

glPushMatrix()
glTranslate / rotate

draw object.

glPopMatrix()

Originally posted by Rajveer:
I’m using glRotatef() in my program and its causes some of my later steps to get messed up. I’m getting the feeling that this is because glRotatef() also rotates the coordinate system along with the scene. Is there a way to rotate the shape without rotating the coordinate system?

Okay, I just read about glPushMatrix() and glPopMatrix(). From my understanding, if I was to put the following two lines one after another in my program:

glPushMatrix();
glPopMatrix();

They would cancel each other out and it should have no effect on my program. Am I right about this? Because for some reason, when I wrote those two lines in my program (just to see what would happen) my entire drawing scene disappeared.

I am sorry, I thought you would understand I ment for them to be place between the object you are rotating…

glPushMatrix() // move past drawing information to the matrix stack.

glRotate
glTranslate
Draw something

glPopMatrix() // Move past drawing information back into current scene.

Yes if you put them without anything between them nothing should happen.
glPushMatrix()
glPopMatrix()

If the scene did not show up after using these commands then there is a problem in how you are calling the opengl commands.

Originally posted by Rajveer:
[b]Okay, I just read about glPushMatrix() and glPopMatrix(). From my understanding, if I was to put the following two lines one after another in my program:

glPushMatrix();
glPopMatrix();

They would cancel each other out and it should have no effect on my program. Am I right about this? Because for some reason, when I wrote those two lines in my program (just to see what would happen) my entire drawing scene disappeared. [/b]

[This message has been edited by nexusone (edited 04-05-2002).]