only set mRendered to true when a frame was actually rendered

This commit is contained in:
Nick Fisher
2025-05-09 11:23:13 +08:00
parent 4a5a1d0157
commit ebab1f528d

View File

@@ -115,23 +115,24 @@ void RenderThread::iter()
{
if (mRender && !mRendered)
{
mRenderTicker->render(0);
mRender = false;
mRendered = true;
if(mRenderTicker->render(0)) {
mRender = false;
mRendered = true;
// Calculate and print FPS
auto currentTime = std::chrono::high_resolution_clock::now();
float deltaTime = std::chrono::duration<float, std::chrono::seconds::period>(currentTime - _lastFrameTime).count();
_lastFrameTime = currentTime;
// Calculate and print FPS
auto currentTime = std::chrono::high_resolution_clock::now();
float deltaTime = std::chrono::duration<float, std::chrono::seconds::period>(currentTime - _lastFrameTime).count();
_lastFrameTime = currentTime;
_frameCount++;
_accumulatedTime += deltaTime;
_frameCount++;
_accumulatedTime += deltaTime;
if (_accumulatedTime >= 1.0f) // Update FPS every second
{
_fps = _frameCount / _accumulatedTime;
_frameCount = 0;
_accumulatedTime = 0.0f;
if (_accumulatedTime >= 1.0f) // Update FPS every second
{
_fps = _frameCount / _accumulatedTime;
_frameCount = 0;
_accumulatedTime = 0.0f;
}
}
}