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; return true;
} }
void COpenGL::SetSwapInterval(int frames)
{
if (wglSwapIntervalEXT)
wglSwapIntervalEXT(frames);
}
bool COpenGL::ApplyDisplayChanges(void) bool COpenGL::ApplyDisplayChanges(void)
{ {
if(wglSwapIntervalEXT) { if(wglSwapIntervalEXT) {

View File

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

View File

@ -286,17 +286,26 @@ bool8 S9xDeinitUpdate (int Width, int Height)
LastWidth = Width; LastWidth = Width;
LastHeight = Height; LastHeight = Height;
} }
WinRefreshDisplay();
if (GUI.DWMSync) if (GUI.DWMSync && GUI.outputMethod == OPENGL)
{ {
BOOL DWMEnabled = false; BOOL DWMEnabled = false;
DwmIsCompositionEnabledProc(&DWMEnabled); 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(); DwmFlushProc();
} }
else
{
WinRefreshDisplay();
}
return (true); return (true);
} }