How do you control the speed of an animation? My objects animate faster on another's machine.
void idle(void){
if (!wantPause){
circleSpin = circleSpin + 2.0; //spin circles
if(circleSpin > 360.0)
{
circleSpin = circleSpin - 360.0;
}
diamondSpin = diamondSpin - 4.0; //spin diamonds
if(diamondSpin > 360.0)
{
diamondSpin = diamondSpin + 360.0;
}
ellipseScale = ellipseScale + 0.1; //scale ellipse
if(ellipseScale > 30)
{
ellipseScale = 15;
}
glutPostRedisplay();
}
}
void drawScene()
{
...
glColor3f(1,0,0);
glPushMatrix();
glRotatef(circleSpin,0,0,1);
drawOuterCircles();
glPopMatrix();
}
int main (int argc, char** argv)
{
glutInit(&argc, argv);
glutInitWindowSize(400,400);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("Lesson 6");
init();
glutDisplayFunc(drawScene);
glutKeyboardFunc(keyboard);
glutReshapeFunc(handleResize);
glutIdleFunc(idle);
glutMainLoop();
return 0;
}