PDA

View Full Version : transformation of objects on screen



04-16-2001, 11:06 AM
I have a very small number of polygons on the screen. I want to translate all of them at the same time using glTranslatef. Then I want to rotate just one of the polygons using glRotatef. How do I do each of these?

Dimae
04-16-2001, 12:09 PM
I think so:

glTranslatef(x,y,z); // translate coordinates system
glBegin(GL_TRIANGLES); // first polygon
glVertexf3(...);
glVertexf3(...);
glVertexf3(...);
glEnd();
glPushMatrix(); // save current matrix
glRotate(45, 0,1,0); // rotate coordinates system
glBegin(GL_TRIANGLES); // second polygon
glVertexf3(...);
glVertexf3(...);
glVertexf3(...);
glEnd();
glPopMatrix(); // Load saved matrix
glBegin(GL_TRIANGLES); // third polygon
glVertexf3(...);
glVertexf3(...);
glVertexf3(...);
glEnd();