[vlc-devel] commit: GLX 1.3: pick a frame buffer configuration with matching visual ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Dec 12 20:46:18 CET 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Dec 12 21:45:20 2009 +0200| [14a0e3f7c3a1c0409aeaf645e00b390d2578f95e] | committer: Rémi Denis-Courmont 

GLX 1.3: pick a frame buffer configuration with matching visual

(refs #1672, 5dca2e339ed999d8d71182f50f5aa1d1927df0c9)

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

 modules/video_output/xcb/glx.c |   41 +++++++++++++++++++++++++++++++++------
 1 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/modules/video_output/xcb/glx.c b/modules/video_output/xcb/glx.c
index eebedc3..fcd9b9a 100644
--- a/modules/video_output/xcb/glx.c
+++ b/modules/video_output/xcb/glx.c
@@ -260,6 +260,14 @@ static int Open (vlc_object_t *obj)
             GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
             None };
 
+        xcb_get_window_attributes_reply_t *wa =
+            xcb_get_window_attributes_reply (conn,
+                xcb_get_window_attributes (conn, sys->embed->xid), NULL);
+        if (wa == NULL)
+            goto error;
+        xcb_visualid_t visual = wa->visual;
+        free (wa);
+
         int nelem;
         GLXFBConfig *confs = glXChooseFBConfig (dpy, snum, attr, &nelem);
         if (confs == NULL)
@@ -268,22 +276,41 @@ static int Open (vlc_object_t *obj)
             goto error;
         }
 
-        /*XVisualInfo *vi = glXGetVisualFromFBConfig (dpy, confs[0]);*/
-        CreateWindow (vd, conn, depth, 0 /* ??? */, width, height);
-        /*XFree (vi);*/
+        GLXFBConfig conf;
+        bool found = false;
+
+        for (int i = 0; i < nelem && !found; i++)
+        {
+            conf = confs[i];
 
-        sys->glwin = glXCreateWindow (dpy, confs[0], sys->window, NULL );
+            XVisualInfo *vi = glXGetVisualFromFBConfig (dpy, conf);
+            if (vi == NULL)
+                continue;
+
+            if (vi->visualid == visual)
+                found = true;
+            XFree (vi);
+        }
+        XFree (confs);
+
+        if (!found)
+        {
+            msg_Err (vd, "no matching GLX frame buffer configuration");
+            goto error;
+        }
+
+        sys->glwin = None;
+        if (!CreateWindow (vd, conn, depth, 0 /* ??? */, width, height))
+            sys->glwin = glXCreateWindow (dpy, conf, sys->window, NULL );
         if (sys->glwin == None)
         {
             msg_Err (vd, "cannot create GLX window");
-            XFree (confs);
             goto error;
         }
 
         /* Create an OpenGL context */
-        sys->ctx = glXCreateNewContext (dpy, confs[0], GLX_RGBA_TYPE, NULL,
+        sys->ctx = glXCreateNewContext (dpy, conf, GLX_RGBA_TYPE, NULL,
                                         True);
-        XFree (confs);
         if (sys->ctx == NULL)
         {
             msg_Err (vd, "cannot create GLX context");




More information about the vlc-devel mailing list