home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !SDL / man / SDL_AddTimer.3 < prev    next >
Encoding:
Text File  |  2006-09-20  |  2.9 KB  |  79 lines

  1. <!-- manual page source format generated by PolyglotMan v3.0.8+X.Org, -->
  2. <!-- available at http://polyglotman.sourceforge.net/ -->
  3.  
  4. <html>
  5. <head>
  6. <title>"SDL_AddTimer"("3") manual page</title>
  7. </head>
  8. <body bgcolor='#efefef' text='black' link='blue' vlink='#551A8B' alink='red'>
  9. <a href='#toc'>Table of Contents</a><p>
  10.  
  11. <h2><a name='sect0' href='#toc0'>Name</a></h2>
  12. SDL_AddTimer- Add a timer which will call a callback after the specified
  13. number of milliseconds has elapsed. 
  14. <h2><a name='sect1' href='#toc1'>Synopsis</a></h2>
  15. <p>
  16. <b>#include "SDL.h" <p>
  17. </b><b>SDL_TimerID
  18. <b>SDL_AddTimer</b></b>(<b>Uint32 interval, SDL_NewTimerCallback callback, void *param</b>);
  19.  
  20. <h2><a name='sect2' href='#toc2'>Callback</a></h2>
  21. <p>
  22. <br>
  23. <pre>CW/* type definition for the "new" timer callback function */
  24. typedef Uint32 (*SDL_NewTimerCallback)(Uint32 interval, void *param);
  25. </pre><p>
  26.  
  27. <h2><a name='sect3' href='#toc3'>Description</a></h2>
  28. <p>
  29. Adds a callback function to be run after the specified number
  30. of milliseconds has elapsed. The callback function is passed the current
  31. timer interval and the user supplied parameter from the <b>SDL_AddTimer</b> call
  32. and returns the next timer interval. If the returned value from the callback
  33. is the same as the one passed in, the periodic alarm continues, otherwise
  34. a new alarm is scheduled. <p>
  35. To cancel a currently running timer call <i>SDL_RemoveTimer</i>
  36. with the timer ID returned from <b>SDL_AddTimer</b>. <p>
  37. The timer callback function
  38. may run in a different thread than your main program, and so shouldn't call
  39. any functions from within itself. You may always call <i>SDL_PushEvent</i>, however.
  40. <p>
  41. The granularity of the timer is platform-dependent, but you should count
  42. on it being at least 10 ms as this is the most common number. This means
  43. that if you request a 16 ms timer, your callback will run approximately
  44. 20 ms later on an unloaded system. If you wanted to set a flag signaling
  45. a frame update at 30 frames per second (every 33 ms), you might set a timer
  46. for 30 ms (see example below). If you use this function, you need to pass
  47. <b>SDL_INIT_TIMER</b> to <i>SDL_Init</i>. 
  48. <h2><a name='sect4' href='#toc4'>Return Value</a></h2>
  49. <p>
  50. Returns an ID value for the added
  51. timer or <b>NULL</b> if there was an error. 
  52. <h2><a name='sect5' href='#toc5'>Examples</a></h2>
  53. <p>
  54. <p>
  55. <br>
  56. <pre>CWmy_timer_id = SDL_AddTimer((33/10)*10, my_callbackfunc, my_callback_param);
  57. </pre><p>
  58.  
  59. <h2><a name='sect6' href='#toc6'>See Also</a></h2>
  60. <p>
  61. <i><b>SDL_RemoveTimer</b></i>, <i><b>SDL_PushEvent</b></i> 
  62. <!--
  63.   
  64.  <p>
  65.  
  66. <hr><p>
  67. <a name='toc'><b>Table of Contents</b></a><p>
  68. <ul>
  69. <li><a name='toc0' href='#sect0'>Name</a></li>
  70. <li><a name='toc1' href='#sect1'>Synopsis</a></li>
  71. <li><a name='toc2' href='#sect2'>Callback</a></li>
  72. <li><a name='toc3' href='#sect3'>Description</a></li>
  73. <li><a name='toc4' href='#sect4'>Return Value</a></li>
  74. <li><a name='toc5' href='#sect5'>Examples</a></li>
  75. <li><a name='toc6' href='#sect6'>See Also</a></li>
  76. </ul>
  77. </body>
  78. </html>
  79.