BARE2D
Timer.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <chrono>
4 
5 namespace BARE2D {
6 
7  /**
8  * @class Timer
9  * @brief Not only does the timer keep track of the current time and delta-times, it can do all the "fancy" calculations for timestepping! Uses semi-fixed timestepping, as this engine isn't going to be used for advanced physics!
10  */
11  class Timer
12  {
13  public:
14  Timer();
15 
16  /**
17  * @brief IntegrateFrame gives an indication of whether we should be updatign again with dt or if we should exit our loop
18  * @return True if we should continue to integrate the update function or False if we're good.
19  */
20  bool integrateFrame();
21 
22  /**
23  * @return The dt variable for update integration.
24  */
25  double getDeltaTime();
26 
27  /**
28  * @brief To be called at the start of a frame
29  */
30  void startTimer();
31 
32  /**
33  * @brief To be called at the end of a frame.
34  */
35  void endTimer();
36 
37  /**
38  * @brief Sets the maximum value of dt. Naturally, there is no minimum. This doesn't take away from accuracy. Setting a maximum means we subdivide the frames if necessary.
39  */
40  void setDeltaTimeLimit(double minDt);
41 
42  private:
44  double m_frameTime;
45  std::chrono::steady_clock::time_point m_startTime;
46 
47  };
48 
49 }
BARE2D::Timer::Timer
Timer()
Definition: Timer.cpp:9
BARE2D
Definition: App.cpp:13
BARE2D::Timer::m_frameTime
double m_frameTime
Definition: Timer.hpp:44
BARE2D::Timer::endTimer
void endTimer()
To be called at the end of a frame.
Definition: Timer.cpp:34
BARE2D::Timer::m_startTime
std::chrono::steady_clock::time_point m_startTime
Definition: Timer.hpp:45
BARE2D::Timer::getDeltaTime
double getDeltaTime()
Definition: Timer.cpp:24
BARE2D::Timer::m_minDeltaTime
double m_minDeltaTime
Definition: Timer.hpp:43
BARE2D::Timer::setDeltaTimeLimit
void setDeltaTimeLimit(double minDt)
Sets the maximum value of dt. Naturally, there is no minimum. This doesn't take away from accuracy....
Definition: Timer.cpp:44
BARE2D::Timer
Not only does the timer keep track of the current time and delta-times, it can do all the "fancy" cal...
Definition: Timer.hpp:11
BARE2D::Timer::startTimer
void startTimer()
To be called at the start of a frame.
Definition: Timer.cpp:29
BARE2D::Timer::integrateFrame
bool integrateFrame()
IntegrateFrame gives an indication of whether we should be updatign again with dt or if we should exi...
Definition: Timer.cpp:14