impr: Much more accurate frame rate limiting

Many thanks to @ws909 in https://github.com/glfw/glfw/issues/2737
This commit is contained in:
WerWolv
2025-07-11 13:29:56 +02:00
parent 82c318f91d
commit 8c59684c14
2 changed files with 98 additions and 120 deletions

View File

@@ -56,9 +56,7 @@ namespace hex {
void drawImGui();
void drawWithShader();
void unlockFrameRate();
void forceNewFrame();
GLFWwindow *m_window = nullptr;
ImGuiTestEngine *m_testEngine = nullptr;
@@ -76,17 +74,9 @@ namespace hex {
u32 m_searchBarPosition = 0;
bool m_emergencyPopupOpen = false;
std::jthread m_frameRateThread;
std::chrono::duration<double, std::nano> m_remainingUnlockedTime;
std::mutex m_sleepMutex;
std::atomic<bool> m_sleepFlag;
std::condition_variable m_sleepCondVar;
std::mutex m_wakeupMutex;
std::atomic<bool> m_wakeupFlag;
std::condition_variable m_wakeupCondVar;
bool m_shouldUnlockFrameRate = false;
double m_fpsUnlockedEndTime = 0.0;
bool m_waitEventsBlocked = false;
gl::Shader m_postProcessingShader;
};