Wednesday, 8 April 2009

rotation in different direction in the same scene

glPushMatrix(); //Save the rotation for the Quad
glRotatef(angle, 0.0f, 0.0f, 1.0f); //Rotate about the z-axis

glBegin(GL_QUADS);

glVertex3f(-0.7f, -0.5f, 0.0f);
glVertex3f(0.7f, -0.5f, 0.0f);
glVertex3f(0.4f, 0.5f, 0.0f);
glVertex3f(-0.4f, 0.5f, 0.0f);

glEnd();

glPopMatrix(); //Undo the rotation

glPushMatrix(); //Save the new rotation for the triangle
glRotatef(angle, 0.0f, 1.0f, 0.0f); //Rotate about the y-axis

glBegin(GL_TRIANGLES);

glVertex3f(-0.5f, -0.5f, 0.0f);
glVertex3f(0.5f, -0.5f, 0.0f);
glVertex3f(-0.5f, 0.0f, 0.0f);


glEnd();

glPopMatrix(); //Undo the rotation of the triangle

No comments:

Post a Comment