The "freeglut" library has two ways to leave the main loop (without
leaving the program or closing down windows)....

  I have pointed out before that the GLUT way of using the screen is backwards from what real time data-oriented (as opposed to mouse/keyboard oriented) applications require. Using glutMainLoopEvent() means that the display gives up the thread to the rest of the program. In many applications (such as video streaming), the other way around is the natural approach. One would rather the time-critical part of the code refresh/update the display when time is available.
   It is nevertheless possible to work this way using freeglut, although some workarounds are needed to obtain OS-related features such as resizing windows. Note that no MainLoop is actually needed:

Init
create window
draw
draw
...
while ()
     { display }
exit

 Note that screen activity occurs only when the application calls for it. My application takes data from a radar; giving up control to the OS via glutMainLoopEvent() risks losing data and is more of a workaround than recreating MainLoop features as they are needed. It would be most helpful if the various features that glutMainLoopEvent() encompasses were available separately at the API so the approach above would be more conventional.

Regards, Ron Larkin

Ronald P. Larkin, Ph.D., Illinois Natural History Survey
1816 S. Oak Street, Champaign, IL 61820  USA
r-larkin@uiuc.edu (Ron Larkin)