All OpenGL rendering goes to the
Bf Li
current window
Ef
.
Many OpenGLUT functions also implicitly use the
Bf Li
current window
Ef
.
Many OpenGLUT callback operations are tied to a window.
When your callback is invoked, OpenGLUT will set that
particular window to be the
Bf Li
current window
Ef
.
However, some callbacks---such as that registered via
glutIdleFunc()---do not have associated windows. If
a callback is not associated to a particular window,
then when OpenGLUT invokes that callback
you should
Bf Em
always
Ef
use glutSetWindow() to
select the appropriate window before doing any
OpenGL rendering or doing any OpenGLUT window-related
operations.
There may be cases when you can get away with assuming
that the
Bf Li
current window
Ef
is unchanged since some
prior time, but OpenGLUT has considerable liberaty with
respect to when it invokes your functions. Also, your
program may add more windows or more operations on other
windows as you develop it.
Lastly, this is a convenient way to select among
multiple windows for drawing without actually waiting
for that window's display callback. Simply set the
Bf Li
current window
Ef
and draw immediately. This is
not always advisable, but may be practical.
It is an error to set the
Bf Li
current window
Ef
to
a non-existant window (e.g., one that you have closed).
A warning will be printed on
Bf Sy
stderr
Ef
if you
try to do so, and the
Bf Li
current window
Ef
should be
unchanged.