From a775352cc4f7de28dc8ccf952ce9e1cd32c6eb02 Mon Sep 17 00:00:00 2001 From: Fabrice Bellet Date: Thu, 3 Jul 2014 15:44:25 +0200 Subject: [PATCH] glx: fix gl_create_context() with parent context set. If GLX window was created from a foreign Display, then that same Display shall be used for subsequent glXMakeCurrent(). This means that gl_create_context() will now use the same Display that the parent, if available. This patch implements the same fix than this one described here: http://lists.freedesktop.org/archives/libva/2012-July/001088.html --- src/utils_glx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils_glx.c b/src/utils_glx.c index 6b70dd8..1cca4bb 100644 --- a/src/utils_glx.c +++ b/src/utils_glx.c @@ -316,7 +316,7 @@ gl_create_context(Display *dpy, int screen, GLContextState *parent) if (!cs) goto error; - cs->display = dpy; + cs->display = parent ? parent->display : dpy; cs->window = parent ? parent->window : None; cs->visual = NULL; cs->context = NULL; @@ -330,14 +330,14 @@ gl_create_context(Display *dpy, int screen, GLContextState *parent) if (status != Success) goto error; - fbconfigs = glXGetFBConfigs(dpy, screen, &n_fbconfigs); + fbconfigs = glXGetFBConfigs(parent->display , screen, &n_fbconfigs); if (!fbconfigs) goto error; /* Find out a GLXFBConfig compatible with the parent context */ for (n = 0; n < n_fbconfigs; n++) { status = glXGetFBConfigAttrib( - dpy, + parent->display, fbconfigs[n], GLX_FBCONFIG_ID, &val ); @@ -349,7 +349,7 @@ gl_create_context(Display *dpy, int screen, GLContextState *parent) } else { fbconfigs = glXChooseFBConfig( - dpy, + cs->display, screen, fbconfig_attrs, &n_fbconfigs ); @@ -360,9 +360,9 @@ gl_create_context(Display *dpy, int screen, GLContextState *parent) n = 0; } - cs->visual = glXGetVisualFromFBConfig(dpy, fbconfigs[n]); + cs->visual = glXGetVisualFromFBConfig(cs->display, fbconfigs[n]); cs->context = glXCreateNewContext( - dpy, + cs->display, fbconfigs[n], GLX_RGBA_TYPE, parent ? parent->context : NULL, -- 1.9.3