# Rotating Selected Objects Only

## Recommended Posts

Hi, I'm learning how to use lighting and materials on platonic solids. All of that is working fine for me. However, I'm having difficulty understanding how I can stop the rotation of my text while still allowing my object to rotate. Any help will be appreciated. Jill
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// rotates about an angle on the y axis
glRotatef(theta, 0.0, 1.0, 0.0);

// set wireframe or solid mode
glPolygonMode(GL_FRONT_AND_BACK, wireframeMode);

switch( currentPlatonicSolid )
{
case 1:
glPushMatrix();
glRotatef(45,1,0,0);
glutSolidCube(1);
glPopMatrix();
break;
case 2:
// pewter material tetrahedron
displayString(0, -3, "Pewter Tetrahedron");
setMaterial(pewter);
glutSolidTetrahedron();
break;
.....


##### Share on other sites
mikeman    2942
The way you are doing it, rotation is applied to the whole scene. To rotate just one object, just use glRotate inside a glPushMatrix()/glPopMatrix() pair. Usually, drawing a scene looks something like this:

glMatrixMode(GL_MODELVIEW);

SetupCameraMatrix();
SetupLightPositions();

glPushMatrix();
DoSomeMatrixStuff();//rotate,translate,etc..
DrawObject1();
glPopMatrix();

glPushMatrix();
DoOtherMatrixStuff();
DrawObject2();
glPopMatrix();