diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-29 21:29:56 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-01 06:06:53 +0100 |
commit | 486e591169af724107ffaf6f24cd1e81b24529a9 (patch) | |
tree | 012ec6c07c474d4695eb5c22b47dd35cfce2767c /src/timer-fwd.hpp | |
parent | 5afe42d6a81eeb81db08d4bd2107ac4c71f6671e (diff) |
time wip
It works now, but some functionality is lost in main/draw.cpp
Diffstat (limited to 'src/timer-fwd.hpp')
-rw-r--r-- | src/timer-fwd.hpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/timer-fwd.hpp b/src/timer-fwd.hpp new file mode 100644 index 00000000..5e11ce7b --- /dev/null +++ b/src/timer-fwd.hpp @@ -0,0 +1,27 @@ +#pragma once +#include <compare> + +namespace Magnum::Math { template<class T> class Nanoseconds; } + +namespace floormat { + +using Ns = Math::Nanoseconds<int64_t>; + +struct Time final +{ + static Time now() noexcept; + bool operator==(const Time&) const noexcept; + std::strong_ordering operator<=>(const Time&) const noexcept; + friend Ns operator-(const Time& a, const Time& b) noexcept; + [[nodiscard]] Ns update(const Time& ts = now()) & noexcept; + + static float to_seconds(const Ns& ts) noexcept; + static float to_milliseconds(const Ns& ts) noexcept; + + uint64_t stamp = init(); + +private: + static uint64_t init() noexcept; +}; + +} // namespace floormat |