Linux+OpenGL: Implement GUI vsync setting (#477)

This commit is contained in:
goeiecool9999 2022-11-13 08:29:25 +01:00 committed by GitHub
parent 2842615edb
commit e9d10a9581
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 391 additions and 19 deletions

View file

@ -64,7 +64,31 @@ public:
delete sGLContext;
}
void UpdateVSyncState()
{
int configValue = GetConfig().vsync.GetValue();
if(m_activeVSyncState != configValue)
{
#if BOOST_OS_WINDOWS
if(wglSwapIntervalEXT)
wglSwapIntervalEXT(configValue); // 1 = enabled, 0 = disabled
#elif BOOST_OS_LINUX
if (eglSwapInterval)
{
if (eglSwapInterval(eglGetCurrentDisplay(), configValue) == EGL_FALSE)
{
cemuLog_force("Failed to set vsync using EGL");
}
}
#else
cemuLog_log(LogType::Force, "OpenGL vsync not implemented");
#endif
m_activeVSyncState = configValue;
}
}
private:
int m_activeVSyncState = -1;
//wxGLContext* m_context = nullptr;
};
@ -93,11 +117,13 @@ void GLCanvas_SwapBuffers(bool swapTV, bool swapDRC)
{
GLCanvas_MakeCurrent(false);
sGLTVView->SwapBuffers();
sGLTVView->UpdateVSyncState();
}
if (swapDRC && sGLPadView)
{
GLCanvas_MakeCurrent(true);
sGLPadView->SwapBuffers();
sGLPadView->UpdateVSyncState();
}
GLCanvas_MakeCurrent(false);