Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
app_clock.cpp
Go to the documentation of this file.
1#include "app_clock.hpp"
2#include "app_time.hpp"
3
4namespace rendering_engine
5{
6
8:
9mStartTime(),
10mCurrentTime(),
11mLastTime()
12{
13 Reset();
14}
15
16const std::chrono::high_resolution_clock::time_point& AppClock::StartTime() const
17{
18 return mStartTime;
19}
20
21const std::chrono::high_resolution_clock::time_point& AppClock::CurrentTime() const
22{
23 return mCurrentTime;
24}
25
26const std::chrono::high_resolution_clock::time_point& AppClock::LastTime() const
27{
28 return mLastTime;
29}
30
32{
33 mStartTime = std::chrono::high_resolution_clock::now();
34 mCurrentTime = mStartTime;
35 mLastTime = mCurrentTime;
36}
37
39{
40 mLastTime = mCurrentTime;
41 mCurrentTime = std::chrono::high_resolution_clock::now();
42
43 appTime.SetCurrentTime( mCurrentTime );
44 appTime.SetTotalAppTime( std::chrono::duration_cast<std::chrono::milliseconds>(mCurrentTime - mStartTime) );
45 appTime.SetElapsedAppTime( std::chrono::duration_cast<std::chrono::milliseconds>(mCurrentTime - mLastTime) );
46}
47
48} //rendering_engine
High-resolution clock for updating application time.
Provides time tracking for the application runtime.
void Reset()
Resets the clock to the current system time.
Definition app_clock.cpp:31
void UpdateAppTime(AppTime &appTime)
Updates the given AppTime instance with elapsed and total durations.
Definition app_clock.cpp:38
AppClock()
Constructs a new clock initialized with the current time.
Definition app_clock.cpp:7
const std::chrono::high_resolution_clock::time_point & CurrentTime() const
Returns the most recent recorded time (current frame).
Definition app_clock.cpp:21
const std::chrono::high_resolution_clock::time_point & LastTime() const
Returns the time recorded at the previous frame.
Definition app_clock.cpp:26
const std::chrono::high_resolution_clock::time_point & StartTime() const
Returns the timestamp when the clock was started.
Definition app_clock.cpp:16
Manages current, total, and elapsed time for the application.
Definition app_time.hpp:36
void SetTotalAppTime(const std::chrono::milliseconds &totalAppTime)
Sets total accumulated application time.
Definition app_time.cpp:33
void SetCurrentTime(const std::chrono::high_resolution_clock::time_point &currentTime)
Sets the current high-resolution time point.
Definition app_time.cpp:18
void SetElapsedAppTime(const std::chrono::milliseconds &elapsedAppTime)
Sets elapsed time since the last frame.
Definition app_time.cpp:48