View Full Version : Rotation Problem
I've a problem with glRotatef: I have some blocks on the screen. I want to rotate ONE of them. But when I use glRotatef, all blocks are rotated. What can I do?
06-01-2001, 11:17 AM
OpenGL is a state machine so whenever you use glRotatef it changes the state of the current matrix so that everything after that call is affected. If you only want to rotate one cube you should use glPushMatrix and glPopMatrix around it like so...
glPushMatrix(); // Push current matrix onto the matrix stack
glRotatef(); // Modify current matrix
glPopMatrix(); // Pop top of stack into current matrix, resetting it to what it was prior to the glRotatef
Yepp, it works. Thanx. But the command don't work for Moving or Scaling because I have the same problems there. Could you give me further help?
06-02-2001, 06:12 AM
It's the same as Deissum proposed. You have to push the matrix that is to be used for ALL cubes, change it to the needs of the single cube you wanted to change, and then pop the stack again.
glMatrixMode( GL_MODELVIEW );
// Draw single cuve now
Then you should also call to mind that the matrix operations work the other way around. With what I wrote above, you would first scale the cube, then translate it and at least, you would rotate it.
Hope that helps.
Thanx, now it works. http://www.opengl.org/discussion_boards/ubb/biggrin.gif
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.