From 2efa9f7028e90a60a569aa29b708897ae205740d Mon Sep 17 00:00:00 2001 From: Miguel Date: Sun, 19 Jan 2025 02:17:55 +0100 Subject: add fps --- main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.cpp b/main.cpp index 2e01744..be82a90 100644 --- a/main.cpp +++ b/main.cpp @@ -1011,9 +1011,21 @@ private: void mainLoop() { std::cout << "Enter Main Loop" << std::endl; + static int frames = 0; while (!glfwWindowShouldClose(window) && !quit) { glfwPollEvents(); drawFrame(); // 14 Drawing -> Rendering + frames++; + + + // Print the current time every second + double currentTime = glfwGetTime(); + static double lastTime = 0.0; + if (currentTime - lastTime >= 1.0) { + std::cout << "Current Time: " << currentTime << " FPS: " << frames << std::endl; + frames = 0; + lastTime = currentTime; + } } vkDeviceWaitIdle(device); std::cout << "Exit Main Loop" << std::endl; -- cgit v1.2.3