OpenMiner/include/system/GameClock.hpp

47 lines
927 B
C++
Raw Normal View History

2014-12-15 16:47:30 +01:00
/*
* =====================================================================================
*
* Filename: GameClock.hpp
*
2018-06-05 01:24:54 +02:00
* Description:
2014-12-15 16:47:30 +01:00
*
* Created: 14/12/2014 13:42:17
*
* Author: Quentin BAZIN, <quent42340@gmail.com>
*
* =====================================================================================
*/
#ifndef GAMECLOCK_HPP_
#define GAMECLOCK_HPP_
#include <functional>
#include "Types.hpp"
class GameClock {
public:
static u32 getTicks(bool realTime = false);
2018-06-05 01:24:54 +02:00
2014-12-15 16:47:30 +01:00
void measureLastFrameDuration();
2018-06-05 01:24:54 +02:00
2014-12-15 16:47:30 +01:00
void updateGame(std::function<void(void)> updateFunc);
2018-06-05 01:24:54 +02:00
2014-12-15 16:47:30 +01:00
void drawGame(std::function<void(void)> drawFunc);
2018-06-05 01:24:54 +02:00
void waitForNextFrame();
void setTimestep(u8 timestep) { m_timestep = timestep; }
2018-06-05 01:24:54 +02:00
2014-12-15 16:47:30 +01:00
private:
static u32 ticks;
2018-06-05 01:24:54 +02:00
u32 m_lastFrameDate = 0;
u32 m_lag = 0;
u32 m_timeDropped = 0;
u8 m_timestep = 6;
u8 m_numUpdates = 0;
2014-12-15 16:47:30 +01:00
};
#endif // GAMECLOCK_HPP_