comparison include/SDL_timer.h @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents c71e05b4dc2e
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
21 */ 21 */
22 22
23 #ifndef _SDL_timer_h 23 #ifndef _SDL_timer_h
24 #define _SDL_timer_h 24 #define _SDL_timer_h
25 25
26 /* Header for the SDL time management routines */ 26 /**
27 * \file SDL_timer.h
28 *
29 * Header for the SDL time management routines
30 */
27 31
28 #include "SDL_stdinc.h" 32 #include "SDL_stdinc.h"
29 #include "SDL_error.h" 33 #include "SDL_error.h"
30 34
31 #include "begin_code.h" 35 #include "begin_code.h"
32 /* Set up for C function definitions, even when using C++ */ 36 /* Set up for C function definitions, even when using C++ */
33 #ifdef __cplusplus 37 #ifdef __cplusplus
38 /* *INDENT-OFF* */
34 extern "C" { 39 extern "C" {
40 /* *INDENT-ON* */
35 #endif 41 #endif
36 42
37 /* This is the OS scheduler timeslice, in milliseconds */ 43 /* This is the OS scheduler timeslice, in milliseconds */
38 #define SDL_TIMESLICE 10 44 #define SDL_TIMESLICE 10
39 45
40 /* This is the maximum resolution of the SDL timer on all platforms */ 46 /* This is the maximum resolution of the SDL timer on all platforms */
41 #define TIMER_RESOLUTION 10 /* Experimentally determined */ 47 #define TIMER_RESOLUTION 10 /* Experimentally determined */
42 48
43 /* Get the number of milliseconds since the SDL library initialization. 49 /* Get the number of milliseconds since the SDL library initialization.
44 * Note that this value wraps if the program runs for more than ~49 days. 50 * Note that this value wraps if the program runs for more than ~49 days.
45 */ 51 */
46 extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); 52 extern DECLSPEC Uint32 SDLCALL SDL_GetTicks (void);
47 53
48 /* Wait a specified number of milliseconds before returning */ 54 /* Wait a specified number of milliseconds before returning */
49 extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); 55 extern DECLSPEC void SDLCALL SDL_Delay (Uint32 ms);
50 56
51 /* Function prototype for the timer callback function */ 57 /* Function prototype for the timer callback function */
52 typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval); 58 typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval);
53 59
54 /* Set a callback to run after the specified number of milliseconds has 60 /* Set a callback to run after the specified number of milliseconds has
55 * elapsed. The callback function is passed the current timer interval 61 * elapsed. The callback function is passed the current timer interval
56 * and returns the next timer interval. If the returned value is the 62 * and returns the next timer interval. If the returned value is the
57 * same as the one passed in, the periodic alarm continues, otherwise a 63 * same as the one passed in, the periodic alarm continues, otherwise a
77 * should not use this function in multi-threaded applications as signals 83 * should not use this function in multi-threaded applications as signals
78 * to multi-threaded apps have undefined behavior in some implementations. 84 * to multi-threaded apps have undefined behavior in some implementations.
79 * 85 *
80 * This function returns 0 if successful, or -1 if there was an error. 86 * This function returns 0 if successful, or -1 if there was an error.
81 */ 87 */
82 extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback); 88 extern DECLSPEC int SDLCALL SDL_SetTimer (Uint32 interval,
89 SDL_TimerCallback callback);
83 90
84 /* New timer API, supports multiple timers 91 /* New timer API, supports multiple timers
85 * Written by Stephane Peter <megastep@lokigames.com> 92 * Written by Stephane Peter <megastep@lokigames.com>
86 */ 93 */
87 94
89 * The callback function is passed the current timer interval and returns 96 * The callback function is passed the current timer interval and returns
90 * the next timer interval. If the returned value is the same as the one 97 * the next timer interval. If the returned value is the same as the one
91 * passed in, the periodic alarm continues, otherwise a new alarm is 98 * passed in, the periodic alarm continues, otherwise a new alarm is
92 * scheduled. If the callback returns 0, the periodic alarm is cancelled. 99 * scheduled. If the callback returns 0, the periodic alarm is cancelled.
93 */ 100 */
94 typedef Uint32 (SDLCALL *SDL_NewTimerCallback)(Uint32 interval, void *param); 101 typedef Uint32 (SDLCALL * SDL_NewTimerCallback) (Uint32 interval,
102 void *param);
95 103
96 /* Definition of the timer ID type */ 104 /* Definition of the timer ID type */
97 typedef struct _SDL_TimerID *SDL_TimerID; 105 typedef struct _SDL_TimerID *SDL_TimerID;
98 106
99 /* Add a new timer to the pool of timers already running. 107 /* Add a new timer to the pool of timers already running.
100 Returns a timer ID, or NULL when an error occurs. 108 Returns a timer ID, or NULL when an error occurs.
101 */ 109 */
102 extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param); 110 extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer (Uint32 interval,
111 SDL_NewTimerCallback
112 callback, void *param);
103 113
104 /* Remove one of the multiple timers knowing its ID. 114 /* Remove one of the multiple timers knowing its ID.
105 * Returns a boolean value indicating success. 115 * Returns a boolean value indicating success.
106 */ 116 */
107 extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t); 117 extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer (SDL_TimerID t);
108 118
109 /* Ends C function definitions when using C++ */ 119 /* Ends C function definitions when using C++ */
110 #ifdef __cplusplus 120 #ifdef __cplusplus
121 /* *INDENT-OFF* */
111 } 122 }
123 /* *INDENT-ON* */
112 #endif 124 #endif
113 #include "close_code.h" 125 #include "close_code.h"
114 126
115 #endif /* _SDL_timer_h */ 127 #endif /* _SDL_timer_h */
128
129 /* vi: set ts=4 sw=4 expandtab: */