Add support for glXSwapIntervalEXT.

This commit is contained in:
Brandon Wright 2011-01-09 03:32:38 -06:00
parent 68492491dd
commit a1e9887d58
2 changed files with 42 additions and 18 deletions

View File

@ -736,6 +736,8 @@ S9xOpenGLDisplayDriver::resize_window (int width, int height)
glXMakeCurrent (display, xwindow, glx_context);
swap_control (config->sync_to_vblank);
return;
}
@ -866,9 +868,15 @@ S9xOpenGLDisplayDriver::init (void)
void
S9xOpenGLDisplayDriver::swap_control (int enable)
{
glSwapIntervalProc glSwapInterval = NULL;
static glSwapIntervalProc glSwapInterval = NULL;
static glXSwapIntervalEXTProc glXSwapIntervalEXT = NULL;
static int queried = FALSE;
const char *ext_str;
enable = enable ? 1 : 0;
if (!queried)
{
ext_str = glXQueryExtensionsString (display, DefaultScreen (display));
/* We try to set this with both extensions since some cards pretend
@ -878,18 +886,31 @@ S9xOpenGLDisplayDriver::swap_control (int enable)
{
glSwapInterval = (glSwapIntervalProc)
glGetProcAddress ((GLubyte *) "glXSwapIntervalMESA");
if (glSwapInterval)
glSwapInterval (enable ? 1 : 0);
}
else if (strstr (ext_str, "GLX_SGI_swap_control"))
if (strstr (ext_str, "GLX_SGI_swap_control"))
{
glSwapInterval = (glSwapIntervalProc)
glGetProcAddress ((GLubyte *) "glXSwapIntervalSGI");
}
if (strstr (ext_str, "GLX_EXT_swap_control"))
{
glXSwapIntervalEXT = (glXSwapIntervalEXTProc)
glGetProcAddress ((GLubyte *) "glXSwapIntervalEXT");
}
queried = TRUE;
}
if (glSwapInterval)
{
glSwapInterval (enable ? 1 : 0);
glSwapInterval (enable);
}
if (glXSwapIntervalEXT)
{
glXSwapIntervalEXT (display, xwindow, enable);
}
return;

View File

@ -35,6 +35,9 @@ typedef void (*gl_proc) (void);
typedef gl_proc (*getProcAddressProc) (const GLubyte *name);
typedef GLint (*glSwapIntervalProc) (GLint interval);
typedef void (*glXSwapIntervalEXTProc) (Display *dpy,
GLXDrawable drawable,
int interval);
/* Procedures for pixel buffer objects */
typedef void (*glGenBuffersProc) (GLsizei n, GLuint *buffers);
typedef void (*glDeleteBuffersProc) (GLsizei n, const GLuint *buffers);