Updated Implementing Power Save, aka Idling outside of ImGui (markdown)

Pascal Thomet 2023-10-20 00:46:36 +02:00
parent e6ec052187
commit 94262bd0c0

@ -126,7 +126,7 @@ bool ShallIdleThisFrame_Emscripten(FpsIdling& ioIdling)
} }
static double lastRefreshTime = 0.; static double lastRefreshTime = 0.;
double now = Internal::ClockSeconds(); double now = ClockSeconds();
bool shallIdleThisFrame = false; bool shallIdleThisFrame = false;
if (hasInputEvent) if (hasInputEvent)
@ -150,4 +150,17 @@ bool ShallIdleThisFrame_Emscripten(FpsIdling& ioIdling)
} }
``` ```
where ClockSeconds could be implemented for example like this:
```cpp
#include <chrono>
double ClockSeconds()
{
static const auto start = std::chrono::steady_clock::now();
auto now = std::chrono::steady_clock::now();
std::chrono::duration<double> elapsed = now - start;
return elapsed.count();
}
```