From 94262bd0c0ea122dc3cbeef5c7fd37e779f2e95c Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Fri, 20 Oct 2023 00:46:36 +0200 Subject: [PATCH] Updated Implementing Power Save, aka Idling outside of ImGui (markdown) --- ...ing-Power-Save,-aka-Idling-outside-of-ImGui.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Implementing-Power-Save,-aka-Idling-outside-of-ImGui.md b/Implementing-Power-Save,-aka-Idling-outside-of-ImGui.md index 94c2e73..f20b567 100644 --- a/Implementing-Power-Save,-aka-Idling-outside-of-ImGui.md +++ b/Implementing-Power-Save,-aka-Idling-outside-of-ImGui.md @@ -126,7 +126,7 @@ bool ShallIdleThisFrame_Emscripten(FpsIdling& ioIdling) } static double lastRefreshTime = 0.; - double now = Internal::ClockSeconds(); + double now = ClockSeconds(); bool shallIdleThisFrame = false; if (hasInputEvent) @@ -150,4 +150,17 @@ bool ShallIdleThisFrame_Emscripten(FpsIdling& ioIdling) } ``` +where ClockSeconds could be implemented for example like this: +```cpp +#include + +double ClockSeconds() +{ + static const auto start = std::chrono::steady_clock::now(); + auto now = std::chrono::steady_clock::now(); + std::chrono::duration elapsed = now - start; + return elapsed.count(); +} + +```