mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 19:55:32 +00:00
Fix gl_create_context() to find a GLXFBConfig compatible with the parent GL context.
This commit is contained in:
parent
b8aadb9e82
commit
d1709fef62
1 changed files with 48 additions and 15 deletions
|
@ -287,16 +287,17 @@ GLContextState *
|
||||||
gl_create_context(Display *dpy, int screen, GLContextState *parent)
|
gl_create_context(Display *dpy, int screen, GLContextState *parent)
|
||||||
{
|
{
|
||||||
GLContextState *cs;
|
GLContextState *cs;
|
||||||
GLXFBConfig *fb_configs = NULL;
|
GLXFBConfig *fbconfigs = NULL;
|
||||||
int n_fb_configs;
|
int fbconfig_id, val, n, n_fbconfigs;
|
||||||
|
Status status;
|
||||||
|
|
||||||
static GLint fb_config_attrs[] = {
|
static GLint fbconfig_attrs[] = {
|
||||||
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
|
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
|
||||||
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||||
GLX_DOUBLEBUFFER, True,
|
GLX_DOUBLEBUFFER, True,
|
||||||
GLX_RED_SIZE, 1,
|
GLX_RED_SIZE, 8,
|
||||||
GLX_GREEN_SIZE, 1,
|
GLX_GREEN_SIZE, 8,
|
||||||
GLX_BLUE_SIZE, 1,
|
GLX_BLUE_SIZE, 8,
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -310,17 +311,49 @@ gl_create_context(Display *dpy, int screen, GLContextState *parent)
|
||||||
cs->context = NULL;
|
cs->context = NULL;
|
||||||
cs->swapped_buffers = FALSE;
|
cs->swapped_buffers = FALSE;
|
||||||
|
|
||||||
fb_configs = glXChooseFBConfig(dpy, screen, fb_config_attrs, &n_fb_configs);
|
if (parent && parent->context) {
|
||||||
if (!fb_configs)
|
status = glXQueryContext(
|
||||||
goto error;
|
parent->display,
|
||||||
|
parent->context,
|
||||||
|
GLX_FBCONFIG_ID, &fbconfig_id
|
||||||
|
);
|
||||||
|
if (status != Success)
|
||||||
|
goto error;
|
||||||
|
|
||||||
cs->visual = glXGetVisualFromFBConfig(dpy, fb_configs[0]);
|
fbconfigs = glXGetFBConfigs(dpy, screen, &n_fbconfigs);
|
||||||
if (!cs->visual)
|
if (!fbconfigs)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
/* Find out a GLXFBConfig compatible with the parent context */
|
||||||
|
for (n = 0; n < n_fbconfigs; n++) {
|
||||||
|
status = glXGetFBConfigAttrib(
|
||||||
|
dpy,
|
||||||
|
fbconfigs[n],
|
||||||
|
GLX_FBCONFIG_ID, &val
|
||||||
|
);
|
||||||
|
if (status == Success && val == fbconfig_id)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (n == n_fbconfigs)
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fbconfigs = glXChooseFBConfig(
|
||||||
|
dpy,
|
||||||
|
screen,
|
||||||
|
fbconfig_attrs, &n_fbconfigs
|
||||||
|
);
|
||||||
|
if (!fbconfigs)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
/* Select the first one */
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cs->visual = glXGetVisualFromFBConfig(dpy, fbconfigs[n]);
|
||||||
cs->context = glXCreateNewContext(
|
cs->context = glXCreateNewContext(
|
||||||
dpy,
|
dpy,
|
||||||
fb_configs[0],
|
fbconfigs[n],
|
||||||
GLX_RGBA_TYPE,
|
GLX_RGBA_TYPE,
|
||||||
parent ? parent->context : NULL,
|
parent ? parent->context : NULL,
|
||||||
True
|
True
|
||||||
|
@ -332,8 +365,8 @@ error:
|
||||||
gl_destroy_context(cs);
|
gl_destroy_context(cs);
|
||||||
cs = NULL;
|
cs = NULL;
|
||||||
end:
|
end:
|
||||||
if (fb_configs)
|
if (fbconfigs)
|
||||||
XFree(fb_configs);
|
XFree(fbconfigs);
|
||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue