Tuesday, May 03, 2005

Order of Transform

OpenGL does a post-order transform. THis means that if you specify something like
 glRotatef(45, 0, 0, 1);
glTranslatef(20,0,0);

glBegin(GL_QUADS);

glVertex3f(-60,0,-10);
glVertex3f(60,0,-10);
glVertex3f(60,60,-10);
glVertex3f(-60,60,-10);
//glVertex3f(-10,0,0);

glEnd();
The Quads will be translated and then followed by rotation.

The following code
 glTranslatef(20,0,0);
glRotatef(45, 0, 0, 1);

glBegin(GL_QUADS);

glVertex3f(-60,0,-10);
glVertex3f(60,0,-10);
glVertex3f(60,60,-10);
glVertex3f(-60,60,-10);

glEnd();

glPopMatrix();
would result in the Quad being rotated first before being translated.

0 Comments:

Post a Comment

<< Home