diff --git a/include/renderer.h b/include/renderer.h index 8af8919..8f3e730 100644 --- a/include/renderer.h +++ b/include/renderer.h @@ -70,6 +70,7 @@ struct RenderTarget { struct GraphicsConfig { int shadowResolution, dofDownscale; + bool vsync = true; }; class World; diff --git a/src/main.cpp b/src/main.cpp index fa035b8..a5b856e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -75,6 +75,7 @@ void readConfig() { windowFullscreen = toInt(config.get("Window", "fullscreen")); currentGraphicsPreset = config.get("Graphics", "preset"); + graphicsConfig.vsync = toInt(config.get("Graphics", "vsync")); loadGraphicsConfig(); } @@ -89,6 +90,7 @@ void writeConfig() { config.set("Window", "fullscreen", std::to_string(windowFullscreen)); config.set("Graphics", "preset", currentGraphicsPreset); + config.set("Graphics", "vsync", std::to_string(graphicsConfig.vsync)); config.save("user.cfg"); } diff --git a/src/renderer.cpp b/src/renderer.cpp index 538d57a..271841a 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -197,7 +197,7 @@ RenderTarget* Renderer::createSurfaceRenderTarget(VkSurfaceKHR surface, RenderTa swapchainCreateInfo.pQueueFamilyIndices = &queueIndices.presentation; swapchainCreateInfo.preTransform = surfaceCapabilities.currentTransform; swapchainCreateInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; - swapchainCreateInfo.presentMode = VK_PRESENT_MODE_FIFO_KHR; + swapchainCreateInfo.presentMode = config_.vsync ? VK_PRESENT_MODE_FIFO_KHR : VK_PRESENT_MODE_IMMEDIATE_KHR; swapchainCreateInfo.clipped = VK_TRUE; if(oldTarget != nullptr)