From 1ee78ecef573c509df22ff81f8371c2aaf1c3cb2 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 15 Nov 2010 21:17:42 +0100 Subject: [PATCH] Added support for GLX_EXT_swap_control. --- readme.html | 1 + src/x11/platform.h | 2 ++ src/x11/x11_window.c | 30 ++++++++++++++++++++++++------ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/readme.html b/readme.html index 1290fefd..0e001b17 100644 --- a/readme.html +++ b/readme.html @@ -295,6 +295,7 @@ version of GLFW.

  • Removed GLFWCALL and GLFWAPIENTRY macros for stdcall calling convention
  • Bugfix: The default OpenGL version in the version test was set to 1.1
  • Bugfix: The OpenGL profile and forward-compatibility window parameters were not saved after context creation
  • +
  • [X11] Added support for the GLX_EXT_swap_control extension as an alternative to GLX_SGI_swap_control
  • [X11] Bugfix: Calling glXCreateContextAttribsARB with an unavailable OpenGL version caused the application to terminate with a BadMatch Xlib error
  • [Win32] Removed explicit support for versions of Windows older than Windows XP
  • [Win32] Bugfix: Window activation and iconification did not work as expected
  • diff --git a/src/x11/platform.h b/src/x11/platform.h index 57b10447..05bc2544 100644 --- a/src/x11/platform.h +++ b/src/x11/platform.h @@ -100,6 +100,7 @@ typedef struct _GLFWcontextGLX // GLX extensions PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI; + PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT; PFNGLXGETFBCONFIGATTRIBSGIXPROC GetFBConfigAttribSGIX; PFNGLXCHOOSEFBCONFIGSGIXPROC ChooseFBConfigSGIX; PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC CreateContextWithConfigSGIX; @@ -107,6 +108,7 @@ typedef struct _GLFWcontextGLX PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; GLboolean has_GLX_SGIX_fbconfig; GLboolean has_GLX_SGI_swap_control; + GLboolean has_GLX_EXT_swap_control; GLboolean has_GLX_ARB_multisample; GLboolean has_GLX_ARB_create_context; GLboolean has_GLX_ARB_create_context_profile; diff --git a/src/x11/x11_window.c b/src/x11/x11_window.c index e716129d..8ae0b256 100644 --- a/src/x11/x11_window.c +++ b/src/x11/x11_window.c @@ -667,13 +667,25 @@ static int createContext(_GLFWwindow* window, static void initGLXExtensions(_GLFWwindow* window) { - if (_glfwPlatformExtensionSupported("GLX_SGI_swap_control")) + if (_glfwPlatformExtensionSupported("GLX_EXT_swap_control")) { - window->GLX.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) - _glfwPlatformGetProcAddress("glXSwapIntervalSGI"); + window->GLX.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC) + _glfwPlatformGetProcAddress("glXSwapIntervalEXT"); - if (window->GLX.SwapIntervalSGI) - window->GLX.has_GLX_SGI_swap_control = GL_TRUE; + if (window->GLX.SwapIntervalEXT) + window->GLX.has_GLX_EXT_swap_control = GL_TRUE; + } + + if (!window->GLX.has_GLX_EXT_swap_control) + { + if (_glfwPlatformExtensionSupported("GLX_SGI_swap_control")) + { + window->GLX.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) + _glfwPlatformGetProcAddress("glXSwapIntervalSGI"); + + if (window->GLX.SwapIntervalSGI) + window->GLX.has_GLX_SGI_swap_control = GL_TRUE; + } } if (_glfwPlatformExtensionSupported("GLX_SGIX_fbconfig")) @@ -1684,7 +1696,13 @@ void _glfwPlatformSwapInterval(int interval) { _GLFWwindow* window = _glfwLibrary.currentWindow; - if (window->GLX.has_GLX_SGI_swap_control) + if (window->GLX.has_GLX_EXT_swap_control) + { + window->GLX.SwapIntervalEXT(_glfwLibrary.X11.display, + window->X11.handle, + interval); + } + else if (window->GLX.has_GLX_SGI_swap_control) window->GLX.SwapIntervalSGI(interval); }