for (i = 0; i < 30; i++) {
glTranslatef (i, 0, 0);
glBegin(GL_POLYGON);
glColor3f (1,0,0); glVertex2f (10,10);
glColor3f (0,1,0); glVertex2f (40,10);
glColor3f (0,0,1); glVertex2f (25,30);
glEnd();
} You're assuming that the scene will be redrawn each time through your loop. That's not how GL works. What would happen with this code is that the loop would run all the way through, then the scene would be drawn with i = 29. Your program has to be restructured a bit to do animation. See NeHe Tutorial #4 and read about GlutIdleFunc.

McLeary

04-26-2011, 10:57 AM

Again, use the code tag.

Remember, every call to display func will be rendered on screen. The for that you have will execute 30 times and only then the result will be available.

an example (using the code tag)

GLfloat tx = 0;

void display() {
glTranslatef( tx, 0, 0 );

[your draw code]

dx += 0.01;
}

So, every time the display func is called, you draw your polygon and dx will be incremented.