diff --git a/DDrawCompat/Config/Config.cpp b/DDrawCompat/Config/Config.cpp index d2b72e4..532c4ff 100644 --- a/DDrawCompat/Config/Config.cpp +++ b/DDrawCompat/Config/Config.cpp @@ -20,4 +20,5 @@ namespace Config Settings::SupportedResolutions supportedResolutions; Settings::TextureFilter textureFilter; Settings::ThreadPriorityBoost threadPriorityBoost; + Settings::VSync vSync; } diff --git a/DDrawCompat/Config/Config.h b/DDrawCompat/Config/Config.h index 6a5bdb8..a56b4c6 100644 --- a/DDrawCompat/Config/Config.h +++ b/DDrawCompat/Config/Config.h @@ -18,6 +18,7 @@ #include #include #include +#include namespace Config { @@ -39,4 +40,5 @@ namespace Config extern Settings::SupportedResolutions supportedResolutions; extern Settings::TextureFilter textureFilter; extern Settings::ThreadPriorityBoost threadPriorityBoost; + extern Settings::VSync vSync; } diff --git a/DDrawCompat/Config/Settings/VSync.cpp b/DDrawCompat/Config/Settings/VSync.cpp new file mode 100644 index 0000000..f3f3777 --- /dev/null +++ b/DDrawCompat/Config/Settings/VSync.cpp @@ -0,0 +1,24 @@ +#include +#include + +#include + +namespace Config +{ + namespace Settings + { + VSync::VSync() + : MappedSetting("VSync", "app", { {"app", APP}, {"off", OFF}, {"on", ON} }) + { + } + + Setting::ParamInfo VSync::getParamInfo() const + { + if (ON == m_value) + { + return { "Interval", 1, 16, 1, m_param }; + } + return {}; + } + } +} diff --git a/DDrawCompat/Config/Settings/VSync.h b/DDrawCompat/Config/Settings/VSync.h new file mode 100644 index 0000000..22348e3 --- /dev/null +++ b/DDrawCompat/Config/Settings/VSync.h @@ -0,0 +1,21 @@ +#pragma once + +#include + +namespace Config +{ + namespace Settings + { + class VSync : public MappedSetting + { + public: + static const int APP = -1; + static const int OFF = 0; + static const int ON = 1; + + VSync(); + + virtual ParamInfo getParamInfo() const override; + }; + } +} diff --git a/DDrawCompat/DDraw/RealPrimarySurface.cpp b/DDrawCompat/DDraw/RealPrimarySurface.cpp index 046a7e1..4138915 100644 --- a/DDrawCompat/DDraw/RealPrimarySurface.cpp +++ b/DDrawCompat/DDraw/RealPrimarySurface.cpp @@ -103,6 +103,12 @@ namespace UINT getFlipInterval(DWORD flags) { + auto vSync = Config::vSync.get(); + if (Config::Settings::VSync::APP != vSync) + { + return Config::Settings::VSync::OFF == vSync ? 0 : Config::vSync.getParam(); + } + if (flags & DDFLIP_NOVSYNC) { return 0; diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index 2fa78c2..1c21963 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -235,6 +235,7 @@ + @@ -361,6 +362,7 @@ + diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters index 6f94c01..e3e87f3 100644 --- a/DDrawCompat/DDrawCompat.vcxproj.filters +++ b/DDrawCompat/DDrawCompat.vcxproj.filters @@ -543,6 +543,9 @@ Header Files\Config\Settings + + Header Files\Config\Settings + @@ -857,6 +860,9 @@ Source Files\Config\Settings + + Source Files\Config\Settings + diff --git a/DDrawCompat/Overlay/ConfigWindow.cpp b/DDrawCompat/Overlay/ConfigWindow.cpp index 017ba5f..11ff470 100644 --- a/DDrawCompat/Overlay/ConfigWindow.cpp +++ b/DDrawCompat/Overlay/ConfigWindow.cpp @@ -20,6 +20,7 @@ namespace Overlay addControl(Config::spriteFilter); addControl(Config::spriteTexCoord); addControl(Config::textureFilter); + addControl(Config::vSync); } void ConfigWindow::addControl(Config::Setting& setting)