Controlling several objects in openGl independentl

Controlling several objects in openGl independently

Hi friends,

I’m creating a scene in openGl. There will be a number of different objects in this scene, and I would like to have the freedom of transforming, scaling, rotation…ect. each object independently of the other objects. I’m having a problem in doing that, given that openGl is a state machine.So, how can I resolve this problem?

Hope you can help me with that.

Ali

In fact you can do you that in several ways :

glMatrixMode(GL_MODELVIEW);
for (each object) {
  glPushMatrix();
  // translate/rotate/scale...
  // draw object
  glPopMatrix();
}
glMatrixMode(GL_MODELVIEW);
for (each object) {
  glLoadIdentity();
  // translate/rotate/scale...
  // draw object
}

Among others.

Thanks for the reply Zbuffer. I’m sure It will help me a lot.

Ali