[vlc-commits] Set swap interval to 1 in glx when possible.

Laurent Aimar git at videolan.org
Thu Jun 2 18:47:29 CEST 2011


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Thu Jun  2 18:37:09 2011 +0200| [b23bbc5d1c2c38f985abb79584cbcc04e6c978ba] | committer: Laurent Aimar

Set swap interval to 1 in glx when possible.

It avoids tearing.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b23bbc5d1c2c38f985abb79584cbcc04e6c978ba
---

 modules/video_output/xcb/glx.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/modules/video_output/xcb/glx.c b/modules/video_output/xcb/glx.c
index 53fc452..d2ce803 100644
--- a/modules/video_output/xcb/glx.c
+++ b/modules/video_output/xcb/glx.c
@@ -31,6 +31,7 @@
 #include <xcb/xcb.h>
 #include <X11/Xlib-xcb.h>
 #include <GL/glx.h>
+#include <GL/glxext.h>
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
@@ -359,6 +360,24 @@ static int Open (vlc_object_t *obj)
         sys->glwin = sys->window;
     }
 
+    const char *glx_extensions = glXQueryExtensionsString (dpy, snum);
+
+    bool is_swap_interval_set = false;
+#ifdef GLX_SGI_swap_control
+    if (strstr (glx_extensions, "GLX_SGI_swap_control")) {
+        PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)GetProcAddress (NULL, "glXSwapIntervalSGI");
+        if (!is_swap_interval_set && SwapIntervalSGI)
+            is_swap_interval_set = !SwapIntervalSGI (1);
+    }
+#endif
+#ifdef GLX_EXT_swap_control
+    if (strstr (glx_extensions, "GLX_EXT_swap_control")) {
+        PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)GetProcAddress (NULL, "glXSwapIntervalEXT");
+        if (!is_swap_interval_set && SwapIntervalEXT)
+            is_swap_interval_set = !SwapIntervalEXT (dpy, sys->glwin, 1);
+    }
+#endif
+
     /* Initialize common OpenGL video display */
     sys->gl.lock = NULL;
     sys->gl.unlock = NULL;



More information about the vlc-commits mailing list