PDA

View Full Version : Controlling several objects in openGl independentl



Ali S. Alfaraj
09-27-2010, 09:08 PM
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

ZbuffeR
09-27-2010, 11:52 PM
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.

Ali S. Alfaraj
09-28-2010, 12:47 AM
Thanks for the reply Zbuffer. I'm sure It will help me a lot.

Ali