Constant game speed independent of variable FPS in OpenGL with GLUT?

后端 未结 3 558
一个人的身影
一个人的身影 2021-02-03 12:16

I\'ve been reading Koen Witters detailed article about different game loop solutions but I\'m having some problems implementing the last one with GLUT, which is the recommended

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-03 12:42

    You could use glutIdleFunc, which is called continuously whenever possible--similar to the while(game_is_running) loop. That is, whatever logic you would otherwise put into that while loop, you could put into the callback for glutIdleFunc. You can avoid using glutTimerFunc by keeping track of the ticks on your own, as in the article you linked (using glutGet(GLUT_ELAPSED_TIME)).

提交回复
热议问题