~ubuntu-branches/ubuntu/trusty/manaplus/trusty

« back to all changes in this revision

Viewing changes to src/sdl2gfx/SDL2_framerate.h

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-11-18 15:19:44 UTC
  • mfrom: (1.1.14)
  • Revision ID: package-import@ubuntu.com-20131118151944-iyd93ut2rmxzp8gg
Tags: 1.3.11.10-1
New upstream release.

Show diffs side-by-side

added added

removed removed

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