1
0
mirror of synced 2024-11-28 01:20:51 +01:00

fix: Undefined behaviour in frame wait time calculation

This commit is contained in:
WerWolv 2022-08-15 22:21:53 +02:00
parent 6b62a1963e
commit 29adeae6a3

View File

@ -202,8 +202,11 @@ namespace hex {
this->frameEnd();
const auto targetFps = ImHexApi::System::getTargetFPS();
if (targetFps <= 200)
std::this_thread::sleep_for(std::chrono::milliseconds(u64((this->m_lastFrameTime + 1 / targetFps - glfwGetTime()) * 1000)));
if (targetFps <= 200) {
auto leftoverFrameTime = i64((this->m_lastFrameTime + 1 / targetFps - glfwGetTime()) * 1000);
if (leftoverFrameTime > 0)
std::this_thread::sleep_for(std::chrono::milliseconds(leftoverFrameTime));
}
this->m_lastFrameTime = glfwGetTime();