From c082902fe4a36f456b115cc89b8ac280fbff45bc Mon Sep 17 00:00:00 2001 From: qiuguohua Date: Tue, 22 Feb 2022 09:57:24 +0800 Subject: [PATCH] Fix fps calculation error for linux and QNX (#10141) --- native/cocos/platform/linux/LinuxPlatform.cpp | 2 +- native/cocos/platform/qnx/QNXPlatform.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/native/cocos/platform/linux/LinuxPlatform.cpp b/native/cocos/platform/linux/LinuxPlatform.cpp index 05d01d70c7..0ed8af73bf 100644 --- a/native/cocos/platform/linux/LinuxPlatform.cpp +++ b/native/cocos/platform/linux/LinuxPlatform.cpp @@ -189,7 +189,7 @@ int32_t LinuxPlatform::loop() { onResume(); while (!_quit) { curTime = getCurrentMillSecond(); - desiredInterval = (long)(1.0 / getFps()); + desiredInterval = static_cast(1000.0 / getFps()); pollEvent(); actualInterval = curTime - lastTime; if (actualInterval >= desiredInterval) { diff --git a/native/cocos/platform/qnx/QNXPlatform.cpp b/native/cocos/platform/qnx/QNXPlatform.cpp index c84306a0e2..8ae44550df 100644 --- a/native/cocos/platform/qnx/QNXPlatform.cpp +++ b/native/cocos/platform/qnx/QNXPlatform.cpp @@ -189,9 +189,9 @@ int32_t QnxPlatform::loop() { onResume(); while (!_quit) { curTime = getCurrentMillSecond(); - desiredInterval = (long)(1.0 / getFps()); - - //pollEvent(); + desiredInterval = static_cast(1000.0 / getFps()); + + // pollEvent(); actualInterval = curTime - lastTime; if (actualInterval >= desiredInterval) { lastTime = getCurrentMillSecond();