include/SDL_timer.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 29 Dec 2011 13:51:42 -0500
changeset 6119 1865b52c093d
parent 5535 96594ac5fd1a
child 6138 4c64952a58fb
permissions -rw-r--r--
Fixed so the header is consistent with the source
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@5535
     3
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
slouken@0
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@0
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@0
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    20
*/
slouken@0
    21
slouken@0
    22
#ifndef _SDL_timer_h
slouken@0
    23
#define _SDL_timer_h
slouken@0
    24
slouken@1895
    25
/**
slouken@3407
    26
 *  \file SDL_timer.h
slouken@3407
    27
 *  
slouken@3407
    28
 *  Header for the SDL time management routines.
slouken@1895
    29
 */
slouken@0
    30
slouken@1356
    31
#include "SDL_stdinc.h"
slouken@1358
    32
#include "SDL_error.h"
slouken@0
    33
slouken@0
    34
#include "begin_code.h"
slouken@0
    35
/* Set up for C function definitions, even when using C++ */
slouken@0
    36
#ifdef __cplusplus
slouken@1895
    37
/* *INDENT-OFF* */
slouken@0
    38
extern "C" {
slouken@1895
    39
/* *INDENT-ON* */
slouken@0
    40
#endif
slouken@0
    41
slouken@3407
    42
/**
slouken@5111
    43
 * \brief Get the number of milliseconds since the SDL library initialization.
slouken@3407
    44
 *  
slouken@5111
    45
 * \note This value wraps if the program runs for more than ~49 days.
slouken@1895
    46
 */
slouken@337
    47
extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void);
slouken@0
    48
slouken@3407
    49
/**
slouken@5514
    50
 * \brief Get the current value of the high resolution counter
slouken@5514
    51
 */
slouken@5514
    52
extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void);
slouken@5514
    53
slouken@5514
    54
/**
slouken@5514
    55
 * \brief Get the count per second of the high resolution counter
slouken@5514
    56
 */
slouken@5514
    57
extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void);
slouken@5514
    58
slouken@5514
    59
/**
slouken@5111
    60
 * \brief Wait a specified number of milliseconds before returning.
slouken@3407
    61
 */
slouken@337
    62
extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
slouken@0
    63
slouken@3407
    64
/**
slouken@3407
    65
 *  Function prototype for the timer callback function.
slouken@3407
    66
 *  
slouken@3407
    67
 *  The callback function is passed the current timer interval and returns
slouken@3407
    68
 *  the next timer interval.  If the returned value is the same as the one
slouken@3407
    69
 *  passed in, the periodic alarm continues, otherwise a new alarm is
slouken@3407
    70
 *  scheduled.  If the callback returns 0, the periodic alarm is cancelled.
slouken@0
    71
 */
slouken@5111
    72
typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param);
slouken@0
    73
slouken@3407
    74
/**
slouken@5111
    75
 * Definition of the timer ID type.
slouken@3407
    76
 */
slouken@5111
    77
typedef int SDL_TimerID;
slouken@0
    78
slouken@3407
    79
/**
slouken@5111
    80
 * \brief Add a new timer to the pool of timers already running.
slouken@5111
    81
 *
slouken@5111
    82
 * \return A timer ID, or NULL when an error occurs.
slouken@0
    83
 */
slouken@1895
    84
extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval,
slouken@5111
    85
                                                 SDL_TimerCallback callback,
slouken@5111
    86
                                                 void *param);
slouken@0
    87
slouken@3407
    88
/**
slouken@5111
    89
 * \brief Remove a timer knowing its ID.
slouken@5111
    90
 *
slouken@5111
    91
 * \return A boolean value indicating success or failure.
slouken@5111
    92
 *
slouken@5111
    93
 * \warning It is not safe to remove a timer multiple times.
slouken@0
    94
 */
slouken@6119
    95
extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id);
slouken@0
    96
slouken@3407
    97
slouken@0
    98
/* Ends C function definitions when using C++ */
slouken@0
    99
#ifdef __cplusplus
slouken@1895
   100
/* *INDENT-OFF* */
slouken@0
   101
}
slouken@1895
   102
/* *INDENT-ON* */
slouken@0
   103
#endif
slouken@0
   104
#include "close_code.h"
slouken@0
   105
slouken@0
   106
#endif /* _SDL_timer_h */
slouken@1895
   107
slouken@1895
   108
/* vi: set ts=4 sw=4 expandtab: */