summaryrefslogtreecommitdiff
path: root/src/sdl2gfx/SDL2_framerate.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-11-09 17:59:14 +0300
committerAndrei Karas <akaras@inbox.ru>2013-11-09 17:59:14 +0300
commitdb1e60556c72b1b87ff2a384c556ccca724c46d6 (patch)
tree22a5f4e9c4f436ef8e746e0a2d688de80c1597a6 /src/sdl2gfx/SDL2_framerate.h
parentc2bb49be52a92deccec7428b6859242688fc8987 (diff)
parent1716861f0ee2f7a3714c5b44bb0f017c3d8d3b2c (diff)
downloadplus-db1e60556c72b1b87ff2a384c556ccca724c46d6.tar.gz
plus-db1e60556c72b1b87ff2a384c556ccca724c46d6.tar.bz2
plus-db1e60556c72b1b87ff2a384c556ccca724c46d6.tar.xz
plus-db1e60556c72b1b87ff2a384c556ccca724c46d6.zip
Merge branch 'master' into stable
Diffstat (limited to 'src/sdl2gfx/SDL2_framerate.h')
-rw-r--r--src/sdl2gfx/SDL2_framerate.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/sdl2gfx/SDL2_framerate.h b/src/sdl2gfx/SDL2_framerate.h
new file mode 100644
index 000000000..a2e62e944
--- /dev/null
+++ b/src/sdl2gfx/SDL2_framerate.h
@@ -0,0 +1,103 @@
+/*
+
+SDL2_framerate.h: framerate manager
+
+Copyright (C) 2012 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 _SDL2_framerate_h
+#define _SDL2_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_t framecount;
+ float rateticks;
+ uint32_t baseticks;
+ uint32_t lastticks;
+ uint32_t rate;
+ } FPSmanager;
+
+ /* ---- Function Prototypes */
+
+#ifdef _MSC_VER
+# if defined(DLL_EXPORT) && !defined(LIBSDL2_GFX_DLL_IMPORT)
+# define SDL2_FRAMERATE_SCOPE __declspec(dllexport)
+# else
+# ifdef LIBSDL2_GFX_DLL_IMPORT
+# define SDL2_FRAMERATE_SCOPE __declspec(dllimport)
+# endif
+# endif
+#endif
+#ifndef SDL2_FRAMERATE_SCOPE
+# define SDL2_FRAMERATE_SCOPE extern
+#endif
+
+ /* Functions return 0 or value for sucess and -1 for error */
+
+ SDL2_FRAMERATE_SCOPE void SDL_initFramerate(FPSmanager *const manager);
+ SDL2_FRAMERATE_SCOPE int SDL_setFramerate(FPSmanager *const manager,
+ const uint32_t rate);
+ SDL2_FRAMERATE_SCOPE int SDL_getFramerate(FPSmanager *const manager);
+ SDL2_FRAMERATE_SCOPE int SDL_getFramecount(FPSmanager *const manager);
+ SDL2_FRAMERATE_SCOPE uint32_t SDL_framerateDelay(FPSmanager *const
+ manager);
+
+ /* --- */
+
+ /* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SDL2_framerate_h */