Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

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