version 2, including all changes.
.
Rev |
Author |
# |
Line |
2 |
perry |
1 |
SDL_!SetTimer |
|
|
2 |
!!!SDL_!SetTimer |
1 |
perry |
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
CALLBACK |
|
|
6 |
DESCRIPTION |
|
|
7 |
EXAMPLES |
|
|
8 |
SEE ALSO |
|
|
9 |
---- |
|
|
10 |
!!NAME |
|
|
11 |
|
|
|
12 |
|
2 |
perry |
13 |
SDL_!SetTimer- Set a callback to run after the specified number of milliseconds has elapsed. |
1 |
perry |
14 |
!!SYNOPSIS |
|
|
15 |
|
|
|
16 |
|
|
|
17 |
__#include __ |
|
|
18 |
|
|
|
19 |
|
2 |
perry |
20 |
__int SDL_!SetTimer__(__Uint32 interval, |
|
|
21 |
SDL_!TimerCallback callback__); |
1 |
perry |
22 |
!!CALLBACK |
|
|
23 |
|
|
|
24 |
|
|
|
25 |
/* Function prototype for the timer callback function */ |
2 |
perry |
26 |
typedef Uint32 (*SDL_!TimerCallback)(Uint32 |
1 |
perry |
27 |
interval); |
|
|
28 |
!!DESCRIPTION |
|
|
29 |
|
|
|
30 |
|
|
|
31 |
Set a callback to run after the specified number of |
|
|
32 |
milliseconds has elapsed. The callback function is passed |
|
|
33 |
the current timer interval and returns the next timer |
|
|
34 |
interval. If the returned value is the same as the one |
|
|
35 |
passed in, the periodic alarm continues, otherwise a new |
|
|
36 |
alarm is scheduled. |
|
|
37 |
|
|
|
38 |
|
2 |
perry |
39 |
To cancel a currently running timer, call __SDL_!SetTimer(0, |
1 |
perry |
40 |
NULL);__ |
|
|
41 |
|
|
|
42 |
|
|
|
43 |
The timer callback function may run in a different thread |
|
|
44 |
than your main constant, and so shouldn't call any functions |
|
|
45 |
from within itself. |
|
|
46 |
|
|
|
47 |
|
|
|
48 |
The maximum resolution of this timer is 10 ms, which means |
|
|
49 |
that if you request a 16 ms timer, your callback will run |
|
|
50 |
approximately 20 ms later on an unloaded system. If you |
|
|
51 |
wanted to set a flag signaling a frame update at 30 frames |
|
|
52 |
per second (every 33 ms), you might set a timer for 30 ms |
|
|
53 |
(see example below). |
|
|
54 |
|
|
|
55 |
|
|
|
56 |
If you use this function, you need to pass |
|
|
57 |
__SDL_INIT_TIMER__ to __SDL_Init()__. |
|
|
58 |
|
|
|
59 |
|
|
|
60 |
__Note:__ |
|
|
61 |
|
|
|
62 |
|
|
|
63 |
This function is kept for compatibility but has been |
2 |
perry |
64 |
superceeded by the new timer functions ''SDL_!AddTimer'' |
|
|
65 |
and ''SDL_!RemoveTimer'' which support multiple |
1 |
perry |
66 |
timers. |
|
|
67 |
!!EXAMPLES |
|
|
68 |
|
|
|
69 |
|
2 |
perry |
70 |
SDL_!SetTimer((33/10)*10, my_callback); |
1 |
perry |
71 |
!!SEE ALSO |
|
|
72 |
|
|
|
73 |
|
2 |
perry |
74 |
__SDL_!AddTimer__ |
1 |
perry |
75 |
---- |