From 8af3f751db100890f403945d8374a47ea76244b4 Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 24 Feb 2014 12:45:02 +0100 Subject: [PATCH] Fetch swapInterval function pointer after binding a context This fixes vsync on windows --- Source/Core/DolphinWX/GLInterface/GLX.cpp | 10 ++++++++-- Source/Core/DolphinWX/GLInterface/WGL.cpp | 11 +++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Source/Core/DolphinWX/GLInterface/GLX.cpp b/Source/Core/DolphinWX/GLInterface/GLX.cpp index ea220d8876..ce61989efa 100644 --- a/Source/Core/DolphinWX/GLInterface/GLX.cpp +++ b/Source/Core/DolphinWX/GLInterface/GLX.cpp @@ -110,7 +110,6 @@ bool cInterfaceGLX::Create(void *&window_handle) PanicAlert("Unable to create GLX context."); return false; } - glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)GLInterface->GetFuncAddress("glXSwapIntervalSGI"); GLWin.x = _tx; GLWin.y = _ty; @@ -131,7 +130,14 @@ bool cInterfaceGLX::MakeCurrent() XMoveResizeWindow(GLWin.evdpy, GLWin.win, GLWin.x, GLWin.y, GLWin.width, GLWin.height); #endif - return glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx); + + bool success = glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx); + if (success) + { + // load this function based on the current bound context + glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)GLInterface->GetFuncAddress("glXSwapIntervalSGI"); + } + return success; } bool cInterfaceGLX::ClearCurrent() diff --git a/Source/Core/DolphinWX/GLInterface/WGL.cpp b/Source/Core/DolphinWX/GLInterface/WGL.cpp index 5de1468113..db3bc3d0f1 100644 --- a/Source/Core/DolphinWX/GLInterface/WGL.cpp +++ b/Source/Core/DolphinWX/GLInterface/WGL.cpp @@ -128,9 +128,6 @@ bool cInterfaceWGL::Create(void *&window_handle) return false; } - // Grab the swap interval function pointer - wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)GLInterface->GetFuncAddress("wglSwapIntervalEXT"); - return true; } @@ -141,7 +138,13 @@ bool cInterfaceWGL::MakeCurrent() bool cInterfaceWGL::ClearCurrent() { - return wglMakeCurrent(hDC, NULL) ? true : false; + bool success = wglMakeCurrent(hDC, NULL) ? true : false; + if (success) + { + // Grab the swap interval function pointer + wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)GLInterface->GetFuncAddress("wglSwapIntervalEXT"); + } + return success; } // Update window width, size and etc. Called from Render.cpp