From 5adb44e2ace9ca7c6db241ec77b379dd1791d824 Mon Sep 17 00:00:00 2001 From: saschawillems Date: Thu, 24 Mar 2016 22:43:33 +0100 Subject: [PATCH] Android timer (#97) --- base/vulkanexamplebase.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index b10c0bf1..faffc86d 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -387,6 +387,15 @@ void VulkanExampleBase::renderLoop() auto tEnd = std::chrono::high_resolution_clock::now(); auto tDiff = std::chrono::duration(tEnd - tStart).count(); frameTimer = tDiff / 1000.0f; + // Convert to clamped timer value + if (!paused) + { + timer += timerSpeed * frameTimer; + if (timer > 1.0) + { + timer -= 1.0f; + } + } // Check gamepad state const float deadZone = 0.10f; // todo : check if gamepad is present