Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > eee00533ac83fd7ebbf9846dc6d3b77b > files > 257

Io-language-graphics-and-sound-20080330-6.fc15.i686.rpm


<HTML><HEAD><TITLE>Manpage of glutIdleFunc</TITLE>
</HEAD><BODY>
<H1>glutIdleFunc</H1>
Section: GLUT (3GLUT)<BR>Updated: 3.7<BR><A HREF="#index">Index</A>
<A HREF="">Return to Main Contents</A><HR>

<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>

glutIdleFunc - sets the global idle callback. 
<A NAME="lbAC">&nbsp;</A>
<H2>SYNTAX</H2>

<PRE>

void glutIdleFunc(void (*func)(void));
</PRE>

<A NAME="lbAD">&nbsp;</A>
<H2>ARGUMENTS</H2>

<DL COMPACT>
<DT><I>func</I><DD>
The new idle callback function.
</DL>
<A NAME="lbAE">&nbsp;</A>
<H2>DESCRIPTION</H2>

glutIdleFunc sets the global idle callback to be func so a GLUT
program can perform background processing tasks or continuous
animation when window system events are not being received. If
enabled, the idle callback is continuously called when events are not
being received. The callback routine has no parameters. The current
window and current menu will not be changed before the idle callback.
Programs with multiple windows and/or menus should explicitly set the
current window and/or current menu and not rely on its current setting. 

The amount of computation and rendering done in an idle callback
should be minimized to avoid affecting the program's interactive
response. In general, not more than a single frame of rendering should be
done in an idle callback. 

Passing NULL to glutIdleFunc disables the generation of the idle
callback.
<A NAME="lbAF">&nbsp;</A>
<H2>EXAMPLE</H2>

A typical idle callback to animate a window might look like:
<PRE>

  void 
  idle(void)
  {
    time += 0.05;
    glutSetWindow(window);
    glutPostRedisplay();
  }
</PRE>

<P>

Notice how the idle callback does not do any actual drawing; it only
advances the time scene state global variable.  That
is left to the window's display callback which will be triggered
by the call to glutPostRedisplay.
<P>

If you use the idle callback for animation, you should be sure to stop
rendering when the window is not visible.  This is easy to set up
with a visibility callback.  For example:
<PRE>

  void
  visible(int vis)
  {
    if (vis == GLUT_VISIBLE)
      glutIdleFunc(idle);
    else
      glutIdleFunc(NULL);
  }
</PRE>

<P>

If you do use the idle callback for animation, one thing you should
<I>not</I>

do is setup the idle callback before calling glutMainLoop.  It is much
better to use the visibility callback to install idle callback when the
window first becomes visible on the screen.
<A NAME="lbAG">&nbsp;</A>
<H2>SEE ALSO</H2>

glutTimerFunc, glutVisibilityFunc
<A NAME="lbAH">&nbsp;</A>
<H2>AUTHOR</H2>

Mark J. Kilgard (<A HREF="mailto:mjk@nvidia.com">mjk@nvidia.com</A>)
<P>

<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT><A HREF="#lbAB">NAME</A><DD>
<DT><A HREF="#lbAC">SYNTAX</A><DD>
<DT><A HREF="#lbAD">ARGUMENTS</A><DD>
<DT><A HREF="#lbAE">DESCRIPTION</A><DD>
<DT><A HREF="#lbAF">EXAMPLE</A><DD>
<DT><A HREF="#lbAG">SEE ALSO</A><DD>
<DT><A HREF="#lbAH">AUTHOR</A><DD>
</DL>
<HR>
This document was created by
<A HREF="">man2html</A>,
using the manual pages.<BR>
Time: 19:05:09 GMT, September 15, 2003
</BODY>
</HTML>