From 6665821972afe7c44a7b602dc27326d2fe211f8a Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Fri, 12 Jan 2018 17:20:05 +0500 Subject: Added togglable VSync option --- src/Render.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Render.cpp b/src/Render.cpp index b19b679..9c6cb38 100644 --- a/src/Render.cpp +++ b/src/Render.cpp @@ -496,6 +496,10 @@ void Render::RenderGui() { ImGui::Checkbox("Wireframe", &wireframe); + static bool vsync = false; + + ImGui::Checkbox("VSync", &vsync); + if (ImGui::Button("Apply settings")) { if (distance != world->MaxRenderingDistance) { world->MaxRenderingDistance = distance; @@ -507,6 +511,12 @@ void Render::RenderGui() { isWireframe = wireframe; timer.SetDelayLength(std::chrono::duration(1.0 / targetFps * 1000.0)); + if (vsync) { + timer.SetDelayLength(std::chrono::milliseconds(0)); + SDL_GL_SetSwapInterval(1); + } else + SDL_GL_SetSwapInterval(0); + } ImGui::Separator(); -- cgit v1.2.3