how to setup glut main loop

Solutions on MaxInterview for how to setup glut main loop by the best coders in the world

showing results for - "how to setup glut main loop"
Theo
10 Oct 2016
1It calls your display callback over and over, 
2calling idle between so that it can maintain a specific framerate if possible, 
3and others if necessary (such as if you resize the window or trigger an input event).
4Essentially, within this function is the main program loop, where GLUT does most of the work for you and allows you to simply set up the specific program logic in these callbacks.
5In your display callback should obviously be your main logic to draw whatever it is that should be going on.
6In the idle callback should be some very lightweight operations to determine what the change in state should be from the last time display was called to the next time. 
7For example, if you're animating something, this would be where you change its position or orientation.