X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=sidebyside;f=progs%2Fdemos%2Ftimer%2Ftimer.c;h=0f1b49f135a28d5296e3c5284f20510e859e829c;hb=3e5d1e857f4bf0e28d550c4ccf3aaa1617331a8f;hp=d9bd89b2655ea8ad45ec9eaa636649bc964858c3;hpb=f2582ac6c7d21fb7f96818f7c4f21d14f43cfa4d;p=freeglut diff --git a/progs/demos/timer/timer.c b/progs/demos/timer/timer.c index d9bd89b..0f1b49f 100644 --- a/progs/demos/timer/timer.c +++ b/progs/demos/timer/timer.c @@ -31,6 +31,9 @@ int main(int argc, char **argv) glutDisplayFunc(disp); + /* get timer started, its reset in the timer function itself */ + glutTimerFunc(1000, timer_func, 0); + glutMainLoop(); return 0; } @@ -40,8 +43,6 @@ void disp(void) 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(); } @@ -50,4 +51,7 @@ void timer_func(int unused) /* 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); }