aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2019-09-01 20:20:22 +0200
committerArisotura <thetotalworm@gmail.com>2019-09-01 20:20:22 +0200
commitabb06269a1ade49f71c02d1fc2b63128f872d294 (patch)
treec2f80a024e512ad176686b0acd8160e00dc13e1b
parent5b5103443608d6f7e88229b1fbf8fb276b4f5f27 (diff)
add VSync toggle
-rw-r--r--src/libui_sdl/DlgVideoSettings.cpp26
-rw-r--r--src/libui_sdl/PlatformConfig.cpp2
-rw-r--r--src/libui_sdl/PlatformConfig.h1
-rw-r--r--src/libui_sdl/main.cpp18
4 files changed, 44 insertions, 3 deletions
diff --git a/src/libui_sdl/DlgVideoSettings.cpp b/src/libui_sdl/DlgVideoSettings.cpp
index 7d876e2..155fe8b 100644
--- a/src/libui_sdl/DlgVideoSettings.cpp
+++ b/src/libui_sdl/DlgVideoSettings.cpp
@@ -39,12 +39,14 @@ uiWindow* win;
uiRadioButtons* rbRenderer;
uiCheckbox* cbGLDisplay;
+uiCheckbox* cbVSync;
uiCheckbox* cbThreaded3D;
uiCombobox* cbResolution;
uiCheckbox* cbAntialias;
int old_renderer;
int old_gldisplay;
+int old_vsync;
int old_threaded3D;
int old_resolution;
int old_antialias;
@@ -89,6 +91,11 @@ void RevertSettings()
{
Config::ScreenUseGL = old_gldisplay;
}
+ if (old_vsync != Config::ScreenVSync)
+ {
+ Config::ScreenVSync = old_vsync;
+ ApplyNewSettings(4);
+ }
if (old_usegl != new_usegl)
{
apply2 = true;
@@ -134,17 +141,25 @@ void OnRendererChanged(uiRadioButtons* rb, void* blarg)
ApplyNewSettings(2);
else
ApplyNewSettings(3);
-
+
uiControlSetFocus(uiControl(win));
}
void OnGLDisplayChanged(uiCheckbox* cb, void* blarg)
{
Config::ScreenUseGL = uiCheckboxChecked(cb);
+ if (Config::ScreenUseGL) uiControlEnable(uiControl(cbVSync));
+ else uiControlDisable(uiControl(cbVSync));
ApplyNewSettings(2);
uiControlSetFocus(uiControl(win));
}
+void OnVSyncChanged(uiCheckbox* cb, void* blarg)
+{
+ Config::ScreenVSync = uiCheckboxChecked(cb);
+ ApplyNewSettings(4);
+}
+
void OnThreaded3DChanged(uiCheckbox* cb, void* blarg)
{
Config::Threaded3D = uiCheckboxChecked(cb);
@@ -232,6 +247,10 @@ void Open()
cbGLDisplay = uiNewCheckbox("OpenGL display");
uiCheckboxOnToggled(cbGLDisplay, OnGLDisplayChanged, NULL);
uiBoxAppend(in_ctrl, uiControl(cbGLDisplay), 0);
+
+ cbVSync = uiNewCheckbox("VSync");
+ uiCheckboxOnToggled(cbVSync, OnVSyncChanged, NULL);
+ uiBoxAppend(in_ctrl, uiControl(cbVSync), 0);
}
{
@@ -300,17 +319,22 @@ void Open()
old_renderer = Config::_3DRenderer;
old_gldisplay = Config::ScreenUseGL;
+ old_vsync = Config::ScreenVSync;
old_threaded3D = Config::Threaded3D;
old_resolution = Config::GL_ScaleFactor;
old_antialias = Config::GL_Antialias;
uiCheckboxSetChecked(cbGLDisplay, Config::ScreenUseGL);
+ uiCheckboxSetChecked(cbVSync, Config::ScreenVSync);
uiCheckboxSetChecked(cbThreaded3D, Config::Threaded3D);
uiComboboxSetSelected(cbResolution, Config::GL_ScaleFactor-1);
//uiCheckboxSetChecked(cbAntialias, Config::GL_Antialias);
uiRadioButtonsSetSelected(rbRenderer, Config::_3DRenderer);
UpdateControls();
+ if (Config::ScreenUseGL) uiControlEnable(uiControl(cbVSync));
+ else uiControlDisable(uiControl(cbVSync));
+
uiControlShow(uiControl(win));
}
diff --git a/src/libui_sdl/PlatformConfig.cpp b/src/libui_sdl/PlatformConfig.cpp
index 7f45b59..fb31ccd 100644
--- a/src/libui_sdl/PlatformConfig.cpp
+++ b/src/libui_sdl/PlatformConfig.cpp
@@ -43,6 +43,7 @@ int ScreenSizing;
int ScreenFilter;
int ScreenUseGL;
+int ScreenVSync;
int ScreenRatio;
int LimitFPS;
@@ -118,6 +119,7 @@ ConfigEntry PlatformConfigFile[] =
{"ScreenFilter", 0, &ScreenFilter, 1, NULL, 0},
{"ScreenUseGL", 0, &ScreenUseGL, 1, NULL, 0},
+ {"ScreenVSync", 0, &ScreenVSync, 0, NULL, 0},
{"ScreenRatio", 0, &ScreenRatio, 0, NULL, 0},
{"LimitFPS", 0, &LimitFPS, 1, NULL, 0},
diff --git a/src/libui_sdl/PlatformConfig.h b/src/libui_sdl/PlatformConfig.h
index 2c59e5d..2aede24 100644
--- a/src/libui_sdl/PlatformConfig.h
+++ b/src/libui_sdl/PlatformConfig.h
@@ -54,6 +54,7 @@ extern int ScreenSizing;
extern int ScreenFilter;
extern int ScreenUseGL;
+extern int ScreenVSync;
extern int ScreenRatio;
extern int LimitFPS;
diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp
index 1b4a9c6..24febf6 100644
--- a/src/libui_sdl/main.cpp
+++ b/src/libui_sdl/main.cpp
@@ -988,7 +988,8 @@ int EmuThreadFunc(void* burp)
uiAreaQueueRedrawAll(MainDrawArea);
bool limitfps = Config::LimitFPS && !HotkeyDown(HK_FastForward);
- SPU::Sync(limitfps);
+ bool vsync = Config::ScreenVSync && Screen_UseGL;
+ SPU::Sync(limitfps || vsync);
float framerate = (1000.0f * nlines) / (60.0f * 263.0f);
@@ -2260,6 +2261,19 @@ void ApplyNewSettings(int type)
GPU3D::InitRenderer(Screen_UseGL);
if (Screen_UseGL) uiGLMakeContextCurrent(NULL);
}
+ else if (type == 4) // vsync
+ {
+ if (Screen_UseGL)
+ {
+ uiGLMakeContextCurrent(GLContext);
+ uiGLSetVSync(Config::ScreenVSync);
+ uiGLMakeContextCurrent(NULL);
+ }
+ else
+ {
+ // TODO eventually: VSync for non-GL screen?
+ }
+ }
EmuRunning = prevstatus;
}
@@ -2469,7 +2483,7 @@ void CreateMainWindow(bool opengl)
if (opengl_good)
{
uiGLMakeContextCurrent(GLContext);
- uiGLSetVSync(0); // TODO: make configurable?
+ uiGLSetVSync(Config::ScreenVSync);
if (!GLScreen_Init()) opengl_good = false;
if (opengl_good)
{