tune the preloads a bit
[sdl_omap.git] / docs / html / sdlsettimer.html
CommitLineData
e14743d1 1<HTML
2><HEAD
3><TITLE
4>SDL_SetTimer</TITLE
5><META
6NAME="GENERATOR"
7CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
8"><LINK
9REL="HOME"
10TITLE="SDL Library Documentation"
11HREF="index.html"><LINK
12REL="UP"
13TITLE="Time"
14HREF="time.html"><LINK
15REL="PREVIOUS"
16TITLE="SDL_RemoveTimer"
17HREF="sdlremovetimer.html"></HEAD
18><BODY
19CLASS="REFENTRY"
20BGCOLOR="#FFF8DC"
21TEXT="#000000"
22LINK="#0000ee"
23VLINK="#551a8b"
24ALINK="#ff0000"
25><DIV
26CLASS="NAVHEADER"
27><TABLE
28SUMMARY="Header navigation table"
29WIDTH="100%"
30BORDER="0"
31CELLPADDING="0"
32CELLSPACING="0"
33><TR
34><TH
35COLSPAN="3"
36ALIGN="center"
37>SDL Library Documentation</TH
38></TR
39><TR
40><TD
41WIDTH="10%"
42ALIGN="left"
43VALIGN="bottom"
44><A
45HREF="sdlremovetimer.html"
46ACCESSKEY="P"
47>Prev</A
48></TD
49><TD
50WIDTH="80%"
51ALIGN="center"
52VALIGN="bottom"
53></TD
54><TD
55WIDTH="10%"
56ALIGN="right"
57VALIGN="bottom"
58>&nbsp;</TD
59></TR
60></TABLE
61><HR
62ALIGN="LEFT"
63WIDTH="100%"></DIV
64><H1
65><A
66NAME="SDLSETTIMER"
67></A
68>SDL_SetTimer</H1
69><DIV
70CLASS="REFNAMEDIV"
71><A
72NAME="AEN8557"
73></A
74><H2
75>Name</H2
76>SDL_SetTimer&nbsp;--&nbsp;Set a callback to run after the specified number of milliseconds has
77elapsed.</DIV
78><DIV
79CLASS="REFSYNOPSISDIV"
80><A
81NAME="AEN8560"
82></A
83><H2
84>Synopsis</H2
85><DIV
86CLASS="FUNCSYNOPSIS"
87><A
88NAME="AEN8561"
89></A
90><P
91></P
92><PRE
93CLASS="FUNCSYNOPSISINFO"
94>#include "SDL.h"</PRE
95><P
96><CODE
97><CODE
98CLASS="FUNCDEF"
99>int <B
100CLASS="FSFUNC"
101>SDL_SetTimer</B
102></CODE
103>(Uint32 interval, SDL_TimerCallback callback);</CODE
104></P
105><P
106></P
107></DIV
108></DIV
109><DIV
110CLASS="REFSECT1"
111><A
112NAME="SDLTIMERCALLBACK"
113></A
114><H2
115>Callback</H2
116><P
117>/* Function prototype for the timer callback function */
118typedef Uint32 (*SDL_TimerCallback)(Uint32 interval);</P
119></DIV
120><DIV
121CLASS="REFSECT1"
122><A
123NAME="AEN8570"
124></A
125><H2
126>Description</H2
127><P
128>Set a callback to run after the specified number of milliseconds has
129elapsed. The callback function is passed the current timer interval
130and returns the next timer interval. If the returned value is the
131same as the one passed in, the periodic alarm continues, otherwise a
132new alarm is scheduled.</P
133><P
134>To cancel a currently running timer, call
135<TT
136CLASS="FUNCTION"
137>SDL_SetTimer(0, NULL);</TT
138></P
139><P
140>The timer callback function may run in a different thread than your
141main constant, and so shouldn't call any functions from within itself.</P
142><P
143>The maximum resolution of this timer is 10 ms, which means that if
144you request a 16 ms timer, your callback will run approximately 20 ms
145later on an unloaded system. If you wanted to set a flag signaling
146a frame update at 30 frames per second (every 33 ms), you might set a
147timer for 30 ms (see example below).</P
148><P
149>If you use this function, you need to pass <TT
150CLASS="LITERAL"
151>SDL_INIT_TIMER</TT
152>
153to <TT
154CLASS="FUNCTION"
155>SDL_Init()</TT
156>.</P
157><DIV
158CLASS="NOTE"
159><BLOCKQUOTE
160CLASS="NOTE"
161><P
162><B
163>Note: </B
164>This function is kept for compatibility but has been superseded
165by the new timer functions
166<A
167HREF="sdladdtimer.html"
168>SDL_AddTimer</A
169> and
170<A
171HREF="sdlremovetimer.html"
172>SDL_RemoveTimer</A
173> which support
174multiple timers.</P
175></BLOCKQUOTE
176></DIV
177></DIV
178><DIV
179CLASS="REFSECT1"
180><A
181NAME="AEN8584"
182></A
183><H2
184>Examples</H2
185><P
186><PRE
187CLASS="PROGRAMLISTING"
188>SDL_SetTimer((33/10)*10, my_callback);</PRE
189></P
190></DIV
191><DIV
192CLASS="REFSECT1"
193><A
194NAME="AEN8588"
195></A
196><H2
197>See Also</H2
198><P
199><A
200HREF="sdladdtimer.html"
201><TT
202CLASS="FUNCTION"
203>SDL_AddTimer</TT
204></A
205></P
206></DIV
207><DIV
208CLASS="NAVFOOTER"
209><HR
210ALIGN="LEFT"
211WIDTH="100%"><TABLE
212SUMMARY="Footer navigation table"
213WIDTH="100%"
214BORDER="0"
215CELLPADDING="0"
216CELLSPACING="0"
217><TR
218><TD
219WIDTH="33%"
220ALIGN="left"
221VALIGN="top"
222><A
223HREF="sdlremovetimer.html"
224ACCESSKEY="P"
225>Prev</A
226></TD
227><TD
228WIDTH="34%"
229ALIGN="center"
230VALIGN="top"
231><A
232HREF="index.html"
233ACCESSKEY="H"
234>Home</A
235></TD
236><TD
237WIDTH="33%"
238ALIGN="right"
239VALIGN="top"
240>&nbsp;</TD
241></TR
242><TR
243><TD
244WIDTH="33%"
245ALIGN="left"
246VALIGN="top"
247>SDL_RemoveTimer</TD
248><TD
249WIDTH="34%"
250ALIGN="center"
251VALIGN="top"
252><A
253HREF="time.html"
254ACCESSKEY="U"
255>Up</A
256></TD
257><TD
258WIDTH="33%"
259ALIGN="right"
260VALIGN="top"
261>&nbsp;</TD
262></TR
263></TABLE
264></DIV
265></BODY
266></HTML
267>