More consistent avg. frame time / fps count

This commit is contained in:
saschawillems 2017-12-01 13:10:07 +01:00
parent 2fd2c67672
commit 1f1613a224

View file

@ -258,13 +258,13 @@ void VulkanExampleBase::renderFrame()
fpsTimer += (float)tDiff; fpsTimer += (float)tDiff;
if (fpsTimer > 1000.0f) if (fpsTimer > 1000.0f)
{ {
lastFPS = (float)frameCounter * (1000.0f / fpsTimer);
#if defined(_WIN32) #if defined(_WIN32)
if (!settings.overlay) { if (!settings.overlay) {
std::string windowTitle = getWindowTitle(); std::string windowTitle = getWindowTitle();
SetWindowText(window, windowTitle.c_str()); SetWindowText(window, windowTitle.c_str());
} }
#endif #endif
lastFPS = static_cast<uint32_t>(1.0f / frameTimer);
fpsTimer = 0.0f; fpsTimer = 0.0f;
frameCounter = 0; frameCounter = 0;
} }
@ -350,7 +350,7 @@ void VulkanExampleBase::renderLoop()
fpsTimer += (float)tDiff; fpsTimer += (float)tDiff;
if (fpsTimer > 1000.0f) if (fpsTimer > 1000.0f)
{ {
lastFPS = frameCounter; lastFPS = (float)frameCounter * (1000.0f / fpsTimer);
fpsTimer = 0.0f; fpsTimer = 0.0f;
frameCounter = 0; frameCounter = 0;
} }
@ -440,7 +440,7 @@ void VulkanExampleBase::renderLoop()
fpsTimer += (float)tDiff; fpsTimer += (float)tDiff;
if (fpsTimer > 1000.0f) if (fpsTimer > 1000.0f)
{ {
lastFPS = frameCounter; lastFPS = (float)frameCounter * (1000.0f / fpsTimer);
fpsTimer = 0.0f; fpsTimer = 0.0f;
frameCounter = 0; frameCounter = 0;
} }
@ -489,7 +489,7 @@ void VulkanExampleBase::renderLoop()
std::string windowTitle = getWindowTitle(); std::string windowTitle = getWindowTitle();
wl_shell_surface_set_title(shell_surface, windowTitle.c_str()); wl_shell_surface_set_title(shell_surface, windowTitle.c_str());
} }
lastFPS = frameCounter; lastFPS = (float)frameCounter * (1000.0f / fpsTimer);
fpsTimer = 0.0f; fpsTimer = 0.0f;
frameCounter = 0; frameCounter = 0;
} }
@ -540,7 +540,7 @@ void VulkanExampleBase::renderLoop()
window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8,
windowTitle.size(), windowTitle.c_str()); windowTitle.size(), windowTitle.c_str());
} }
lastFPS = frameCounter; lastFPS = (float)frameCounter * (1000.0f / fpsTimer);
fpsTimer = 0.0f; fpsTimer = 0.0f;
frameCounter = 0; frameCounter = 0;
} }