-
Notifications
You must be signed in to change notification settings - Fork 1
/
SDL_framerate.h
108 lines (83 loc) · 2.84 KB
/
SDL_framerate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
SDL_framerate.h: framerate manager
Copyright (C) 2001-2023 Andreas Schiffler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
Andreas Schiffler -- aschiffler at ferzkopp dot net
*/
#ifndef _SDL_framerate_h
#define _SDL_framerate_h
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/* --- */
#include "SDL.h"
/* --------- Definitions */
/*!
\brief Highest possible rate supported by framerate controller in Hz (1/s).
*/
#define FPS_UPPER_LIMIT 200
/*!
\brief Lowest possible rate supported by framerate controller in Hz (1/s).
*/
#define FPS_LOWER_LIMIT 1
/*!
\brief Default rate of framerate controller in Hz (1/s).
*/
#define FPS_DEFAULT 30
/*!
\brief Structure holding the state and timing information of the framerate controller.
*/
typedef struct {
Uint32 framecount;
float rateticks;
Uint32 baseticks;
Uint32 lastticks;
Uint32 rate;
} FPSmanager;
/* ---- Function Prototypes */
#ifdef _WIN32
# if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT)
# define SDL_FRAMERATE_SCOPE __declspec(dllexport)
# else
# ifdef LIBSDL_GFX_DLL_IMPORT
# define SDL_FRAMERATE_SCOPE __declspec(dllimport)
# endif
# endif
#elif defined(__OS2__)
# if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT)
# define SDL_FRAMERATE_SCOPE __declspec(dllexport)
# else
# define SDL_FRAMERATE_SCOPE extern
# endif
#elif defined(SDLGFX_SYM_VISIBILITY)
# define SDL_FRAMERATE_SCOPE __attribute__((visibility("default")))
#endif
#ifndef SDL_FRAMERATE_SCOPE
# define SDL_FRAMERATE_SCOPE extern
#endif
/* Functions return 0 or value for sucess and -1 for error */
SDL_FRAMERATE_SCOPE void SDL_initFramerate(FPSmanager * manager);
SDL_FRAMERATE_SCOPE int SDL_setFramerate(FPSmanager * manager, Uint32 rate);
SDL_FRAMERATE_SCOPE int SDL_getFramerate(FPSmanager * manager);
SDL_FRAMERATE_SCOPE int SDL_getFramecount(FPSmanager * manager);
SDL_FRAMERATE_SCOPE Uint32 SDL_framerateDelay(FPSmanager * manager);
/* --- */
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#endif /* _SDL_framerate_h */