fix: Undefined behaviour in frame wait time calculation
This commit is contained in:
parent
6b62a1963e
commit
29adeae6a3
@ -202,8 +202,11 @@ namespace hex {
|
|||||||
this->frameEnd();
|
this->frameEnd();
|
||||||
|
|
||||||
const auto targetFps = ImHexApi::System::getTargetFPS();
|
const auto targetFps = ImHexApi::System::getTargetFPS();
|
||||||
if (targetFps <= 200)
|
if (targetFps <= 200) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(u64((this->m_lastFrameTime + 1 / targetFps - glfwGetTime()) * 1000)));
|
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();
|
this->m_lastFrameTime = glfwGetTime();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user