Animation
As we have seen, the screen window will only be redrawn whenever the display callback function is invoked. This occurs automatically when the window is resized or uncovered. You can explicitly force the display callback to be invoked by issuing the function:
glutPostRedisplay(); /* post redraw event on event queue */which places a redraw event on the window's event queue.
To perform a simulation we obviously want to continually update the window, however, we do not want to constantly issue a stream of glutPostRedisplay functions. We need a mechanism for the window to be continually updated automatically.
In addition to the types of callback functions that we have discussed so far, there are two additional callback types that are helpful in this regard.The idle callback specifies a function that is invoked whenever the system is not handling any other callbacks or events.
void (*idleCB)(void); /* function pointer to idle callback */ glutIdleFunc(idleCB);
The timer callback specifies a function that is invoked after a specified time period.
void (*timerCB)(int); /* function pointer to timer callback */ unsigned int msecs; /* time interval, in milliseconds */ int value; /* timer identifier */ glutTimerFunc(msecs, timerCB, value);When the timer callback function timerCB is invoked, after a time interval of msecs milliseconds, the identifier value is passed in as an argument.
Note that the timer callback function is only invoked once, msecs milliseconds after the call to glutTimerFunc. To have the timer callback invoked automatically every msecs milliseconds, place a second call to glutTimerFunc inside of the timerCB function.
On to input...
Back to text fonts...
Back to the 13.016 overview...