GameKit  0.0.1a
C++ gamedev tools
GameClock.hpp
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: GameClock.hpp
5  *
6  * Description:
7  *
8  * Created: 14/12/2014 13:42:17
9  *
10  * Author: Quentin Bazin, <quent42340@gmail.com>
11  *
12  * =====================================================================================
13  */
14 #ifndef GK_GAMECLOCK_HPP_
15 #define GK_GAMECLOCK_HPP_
16 
17 #include <functional>
18 
19 #include "gk/core/IntTypes.hpp"
20 
21 namespace gk {
22 
23 class GameClock {
24  public:
25  static u32 getTicks(bool realTime = false);
26 
28 
29  void updateGame(std::function<void(void)> updateFunc);
30 
31  void drawGame(std::function<void(void)> drawFunc);
32 
33  void waitForNextFrame();
34 
35  void setTimestep(u8 timestep) { m_timestep = timestep; }
36 
37  private:
38  static u32 ticks;
39 
41  u32 m_lag = 0;
43 
46 };
47 
48 } // namespace gk
49 
50 #endif // GK_GAMECLOCK_HPP_
u32 m_lastFrameDate
Definition: GameClock.hpp:40
static u32 ticks
Definition: GameClock.hpp:38
unsigned char u8
Definition: IntTypes.hpp:21
unsigned int u32
Definition: IntTypes.hpp:23
void drawGame(std::function< void(void)> drawFunc)
Definition: GameClock.cpp:56
void updateGame(std::function< void(void)> updateFunc)
Definition: GameClock.cpp:43
static u32 getTicks(bool realTime=false)
Definition: GameClock.cpp:21
void waitForNextFrame()
Definition: GameClock.cpp:64
void setTimestep(u8 timestep)
Definition: GameClock.hpp:35
void measureLastFrameDuration()
Definition: GameClock.cpp:29