From 4359dbdf8963442a1af42575d5ae4280dc98f7ad Mon Sep 17 00:00:00 2001 From: amy Date: Wed, 22 Nov 2023 22:33:05 +0100 Subject: [PATCH] spin --- src/engine/vk/test/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/engine/vk/test/main.cpp b/src/engine/vk/test/main.cpp index 3f1fcc2..8d20a18 100644 --- a/src/engine/vk/test/main.cpp +++ b/src/engine/vk/test/main.cpp @@ -120,13 +120,13 @@ int main() { camera.view(), camera.perspective(static_cast(width) / static_cast(height)) }; - uniformBuffer.write(reinterpret_cast(&ubo), sizeof(UniformBufferObject), 0); auto descriptorPool = std::make_shared(vixen.device, sizes, 1); auto descriptorSet = Vixen::Vk::VkDescriptorSet(vixen.device, descriptorPool, vertex->getDescriptorSetLayout()); descriptorSet.updateUniformBuffer(0, uniformBuffer); double old = glfwGetTime(); + double lastFrame = old; uint32_t fps = 0; while (!vixen.window.shouldClose()) { if (vixen.window.update()) { @@ -135,10 +135,16 @@ int main() { renderer = std::make_unique(vixen.device, vixen.swapchain, pipeline); } + const double& now = glfwGetTime(); + double deltaTime = now - lastFrame; + lastFrame = now; + ubo.model = glm::rotate(ubo.model, static_cast(deltaTime) * glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f)); + uniformBuffer.write(reinterpret_cast(&ubo), sizeof(UniformBufferObject), 0); + renderer->render(buffer, vertices.size(), indices.size(), descriptorSet); fps++; - if (const double& now = glfwGetTime(); now - old >= 1) { + if (now - old >= 1) { spdlog::info("FPS: {}", fps); old = now; fps = 0;