only set mRendered to true when a frame was actually rendered
This commit is contained in:
@@ -115,23 +115,24 @@ void RenderThread::iter()
|
|||||||
{
|
{
|
||||||
if (mRender && !mRendered)
|
if (mRender && !mRendered)
|
||||||
{
|
{
|
||||||
mRenderTicker->render(0);
|
if(mRenderTicker->render(0)) {
|
||||||
mRender = false;
|
mRender = false;
|
||||||
mRendered = true;
|
mRendered = true;
|
||||||
|
|
||||||
// Calculate and print FPS
|
// Calculate and print FPS
|
||||||
auto currentTime = std::chrono::high_resolution_clock::now();
|
auto currentTime = std::chrono::high_resolution_clock::now();
|
||||||
float deltaTime = std::chrono::duration<float, std::chrono::seconds::period>(currentTime - _lastFrameTime).count();
|
float deltaTime = std::chrono::duration<float, std::chrono::seconds::period>(currentTime - _lastFrameTime).count();
|
||||||
_lastFrameTime = currentTime;
|
_lastFrameTime = currentTime;
|
||||||
|
|
||||||
_frameCount++;
|
_frameCount++;
|
||||||
_accumulatedTime += deltaTime;
|
_accumulatedTime += deltaTime;
|
||||||
|
|
||||||
if (_accumulatedTime >= 1.0f) // Update FPS every second
|
if (_accumulatedTime >= 1.0f) // Update FPS every second
|
||||||
{
|
{
|
||||||
_fps = _frameCount / _accumulatedTime;
|
_fps = _frameCount / _accumulatedTime;
|
||||||
_frameCount = 0;
|
_frameCount = 0;
|
||||||
_accumulatedTime = 0.0f;
|
_accumulatedTime = 0.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user