Archived
1
Fork 0

Make vsync user configurable

This commit is contained in:
Joshua Goins 2018-11-08 13:27:24 -05:00
parent bbd18bbec2
commit 73789e58aa
3 changed files with 4 additions and 1 deletions

View file

@ -70,6 +70,7 @@ struct RenderTarget {
struct GraphicsConfig { struct GraphicsConfig {
int shadowResolution, dofDownscale; int shadowResolution, dofDownscale;
bool vsync = true;
}; };
class World; class World;

View file

@ -75,6 +75,7 @@ void readConfig() {
windowFullscreen = toInt(config.get("Window", "fullscreen")); windowFullscreen = toInt(config.get("Window", "fullscreen"));
currentGraphicsPreset = config.get("Graphics", "preset"); currentGraphicsPreset = config.get("Graphics", "preset");
graphicsConfig.vsync = toInt(config.get("Graphics", "vsync"));
loadGraphicsConfig(); loadGraphicsConfig();
} }
@ -89,6 +90,7 @@ void writeConfig() {
config.set("Window", "fullscreen", std::to_string(windowFullscreen)); config.set("Window", "fullscreen", std::to_string(windowFullscreen));
config.set("Graphics", "preset", currentGraphicsPreset); config.set("Graphics", "preset", currentGraphicsPreset);
config.set("Graphics", "vsync", std::to_string(graphicsConfig.vsync));
config.save("user.cfg"); config.save("user.cfg");
} }

View file

@ -197,7 +197,7 @@ RenderTarget* Renderer::createSurfaceRenderTarget(VkSurfaceKHR surface, RenderTa
swapchainCreateInfo.pQueueFamilyIndices = &queueIndices.presentation; swapchainCreateInfo.pQueueFamilyIndices = &queueIndices.presentation;
swapchainCreateInfo.preTransform = surfaceCapabilities.currentTransform; swapchainCreateInfo.preTransform = surfaceCapabilities.currentTransform;
swapchainCreateInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; 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; swapchainCreateInfo.clipped = VK_TRUE;
if(oldTarget != nullptr) if(oldTarget != nullptr)