Device info and frame rate display for linux,

fixed timer on linux
This commit is contained in:
Sascha Willems 2016-03-13 17:15:44 +01:00
parent 66607e2d2f
commit bddaaf13cf

View file

@ -327,10 +327,8 @@ void VulkanExampleBase::renderLoop()
fpsTimer += (float)tDiff; fpsTimer += (float)tDiff;
if (fpsTimer > 1000.0f) if (fpsTimer > 1000.0f)
{ {
#ifdef _WIN32
std::string windowTitle = getWindowTitle(); std::string windowTitle = getWindowTitle();
SetWindowText(window, windowTitle.c_str()); SetWindowText(window, windowTitle.c_str());
#endif
fpsTimer = 0.0f; fpsTimer = 0.0f;
frameCounter = 0.0f; frameCounter = 0.0f;
} }
@ -348,9 +346,29 @@ void VulkanExampleBase::renderLoop()
free(event); free(event);
} }
render(); render();
frameCounter++;
auto tEnd = std::chrono::high_resolution_clock::now(); auto tEnd = std::chrono::high_resolution_clock::now();
auto tDiff = std::chrono::duration<double, std::milli>(tEnd - tStart).count(); auto tDiff = std::chrono::duration<double, std::milli>(tEnd - tStart).count();
frameTimer = tDiff / 1000.0f; frameTimer = tDiff / 1000.0f;
// Convert to clamped timer value
if (!paused)
{
timer += timerSpeed * frameTimer;
if (timer > 1.0)
{
timer -= 1.0f;
}
}
fpsTimer += (float)tDiff;
if (fpsTimer > 1000.0f)
{
std::string windowTitle = getWindowTitle();
xcb_change_property(connection, XCB_PROP_MODE_REPLACE,
window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8,
windowTitle.size(), windowTitle.c_str());
fpsTimer = 0.0f;
frameCounter = 0.0f;
}
} }
#endif #endif
} }
@ -849,9 +867,10 @@ xcb_window_t VulkanExampleBase::setupWindow()
window, (*reply).atom, 4, 32, 1, window, (*reply).atom, 4, 32, 1,
&(*atom_wm_delete_window).atom); &(*atom_wm_delete_window).atom);
std::string windowTitle = getWindowTitle();
xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_change_property(connection, XCB_PROP_MODE_REPLACE,
window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8,
title.size(), title.c_str()); title.size(), windowTitle.c_str());
free(reply); free(reply);
@ -1134,5 +1153,3 @@ void VulkanExampleBase::setupSwapChain()
{ {
swapChain.create(setupCmdBuffer, &width, &height); swapChain.create(setupCmdBuffer, &width, &height);
} }