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);
40 glClearColor(color[cidx][0], color[cidx][1], color[cidx][2], 1);
41 glClear(GL_COLOR_BUFFER_BIT);
43 /* set the timer callback and ask glut to call it in 1 second */
44 glutTimerFunc(1000, timer_func, 0);
48 void timer_func(int unused)
50 /* advance the color index and trigger a redisplay */
51 cidx = (cidx + 1) % (sizeof color / sizeof *color);