Given a number of objects how would you move them independently og each other

# Moving objects independently of each other

glLoadIdentity();

glTranslatef(x1, y1, z1);

/* Draw first object */
glLoadIdentity();
glTranslatef(x2, y2, z2);
/* Draw second object

*/*

glLoadIdentity();

glTranslatef(x3, y3, z3);

/Draw third object */

glLoadIdentity();

glTranslatef(x3, y3, z3);

/

x1, y1, z1, x2 … are the coordanites of the first second and third objects. Just change the coordanites of an object and only it will move.

(Note: This example code doesn’t implement rotation)

Another way to do it:

glPushMatrix();

glTransatef(x1, y1, z1);

/* Draw object 1 */
glPopMatrix();
glPushMatrix();
glTransatef(x2, y2, z2);
/* Draw object 2

*/*

glPopMatrix();

glPushMatrix();

glTransatef(x3, y3, z3);

/Draw object 3 */

glPopMatrix();

glPushMatrix();

glTransatef(x3, y3, z3);

/

glPopMatrix();

This way it keeps any modifications done to the modelview matrix before the drawing.