win32:opengl: Use DWM sync in windowed, Vsync in fullscreen exclusive.

This commit is contained in:
Brandon Wright 2019-03-05 14:25:50 -06:00
parent 045d20507d
commit 23a0e1251e
3 changed files with 22 additions and 6 deletions

View File

@ -384,6 +384,12 @@ bool COpenGL::ChangeRenderSize(unsigned int newWidth, unsigned int newHeight)
return true;
}
void COpenGL::SetSwapInterval(int frames)
{
if (wglSwapIntervalEXT)
wglSwapIntervalEXT(frames);
}
bool COpenGL::ApplyDisplayChanges(void)
{
if(wglSwapIntervalEXT) {

View File

@ -82,6 +82,7 @@ public:
bool SetFullscreen(bool fullscreen);
void SetSnes9xColorFormat(void);
void EnumModes(std::vector<dMode> *modeVector);
void SetSwapInterval(int frames);
GLSLShader *GetActiveShader()
{
return glslShader;

View File

@ -287,16 +287,25 @@ bool8 S9xDeinitUpdate (int Width, int Height)
LastHeight = Height;
}
WinRefreshDisplay();
if (GUI.DWMSync)
if (GUI.DWMSync && GUI.outputMethod == OPENGL)
{
BOOL DWMEnabled = false;
DwmIsCompositionEnabledProc(&DWMEnabled);
if (DWMEnabled)
if (GUI.FullScreen || !DWMEnabled)
((COpenGL *)S9xDisplayOutput)->SetSwapInterval(GUI.Vsync ? 1 : 0);
else
((COpenGL *)S9xDisplayOutput)->SetSwapInterval(0);
WinRefreshDisplay();
if (DWMEnabled && !GUI.FullScreen)
DwmFlushProc();
}
else
{
WinRefreshDisplay();
}
return (true);
}