gsdx linux: add vsync support for free driver

This commit is contained in:
Gregory Hainaut 2016-06-04 13:17:59 +02:00
parent 2b2412ca20
commit 4768f912b8
2 changed files with 10 additions and 5 deletions

View File

@ -24,7 +24,7 @@
#if defined(__unix__) #if defined(__unix__)
GSWndOGL::GSWndOGL() GSWndOGL::GSWndOGL()
: m_NativeWindow(0), m_NativeDisplay(NULL), m_context(0), m_swapinterval(NULL) : m_NativeWindow(0), m_NativeDisplay(NULL), m_context(0), m_swapinterval_ext(NULL), m_swapinterval_mesa(NULL)
{ {
} }
@ -147,7 +147,8 @@ bool GSWndOGL::Attach(void* handle, bool managed)
CheckContext(); CheckContext();
m_swapinterval = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT"); m_swapinterval_ext = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT");
m_swapinterval_mesa = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA");
PopulateGlFunction(); PopulateGlFunction();
@ -194,7 +195,8 @@ bool GSWndOGL::Create(const string& title, int w, int h)
CheckContext(); CheckContext();
m_swapinterval = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT"); m_swapinterval_ext = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT");
m_swapinterval_mesa = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA");
PopulateGlFunction(); PopulateGlFunction();
@ -262,7 +264,9 @@ void GSWndOGL::SetVSync(bool enable)
// m_swapinterval uses an integer as parameter // m_swapinterval uses an integer as parameter
// 0 -> disable vsync // 0 -> disable vsync
// n -> wait n frame // n -> wait n frame
if (m_swapinterval) m_swapinterval(m_NativeDisplay, m_NativeWindow, (int)enable); if (m_swapinterval_ext) m_swapinterval_ext(m_NativeDisplay, m_NativeWindow, (int)enable);
else if (m_swapinterval_mesa) m_swapinterval_mesa((int)enable);
else fprintf(stderr, "Failed to set VSync\n");
} }
void GSWndOGL::Flip() void GSWndOGL::Flip()

View File

@ -31,7 +31,8 @@ class GSWndOGL final : public GSWndGL
Display* m_NativeDisplay; Display* m_NativeDisplay;
GLXContext m_context; GLXContext m_context;
PFNGLXSWAPINTERVALEXTPROC m_swapinterval; PFNGLXSWAPINTERVALEXTPROC m_swapinterval_ext;
PFNGLXSWAPINTERVALMESAPROC m_swapinterval_mesa;
void CreateContext(int major, int minor); void CreateContext(int major, int minor);
void CheckContext(); void CheckContext();