Transforming separate objects...separately??

All week I’ve been banging my head on the wall on trying to get two objects to rotate independently. I’ve searched this site and many others but I can’t find any help on this matter.

In my display function, based on what I have seen…my logic is this…

glPushMatrix();
glRotate(axis1…);
…Draw object…
glPopMatrix();

glPushMatrix();
glRotate(axis2…);
…Draw second object
glPopMatrix(…);

But this doesn’t seem to work. The first object STILL rotates with the second. Why is this? I thought the Push makes the new matrix active? Even if I take out the Rotate func for the first object, it still rotates with the second on axis #2.

Is there something I’m not doing? I’ve seen no examples that accomplish this task. It must be simple…I just can’t see it.

If anyone could help me with this, I’d really appreciate it.

The logic is next:

  • for every frame you do next
  1. place yourself in the center of the world
    2.translate (glTranslatef)
    3.rotate (glRoatatef)
    4.paint the object

and this for every object every frame.

NewROmancer

Are you loading the identity matrix at the start? If not, then the matrix you first push may not be at the center of your world which is what you want. Also, make sure your matrix mode is set properly before you do your pushes and pops. Like:
glMatrixMode(GL_MODELVIEW);