include/SDL_timer.h
author Sam Lantinga <slouken@libsdl.org>
Fri, 11 Feb 2011 22:37:15 -0800
changeset 5262 b530ef003506
parent 5111 481dabb098ef
child 5514 6bd701987ba9
permissions -rw-r--r--
Happy 2011! :)
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@5262
     3
    Copyright (C) 1997-2011 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@251
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
#ifndef _SDL_timer_h
slouken@0
    24
#define _SDL_timer_h
slouken@0
    25
slouken@1895
    26
/**
slouken@3407
    27
 *  \file SDL_timer.h
slouken@3407
    28
 *  
slouken@3407
    29
 *  Header for the SDL time management routines.
slouken@1895
    30
 */
slouken@0
    31
slouken@1356
    32
#include "SDL_stdinc.h"
slouken@1358
    33
#include "SDL_error.h"
slouken@0
    34
slouken@0
    35
#include "begin_code.h"
slouken@0
    36
/* Set up for C function definitions, even when using C++ */
slouken@0
    37
#ifdef __cplusplus
slouken@1895
    38
/* *INDENT-OFF* */
slouken@0
    39
extern "C" {
slouken@1895
    40
/* *INDENT-ON* */
slouken@0
    41
#endif
slouken@0
    42
slouken@3407
    43
/**
slouken@5111
    44
 * \brief Get the number of milliseconds since the SDL library initialization.
slouken@3407
    45
 *  
slouken@5111
    46
 * \note This value wraps if the program runs for more than ~49 days.
slouken@1895
    47
 */
slouken@337
    48
extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void);
slouken@0
    49
slouken@3407
    50
/**
slouken@5111
    51
 * \brief Wait a specified number of milliseconds before returning.
slouken@3407
    52
 */
slouken@337
    53
extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
slouken@0
    54
slouken@3407
    55
/**
slouken@3407
    56
 *  Function prototype for the timer callback function.
slouken@3407
    57
 *  
slouken@3407
    58
 *  The callback function is passed the current timer interval and returns
slouken@3407
    59
 *  the next timer interval.  If the returned value is the same as the one
slouken@3407
    60
 *  passed in, the periodic alarm continues, otherwise a new alarm is
slouken@3407
    61
 *  scheduled.  If the callback returns 0, the periodic alarm is cancelled.
slouken@0
    62
 */
slouken@5111
    63
typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param);
slouken@0
    64
slouken@3407
    65
/**
slouken@5111
    66
 * Definition of the timer ID type.
slouken@3407
    67
 */
slouken@5111
    68
typedef int SDL_TimerID;
slouken@0
    69
slouken@3407
    70
/**
slouken@5111
    71
 * \brief Add a new timer to the pool of timers already running.
slouken@5111
    72
 *
slouken@5111
    73
 * \return A timer ID, or NULL when an error occurs.
slouken@0
    74
 */
slouken@1895
    75
extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval,
slouken@5111
    76
                                                 SDL_TimerCallback callback,
slouken@5111
    77
                                                 void *param);
slouken@0
    78
slouken@3407
    79
/**
slouken@5111
    80
 * \brief Remove a timer knowing its ID.
slouken@5111
    81
 *
slouken@5111
    82
 * \return A boolean value indicating success or failure.
slouken@5111
    83
 *
slouken@5111
    84
 * \warning It is not safe to remove a timer multiple times.
slouken@0
    85
 */
slouken@337
    86
extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t);
slouken@0
    87
slouken@3407
    88
slouken@0
    89
/* Ends C function definitions when using C++ */
slouken@0
    90
#ifdef __cplusplus
slouken@1895
    91
/* *INDENT-OFF* */
slouken@0
    92
}
slouken@1895
    93
/* *INDENT-ON* */
slouken@0
    94
#endif
slouken@0
    95
#include "close_code.h"
slouken@0
    96
slouken@0
    97
#endif /* _SDL_timer_h */
slouken@1895
    98
slouken@1895
    99
/* vi: set ts=4 sw=4 expandtab: */