3 * Written by John Tsiombikas <nuclear@member.fsf.org>
5 * Demonstrate the use of glutTimerFunc, by changing the color of the
6 * framebuffer every (approximately) 1 sec.
12 void timer_func(int unused);
14 /* color index will be advanced every time the timer expires */
25 int main(int argc, char **argv)
27 glutInit(&argc, argv);
28 glutInitWindowSize(128, 128);
29 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
30 glutCreateWindow("timer test");
32 glutDisplayFunc(disp);
34 /* get timer started, its reset in the timer function itself */
35 glutTimerFunc(1000, timer_func, 0);
43 glClearColor(color[cidx][0], color[cidx][1], color[cidx][2], 1);
44 glClear(GL_COLOR_BUFFER_BIT);
49 void timer_func(int unused)
51 /* advance the color index and trigger a redisplay */
52 cidx = (cidx + 1) % (sizeof color / sizeof *color);
55 /* (re)set the timer callback and ask glut to call it in 1 second */
56 glutTimerFunc(1000, timer_func, 0);