If you need some sort of regular updating, you probably want to set a glutIdleFunc
. This is a function that will get called in a loop whenever there are no events coming in to be processed. If you instead want to call something at regular intervals (as opposed to as fast as possible), you might want to try glutTimerFunc
which allows you to schedule something to be run by the GLUT loop some number of milliseconds in the future.
As for your second question, if you need to sleep for fractions of seconds, you might want to try usleep
for microsecond resolution sleep periods, or nanosleep
to specify sleep periods in nanoseconds (though you're not actually going to get nanosecond resolution). I don't know what platform you're on or if these are available on Windows, but they should be available on any POSIX compatible system (Linux, BSD, Mac OS X). But perhaps for your purposes glutTimerFunc
will work better.
edit to add: It looks like on Windows you would need to use Sleep
(note the capital S
), which takes a time in milliseconds.