From 486e591169af724107ffaf6f24cd1e81b24529a9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 29 Feb 2024 21:29:56 +0100 Subject: time wip It works now, but some functionality is lost in main/draw.cpp --- src/timer-fwd.hpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/timer-fwd.hpp (limited to 'src/timer-fwd.hpp') 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 + +namespace Magnum::Math { template class Nanoseconds; } + +namespace floormat { + +using Ns = Math::Nanoseconds; + +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 -- cgit v1.2.3