Make vsync user configurable
This commit is contained in:
parent
bbd18bbec2
commit
73789e58aa
3 changed files with 4 additions and 1 deletions
|
@ -70,6 +70,7 @@ struct RenderTarget {
|
||||||
|
|
||||||
struct GraphicsConfig {
|
struct GraphicsConfig {
|
||||||
int shadowResolution, dofDownscale;
|
int shadowResolution, dofDownscale;
|
||||||
|
bool vsync = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
class World;
|
class World;
|
||||||
|
|
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Reference in a new issue