moved glutTimerFunc in timer demo
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1121 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
19095d15bf
commit
b6e8aa6776
@ -31,6 +31,9 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
glutDisplayFunc(disp);
|
glutDisplayFunc(disp);
|
||||||
|
|
||||||
|
/* get timer started, its reset in the timer function itself */
|
||||||
|
glutTimerFunc(1000, timer_func, 0);
|
||||||
|
|
||||||
glutMainLoop();
|
glutMainLoop();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -40,8 +43,6 @@ void disp(void)
|
|||||||
glClearColor(color[cidx][0], color[cidx][1], color[cidx][2], 1);
|
glClearColor(color[cidx][0], color[cidx][1], color[cidx][2], 1);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
/* set the timer callback and ask glut to call it in 1 second */
|
|
||||||
glutTimerFunc(1000, timer_func, 0);
|
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,4 +51,7 @@ void timer_func(int unused)
|
|||||||
/* advance the color index and trigger a redisplay */
|
/* advance the color index and trigger a redisplay */
|
||||||
cidx = (cidx + 1) % (sizeof color / sizeof *color);
|
cidx = (cidx + 1) % (sizeof color / sizeof *color);
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
|
|
||||||
|
/* (re)set the timer callback and ask glut to call it in 1 second */
|
||||||
|
glutTimerFunc(1000, timer_func, 0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user