home *** CD-ROM | disk | FTP | other *** search
- <!-- manual page source format generated by PolyglotMan v3.0.8+X.Org, -->
- <!-- available at http://polyglotman.sourceforge.net/ -->
-
- <html>
- <head>
- <title>"SDL_AddTimer"("3") manual page</title>
- </head>
- <body bgcolor='#efefef' text='black' link='blue' vlink='#551A8B' alink='red'>
- <a href='#toc'>Table of Contents</a><p>
-
- <h2><a name='sect0' href='#toc0'>Name</a></h2>
- SDL_AddTimer- Add a timer which will call a callback after the specified
- number of milliseconds has elapsed.
- <h2><a name='sect1' href='#toc1'>Synopsis</a></h2>
- <p>
- <b>#include "SDL.h" <p>
- </b><b>SDL_TimerID
- <b>SDL_AddTimer</b></b>(<b>Uint32 interval, SDL_NewTimerCallback callback, void *param</b>);
-
- <h2><a name='sect2' href='#toc2'>Callback</a></h2>
- <p>
- <br>
- <pre>CW/* type definition for the "new" timer callback function */
- typedef Uint32 (*SDL_NewTimerCallback)(Uint32 interval, void *param);
- </pre><p>
-
- <h2><a name='sect3' href='#toc3'>Description</a></h2>
- <p>
- Adds a callback function to be run after the specified number
- of milliseconds has elapsed. The callback function is passed the current
- timer interval and the user supplied parameter from the <b>SDL_AddTimer</b> call
- and returns the next timer interval. If the returned value from the callback
- is the same as the one passed in, the periodic alarm continues, otherwise
- a new alarm is scheduled. <p>
- To cancel a currently running timer call <i>SDL_RemoveTimer</i>
- with the timer ID returned from <b>SDL_AddTimer</b>. <p>
- The timer callback function
- may run in a different thread than your main program, and so shouldn't call
- any functions from within itself. You may always call <i>SDL_PushEvent</i>, however.
- <p>
- The granularity of the timer is platform-dependent, but you should count
- on it being at least 10 ms as this is the most common number. This means
- that if you request a 16 ms timer, your callback will run approximately
- 20 ms later on an unloaded system. If you wanted to set a flag signaling
- a frame update at 30 frames per second (every 33 ms), you might set a timer
- for 30 ms (see example below). If you use this function, you need to pass
- <b>SDL_INIT_TIMER</b> to <i>SDL_Init</i>.
- <h2><a name='sect4' href='#toc4'>Return Value</a></h2>
- <p>
- Returns an ID value for the added
- timer or <b>NULL</b> if there was an error.
- <h2><a name='sect5' href='#toc5'>Examples</a></h2>
- <p>
- <p>
- <br>
- <pre>CWmy_timer_id = SDL_AddTimer((33/10)*10, my_callbackfunc, my_callback_param);
- </pre><p>
-
- <h2><a name='sect6' href='#toc6'>See Also</a></h2>
- <p>
- <i><b>SDL_RemoveTimer</b></i>, <i><b>SDL_PushEvent</b></i>
- <!--
-
- <p>
-
- <hr><p>
- <a name='toc'><b>Table of Contents</b></a><p>
- <ul>
- <li><a name='toc0' href='#sect0'>Name</a></li>
- <li><a name='toc1' href='#sect1'>Synopsis</a></li>
- <li><a name='toc2' href='#sect2'>Callback</a></li>
- <li><a name='toc3' href='#sect3'>Description</a></li>
- <li><a name='toc4' href='#sect4'>Return Value</a></li>
- <li><a name='toc5' href='#sect5'>Examples</a></li>
- <li><a name='toc6' href='#sect6'>See Also</a></li>
- </ul>
- </body>
- </html>
-