Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5131 clevermous 1
2
>
3
>
4
>SDL_AddTimer
5
>
6
NAME="GENERATOR"
7
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
8
">
9
REL="HOME"
10
TITLE="SDL Library Documentation"
11
HREF="index.html">
12
REL="UP"
13
TITLE="Time"
14
HREF="time.html">
15
REL="PREVIOUS"
16
TITLE="SDL_Delay"
17
HREF="sdldelay.html">
18
REL="NEXT"
19
TITLE="SDL_RemoveTimer"
20
HREF="sdlremovetimer.html">
21
>
22
CLASS="REFENTRY"
23
BGCOLOR="#FFF8DC"
24
TEXT="#000000"
25
LINK="#0000ee"
26
VLINK="#551a8b"
27
ALINK="#ff0000"
28
>
29
CLASS="NAVHEADER"
30
>
31
WIDTH="100%"
32
BORDER="0"
33
CELLPADDING="0"
34
CELLSPACING="0"
35
>
36
>
37
COLSPAN="3"
38
ALIGN="center"
39
>SDL Library Documentation
40
>
41
>
42
>
43
WIDTH="10%"
44
ALIGN="left"
45
VALIGN="bottom"
46
>
47
HREF="sdldelay.html"
48
>Prev
49
>
50
>
51
WIDTH="80%"
52
ALIGN="center"
53
VALIGN="bottom"
54
>
55
>
56
WIDTH="10%"
57
ALIGN="right"
58
VALIGN="bottom"
59
>
60
HREF="sdlremovetimer.html"
61
>Next
62
>
63
>
64
>
65
>
66
ALIGN="LEFT"
67
WIDTH="100%">
68
>
69
>
70
NAME="SDLADDTIMER"
71
>SDL_AddTimer
72
>
73
>
74
CLASS="REFNAMEDIV"
75
>
76
NAME="AEN7933"
77
>
78
>
79
>Name
80
>SDL_AddTimer -- Add a timer which will call a callback after the specified number of milliseconds has
81
elapsed.
82
>
83
CLASS="REFSYNOPSISDIV"
84
>
85
NAME="AEN7936"
86
>
87
>
88
>Synopsis
89
>
90
CLASS="FUNCSYNOPSIS"
91
>
92
NAME="AEN7937"
93
>
94
>
95
>
96
>
97
CLASS="FUNCSYNOPSISINFO"
98
>#include "SDL.h"
99
>
100
>
101
>
102
CLASS="FUNCDEF"
103
>SDL_TimerID 
104
CLASS="FSFUNC"
105
>SDL_AddTimer
106
>
107
>(Uint32 interval, SDL_NewTimerCallback callback, void *param);
108
>
109
>
110
>
111
>
112
>
113
>
114
CLASS="REFSECT1"
115
>
116
NAME="SDLNEWTIMERCALLBACK"
117
>
118
>
119
>Callback
120
>
121
CLASS="PROGRAMLISTING"
122
>/* type definition for the "new" timer callback function */
123
typedef Uint32 (*SDL_NewTimerCallback)(Uint32 interval, void *param);
124
>
125
>
126
CLASS="REFSECT1"
127
>
128
NAME="AEN7946"
129
>
130
>
131
>Description
132
>
133
>Adds a callback function to be run after the specified number of
134
milliseconds has elapsed. The callback function is passed the current
135
timer interval and the user supplied parameter from the
136
137
CLASS="FUNCTION"
138
>SDL_AddTimer
139
> call and returns the next timer
140
interval. If the returned value from the callback is the same as the one
141
passed in, the periodic alarm continues, otherwise a new alarm is
142
scheduled.
143
>
144
>To cancel a currently running timer call
145
146
HREF="sdlremovetimer.html"
147
>SDL_RemoveTimer
148
> with the
149
timer ID returned from
150
151
CLASS="FUNCTION"
152
>SDL_AddTimer
153
>.
154
>
155
>The timer callback function may run in a different thread than your
156
main program, and so shouldn't call any functions from within itself.
157
You may always call 
158
HREF="sdlpushevent.html"
159
>SDL_PushEvent
160
>, however.
161
>
162
>The granularity of the timer is platform-dependent, but you should count
163
on it being at least 10 ms as this is the most common number.
164
This means that if
165
you request a 16 ms timer, your callback will run approximately 20 ms
166
later on an unloaded system.  If you wanted to set a flag signaling
167
a frame update at 30 frames per second (every 33 ms), you might set a
168
timer for 30 ms (see example below).
169
 
170
If you use this function, you need to pass 
171
CLASS="LITERAL"
172
>SDL_INIT_TIMER
173
>
174
to 
175
HREF="sdlinit.html"
176
>SDL_Init
177
>.
178
>
179
>
180
CLASS="REFSECT1"
181
>
182
NAME="AEN7958"
183
>
184
>
185
>Return Value
186
>
187
>Returns an ID value for the added timer or
188
189
CLASS="RETURNVALUE"
190
>NULL
191
> if there was an error.
192
>
193
>
194
CLASS="REFSECT1"
195
>
196
NAME="AEN7962"
197
>
198
>
199
>Examples
200
>
201
>
202
CLASS="PROGRAMLISTING"
203
>my_timer_id = SDL_AddTimer((33/10)*10, my_callbackfunc, my_callback_param);
204
>
205
>
206
>
207
CLASS="REFSECT1"
208
>
209
NAME="AEN7966"
210
>
211
>
212
>See Also
213
>
214
>
215
HREF="sdlremovetimer.html"
216
>
217
CLASS="FUNCTION"
218
>SDL_RemoveTimer
219
>
220
>,
221
222
HREF="sdlpushevent.html"
223
>
224
CLASS="FUNCTION"
225
>SDL_PushEvent
226
>
227
>
228
>
229
>
230
CLASS="NAVFOOTER"
231
>
232
ALIGN="LEFT"
233
WIDTH="100%">
234
WIDTH="100%"
235
BORDER="0"
236
CELLPADDING="0"
237
CELLSPACING="0"
238
>
239
>
240
WIDTH="33%"
241
ALIGN="left"
242
VALIGN="top"
243
>
244
HREF="sdldelay.html"
245
>Prev
246
>
247
>
248
WIDTH="34%"
249
ALIGN="center"
250
VALIGN="top"
251
>
252
HREF="index.html"
253
>Home
254
>
255
>
256
WIDTH="33%"
257
ALIGN="right"
258
VALIGN="top"
259
>
260
HREF="sdlremovetimer.html"
261
>Next
262
>
263
>
264
>
265
>
266
WIDTH="33%"
267
ALIGN="left"
268
VALIGN="top"
269
>SDL_Delay
270
>
271
WIDTH="34%"
272
ALIGN="center"
273
VALIGN="top"
274
>
275
HREF="time.html"
276
>Up
277
>
278
>
279
WIDTH="33%"
280
ALIGN="right"
281
VALIGN="top"
282
>SDL_RemoveTimer
283
>
284
>
285
>
286
>
287
>
288
>