You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. SDL2_framerate.h: framerate manager
  3. Copyright (C) 2012-2014 Andreas Schiffler
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source
  17. distribution.
  18. Andreas Schiffler -- aschiffler at ferzkopp dot net
  19. */
  20. #ifndef _SDL2_framerate_h
  21. #define _SDL2_framerate_h
  22. /* Set up for C function definitions, even when using C++ */
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* --- */
  27. #include "SDL.h"
  28. /* --------- Definitions */
  29. /*!
  30. \brief Highest possible rate supported by framerate controller in Hz (1/s).
  31. */
  32. #define FPS_UPPER_LIMIT 200
  33. /*!
  34. \brief Lowest possible rate supported by framerate controller in Hz (1/s).
  35. */
  36. #define FPS_LOWER_LIMIT 1
  37. /*!
  38. \brief Default rate of framerate controller in Hz (1/s).
  39. */
  40. #define FPS_DEFAULT 30
  41. /*!
  42. \brief Structure holding the state and timing information of the framerate controller.
  43. */
  44. typedef struct {
  45. Uint32 framecount;
  46. float rateticks;
  47. Uint32 baseticks;
  48. Uint32 lastticks;
  49. Uint32 rate;
  50. } FPSmanager;
  51. /* ---- Function Prototypes */
  52. #ifdef _MSC_VER
  53. # if defined(DLL_EXPORT) && !defined(LIBSDL2_GFX_DLL_IMPORT)
  54. # define SDL2_FRAMERATE_SCOPE __declspec(dllexport)
  55. # else
  56. # ifdef LIBSDL2_GFX_DLL_IMPORT
  57. # define SDL2_FRAMERATE_SCOPE __declspec(dllimport)
  58. # endif
  59. # endif
  60. #endif
  61. #ifndef SDL2_FRAMERATE_SCOPE
  62. # define SDL2_FRAMERATE_SCOPE extern
  63. #endif
  64. /* Functions return 0 or value for sucess and -1 for error */
  65. SDL2_FRAMERATE_SCOPE void SDL_initFramerate(FPSmanager * manager);
  66. SDL2_FRAMERATE_SCOPE int SDL_setFramerate(FPSmanager * manager, Uint32 rate);
  67. SDL2_FRAMERATE_SCOPE int SDL_getFramerate(FPSmanager * manager);
  68. SDL2_FRAMERATE_SCOPE int SDL_getFramecount(FPSmanager * manager);
  69. SDL2_FRAMERATE_SCOPE Uint32 SDL_framerateDelay(FPSmanager * manager);
  70. /* --- */
  71. /* Ends C function definitions when using C++ */
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75. #endif /* _SDL2_framerate_h */