From 0bba09a0558cb0f75f78b55a20d126da770fc033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Con=C3=A1l?= Date: Wed, 21 Feb 2024 16:25:32 -0500 Subject: [PATCH] Fixed timing --- Input/Input.cpp | 2 +- Renderer/Swapchain.cpp | 2 +- UI/UI.cpp | 3 ++- pléascach.cpp | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Input/Input.cpp b/Input/Input.cpp index 87cb602..ae5f12e 100644 --- a/Input/Input.cpp +++ b/Input/Input.cpp @@ -85,7 +85,7 @@ void Input::handleMovementKeys(Renderer& ren) { } const auto right = glm::normalize(glm::cross(forward, glm::vec3(0.0, 1.0, 0.0))); auto speed = glfwGetKey(in, GLFW_KEY_LEFT_SHIFT)? 2.0f : 1.0f; - speed *= ren.speed; + speed *= ren.speed * ren.frametime / 8.0; if(glfwGetKey(in, GLFW_KEY_UP)) { ren.cam.theta -= 0.01; diff --git a/Renderer/Swapchain.cpp b/Renderer/Swapchain.cpp index e4226dc..5cdb6a3 100644 --- a/Renderer/Swapchain.cpp +++ b/Renderer/Swapchain.cpp @@ -60,7 +60,7 @@ void Swapchain::create(vk::SwapchainKHR old_swapchain) { /* see if this allows see through windows on Wayland */ .compositeAlpha = vk::CompositeAlphaFlagBitsKHR::eOpaque, /* waits for refresh (V-Sync), consider playing with relaxed fifo later on*/ -// .presentMode = vk::PresentModeKHR::eFifo, +// .presentMode = vk::PresentModeKHR::eFifoRelaxed, .presentMode = vk::PresentModeKHR::eMailbox, .clipped = VK_TRUE, .oldSwapchain = old_swapchain, diff --git a/UI/UI.cpp b/UI/UI.cpp index ba9d007..16b7466 100644 --- a/UI/UI.cpp +++ b/UI/UI.cpp @@ -127,7 +127,7 @@ UI::UI(Renderer* ren) : ren(ren), dev(ren->dev) { console->System().RegisterVariable("visibility_testing", ren->visibility_testing, csys::Arg("value")); console->System().RegisterVariable("flycam", ren->flycam, csys::Arg("value")); console->System().RegisterVariable("speed", ren->speed, csys::Arg("value")); - console->System().RegisterVariable("max_fps", ren->speed, csys::Arg("value")); + console->System().RegisterVariable("max_fps", ren->max_fps, csys::Arg("value")); console->System().Log(csys::ItemType::eINFO) << "Welcome to Pleascach!" << csys::endl; } @@ -143,6 +143,7 @@ void UI::newFrame() { ImGui::Text("# of Indices: %zu", ren->n_indices); ImGui::Text("FPS: %f", ren->fps); ImGui::Text("Time: %f", ren->time); + ImGui::Text("Speed: %f", ren->speed * ren->frametime / 8.0); if(ren->in_menu) console->Draw(); diff --git a/pléascach.cpp b/pléascach.cpp index 22443e1..7257199 100644 --- a/pléascach.cpp +++ b/pléascach.cpp @@ -77,7 +77,7 @@ int main(int argc, char* argv[]) { ren.frametime = frame_timer.read(); ren.fps = 1000.0f / ren.frametime; - while (frame_timer.read() < 1000 / ren.max_fps) + while (frame_timer.read() < 1000.0 / ren.max_fps) ; ren.frametime = frame_timer.read();