mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 14:19:55 -06:00
add VSync toggle
This commit is contained in:
@ -39,12 +39,14 @@ uiWindow* win;
|
|||||||
|
|
||||||
uiRadioButtons* rbRenderer;
|
uiRadioButtons* rbRenderer;
|
||||||
uiCheckbox* cbGLDisplay;
|
uiCheckbox* cbGLDisplay;
|
||||||
|
uiCheckbox* cbVSync;
|
||||||
uiCheckbox* cbThreaded3D;
|
uiCheckbox* cbThreaded3D;
|
||||||
uiCombobox* cbResolution;
|
uiCombobox* cbResolution;
|
||||||
uiCheckbox* cbAntialias;
|
uiCheckbox* cbAntialias;
|
||||||
|
|
||||||
int old_renderer;
|
int old_renderer;
|
||||||
int old_gldisplay;
|
int old_gldisplay;
|
||||||
|
int old_vsync;
|
||||||
int old_threaded3D;
|
int old_threaded3D;
|
||||||
int old_resolution;
|
int old_resolution;
|
||||||
int old_antialias;
|
int old_antialias;
|
||||||
@ -89,6 +91,11 @@ void RevertSettings()
|
|||||||
{
|
{
|
||||||
Config::ScreenUseGL = old_gldisplay;
|
Config::ScreenUseGL = old_gldisplay;
|
||||||
}
|
}
|
||||||
|
if (old_vsync != Config::ScreenVSync)
|
||||||
|
{
|
||||||
|
Config::ScreenVSync = old_vsync;
|
||||||
|
ApplyNewSettings(4);
|
||||||
|
}
|
||||||
if (old_usegl != new_usegl)
|
if (old_usegl != new_usegl)
|
||||||
{
|
{
|
||||||
apply2 = true;
|
apply2 = true;
|
||||||
@ -134,17 +141,25 @@ void OnRendererChanged(uiRadioButtons* rb, void* blarg)
|
|||||||
ApplyNewSettings(2);
|
ApplyNewSettings(2);
|
||||||
else
|
else
|
||||||
ApplyNewSettings(3);
|
ApplyNewSettings(3);
|
||||||
|
|
||||||
uiControlSetFocus(uiControl(win));
|
uiControlSetFocus(uiControl(win));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnGLDisplayChanged(uiCheckbox* cb, void* blarg)
|
void OnGLDisplayChanged(uiCheckbox* cb, void* blarg)
|
||||||
{
|
{
|
||||||
Config::ScreenUseGL = uiCheckboxChecked(cb);
|
Config::ScreenUseGL = uiCheckboxChecked(cb);
|
||||||
|
if (Config::ScreenUseGL) uiControlEnable(uiControl(cbVSync));
|
||||||
|
else uiControlDisable(uiControl(cbVSync));
|
||||||
ApplyNewSettings(2);
|
ApplyNewSettings(2);
|
||||||
uiControlSetFocus(uiControl(win));
|
uiControlSetFocus(uiControl(win));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnVSyncChanged(uiCheckbox* cb, void* blarg)
|
||||||
|
{
|
||||||
|
Config::ScreenVSync = uiCheckboxChecked(cb);
|
||||||
|
ApplyNewSettings(4);
|
||||||
|
}
|
||||||
|
|
||||||
void OnThreaded3DChanged(uiCheckbox* cb, void* blarg)
|
void OnThreaded3DChanged(uiCheckbox* cb, void* blarg)
|
||||||
{
|
{
|
||||||
Config::Threaded3D = uiCheckboxChecked(cb);
|
Config::Threaded3D = uiCheckboxChecked(cb);
|
||||||
@ -232,6 +247,10 @@ void Open()
|
|||||||
cbGLDisplay = uiNewCheckbox("OpenGL display");
|
cbGLDisplay = uiNewCheckbox("OpenGL display");
|
||||||
uiCheckboxOnToggled(cbGLDisplay, OnGLDisplayChanged, NULL);
|
uiCheckboxOnToggled(cbGLDisplay, OnGLDisplayChanged, NULL);
|
||||||
uiBoxAppend(in_ctrl, uiControl(cbGLDisplay), 0);
|
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_renderer = Config::_3DRenderer;
|
||||||
old_gldisplay = Config::ScreenUseGL;
|
old_gldisplay = Config::ScreenUseGL;
|
||||||
|
old_vsync = Config::ScreenVSync;
|
||||||
old_threaded3D = Config::Threaded3D;
|
old_threaded3D = Config::Threaded3D;
|
||||||
old_resolution = Config::GL_ScaleFactor;
|
old_resolution = Config::GL_ScaleFactor;
|
||||||
old_antialias = Config::GL_Antialias;
|
old_antialias = Config::GL_Antialias;
|
||||||
|
|
||||||
uiCheckboxSetChecked(cbGLDisplay, Config::ScreenUseGL);
|
uiCheckboxSetChecked(cbGLDisplay, Config::ScreenUseGL);
|
||||||
|
uiCheckboxSetChecked(cbVSync, Config::ScreenVSync);
|
||||||
uiCheckboxSetChecked(cbThreaded3D, Config::Threaded3D);
|
uiCheckboxSetChecked(cbThreaded3D, Config::Threaded3D);
|
||||||
uiComboboxSetSelected(cbResolution, Config::GL_ScaleFactor-1);
|
uiComboboxSetSelected(cbResolution, Config::GL_ScaleFactor-1);
|
||||||
//uiCheckboxSetChecked(cbAntialias, Config::GL_Antialias);
|
//uiCheckboxSetChecked(cbAntialias, Config::GL_Antialias);
|
||||||
uiRadioButtonsSetSelected(rbRenderer, Config::_3DRenderer);
|
uiRadioButtonsSetSelected(rbRenderer, Config::_3DRenderer);
|
||||||
UpdateControls();
|
UpdateControls();
|
||||||
|
|
||||||
|
if (Config::ScreenUseGL) uiControlEnable(uiControl(cbVSync));
|
||||||
|
else uiControlDisable(uiControl(cbVSync));
|
||||||
|
|
||||||
uiControlShow(uiControl(win));
|
uiControlShow(uiControl(win));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ int ScreenSizing;
|
|||||||
int ScreenFilter;
|
int ScreenFilter;
|
||||||
|
|
||||||
int ScreenUseGL;
|
int ScreenUseGL;
|
||||||
|
int ScreenVSync;
|
||||||
int ScreenRatio;
|
int ScreenRatio;
|
||||||
|
|
||||||
int LimitFPS;
|
int LimitFPS;
|
||||||
@ -118,6 +119,7 @@ ConfigEntry PlatformConfigFile[] =
|
|||||||
{"ScreenFilter", 0, &ScreenFilter, 1, NULL, 0},
|
{"ScreenFilter", 0, &ScreenFilter, 1, NULL, 0},
|
||||||
|
|
||||||
{"ScreenUseGL", 0, &ScreenUseGL, 1, NULL, 0},
|
{"ScreenUseGL", 0, &ScreenUseGL, 1, NULL, 0},
|
||||||
|
{"ScreenVSync", 0, &ScreenVSync, 0, NULL, 0},
|
||||||
{"ScreenRatio", 0, &ScreenRatio, 0, NULL, 0},
|
{"ScreenRatio", 0, &ScreenRatio, 0, NULL, 0},
|
||||||
|
|
||||||
{"LimitFPS", 0, &LimitFPS, 1, NULL, 0},
|
{"LimitFPS", 0, &LimitFPS, 1, NULL, 0},
|
||||||
|
@ -54,6 +54,7 @@ extern int ScreenSizing;
|
|||||||
extern int ScreenFilter;
|
extern int ScreenFilter;
|
||||||
|
|
||||||
extern int ScreenUseGL;
|
extern int ScreenUseGL;
|
||||||
|
extern int ScreenVSync;
|
||||||
extern int ScreenRatio;
|
extern int ScreenRatio;
|
||||||
|
|
||||||
extern int LimitFPS;
|
extern int LimitFPS;
|
||||||
|
@ -988,7 +988,8 @@ int EmuThreadFunc(void* burp)
|
|||||||
uiAreaQueueRedrawAll(MainDrawArea);
|
uiAreaQueueRedrawAll(MainDrawArea);
|
||||||
|
|
||||||
bool limitfps = Config::LimitFPS && !HotkeyDown(HK_FastForward);
|
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);
|
float framerate = (1000.0f * nlines) / (60.0f * 263.0f);
|
||||||
|
|
||||||
@ -2260,6 +2261,19 @@ void ApplyNewSettings(int type)
|
|||||||
GPU3D::InitRenderer(Screen_UseGL);
|
GPU3D::InitRenderer(Screen_UseGL);
|
||||||
if (Screen_UseGL) uiGLMakeContextCurrent(NULL);
|
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;
|
EmuRunning = prevstatus;
|
||||||
}
|
}
|
||||||
@ -2469,7 +2483,7 @@ void CreateMainWindow(bool opengl)
|
|||||||
if (opengl_good)
|
if (opengl_good)
|
||||||
{
|
{
|
||||||
uiGLMakeContextCurrent(GLContext);
|
uiGLMakeContextCurrent(GLContext);
|
||||||
uiGLSetVSync(0); // TODO: make configurable?
|
uiGLSetVSync(Config::ScreenVSync);
|
||||||
if (!GLScreen_Init()) opengl_good = false;
|
if (!GLScreen_Init()) opengl_good = false;
|
||||||
if (opengl_good)
|
if (opengl_good)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user