glutDisplayFunc(disp);
+ /* get timer started, its reset in the timer function itself */
+ glutTimerFunc(1000, timer_func, 0);
+
glutMainLoop();
return 0;
}
glClearColor(color[cidx][0], color[cidx][1], color[cidx][2], 1);
glClear(GL_COLOR_BUFFER_BIT);
- /* set the timer callback and ask glut to call it in 1 second */
- glutTimerFunc(1000, timer_func, 0);
glutSwapBuffers();
}
/* advance the color index and trigger a redisplay */
cidx = (cidx + 1) % (sizeof color / sizeof *color);
glutPostRedisplay();
+
+ /* (re)set the timer callback and ask glut to call it in 1 second */
+ glutTimerFunc(1000, timer_func, 0);
}