vengine
0.1.0
3D graphics engine made with Vulkan
Loading...
Searching...
No Matches
clock.cpp
Go to the documentation of this file.
1
#include "
myLib/Clock/Clock.hpp
"
2
3
void
myLib::Clock::pause
()
4
{
5
if
(
m_paused
) {
6
return
;
7
}
8
m_pause
= std::chrono::high_resolution_clock::now();
9
m_paused
=
true
;
10
}
11
12
void
myLib::Clock::resume
()
13
{
14
if
(!m_paused) {
15
return
;
16
}
17
18
m_start += std::chrono::high_resolution_clock::now() - m_pause;
19
m_paused =
false
;
20
}
21
22
myLib::Time
myLib::Clock::getElapsedTime
()
const
23
{
24
TimePoint
now = std::chrono::high_resolution_clock::now();
25
std::chrono::duration<float> elapsed_time{};
26
if
(m_paused) {
27
elapsed_time = m_pause - m_start;
28
}
else
{
29
elapsed_time = now - m_start;
30
}
31
return
Time
(elapsed_time.count());
32
}
Clock.hpp
Clock class for time management.
TimePoint
std::chrono::time_point< std::chrono::high_resolution_clock > TimePoint
TimePoint is a type alias for a time point which is a very long and complicated type in the standard ...
Definition
Clock.hpp:16
myLib::Clock::getElapsedTime
Time getElapsedTime() const
Get the elapsed time since the last restart.
Definition
clock.cpp:22
myLib::Clock::m_pause
TimePoint m_pause
Definition
Clock.hpp:62
myLib::Clock::m_paused
bool m_paused
Definition
Clock.hpp:67
myLib::Clock::resume
void resume()
Resume the clock.
Definition
clock.cpp:12
myLib::Clock::pause
void pause()
Pause the clock.
Definition
clock.cpp:3
myLib::Time
Class used for time management.
Definition
Time.hpp:15
lib
local
static
myLib
src
clock.cpp
Generated by
1.11.0