mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
[glx backend] use FBConfigs instead of Visuals for GL context creation
This replaces calls to the old (glx 1.2) functions glXChooseVisual, glXCreateContext, glXMakeCurrent with the 1.3+ fbconfig varients glXChooseFBConfig, glXCreateNewContext, glXMakeContextCurrent.
This commit is contained in:
parent
15d7a86621
commit
45a668bef8
@ -354,6 +354,60 @@ clutter_backend_glx_get_features (ClutterBackend *backend)
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
clutter_backend_glx_get_fbconfig (ClutterBackendX11 *backend_x11,
|
||||||
|
GLXFBConfig *config)
|
||||||
|
{
|
||||||
|
int attributes[] = {
|
||||||
|
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
|
||||||
|
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||||
|
GLX_DOUBLEBUFFER, GL_TRUE,
|
||||||
|
GLX_RED_SIZE, 1,
|
||||||
|
GLX_GREEN_SIZE, 1,
|
||||||
|
GLX_BLUE_SIZE, 1,
|
||||||
|
GLX_ALPHA_SIZE, 1,
|
||||||
|
GLX_DEPTH_SIZE, 1,
|
||||||
|
GLX_STENCIL_SIZE, 1,
|
||||||
|
None
|
||||||
|
};
|
||||||
|
GLXFBConfig *configs = NULL;
|
||||||
|
int n_configs;
|
||||||
|
|
||||||
|
if (backend_x11->xdpy == None || backend_x11->xscreen == None)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
CLUTTER_NOTE (BACKEND,
|
||||||
|
"Retrieving GL fbconfig, dpy: %p, xscreen; %p (%d)",
|
||||||
|
backend_x11->xdpy,
|
||||||
|
backend_x11->xscreen,
|
||||||
|
backend_x11->xscreen_num);
|
||||||
|
|
||||||
|
configs = glXChooseFBConfig (backend_x11->xdpy,
|
||||||
|
backend_x11->xscreen_num,
|
||||||
|
attributes,
|
||||||
|
&n_configs);
|
||||||
|
if (configs)
|
||||||
|
*config = configs[0];
|
||||||
|
|
||||||
|
XFree (configs);
|
||||||
|
|
||||||
|
if (configs)
|
||||||
|
return TRUE;
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static XVisualInfo *
|
||||||
|
clutter_backend_glx_get_visual_info (ClutterBackendX11 *backend_x11)
|
||||||
|
{
|
||||||
|
GLXFBConfig config;
|
||||||
|
|
||||||
|
if (!clutter_backend_glx_get_fbconfig (backend_x11, &config))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return glXGetVisualFromFBConfig (backend_x11->xdpy, config);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
clutter_backend_glx_create_context (ClutterBackend *backend,
|
clutter_backend_glx_create_context (ClutterBackend *backend,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -363,20 +417,25 @@ clutter_backend_glx_create_context (ClutterBackend *backend,
|
|||||||
|
|
||||||
if (backend_glx->gl_context == None)
|
if (backend_glx->gl_context == None)
|
||||||
{
|
{
|
||||||
XVisualInfo *xvisinfo;
|
GLXFBConfig config;
|
||||||
gboolean is_direct;
|
gboolean is_direct;
|
||||||
|
|
||||||
xvisinfo = clutter_backend_x11_get_visual_info (backend_x11);
|
if (!clutter_backend_glx_get_fbconfig (backend_x11, &config))
|
||||||
|
{
|
||||||
|
g_set_error (error, CLUTTER_INIT_ERROR,
|
||||||
|
CLUTTER_INIT_ERROR_BACKEND,
|
||||||
|
"Unable to find suitable fbconfig for GL context");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
CLUTTER_NOTE (GL, "Creating GL Context (display: %p)",
|
CLUTTER_NOTE (GL, "Creating GL Context (display: %p)",
|
||||||
backend_x11->xdpy);
|
backend_x11->xdpy);
|
||||||
|
backend_glx->gl_context =
|
||||||
backend_glx->gl_context = glXCreateContext (backend_x11->xdpy,
|
glXCreateNewContext (backend_x11->xdpy,
|
||||||
xvisinfo,
|
config,
|
||||||
0,
|
GLX_RGBA_TYPE,
|
||||||
True);
|
NULL,
|
||||||
|
True);
|
||||||
XFree (xvisinfo);
|
|
||||||
|
|
||||||
if (backend_glx->gl_context == None)
|
if (backend_glx->gl_context == None)
|
||||||
{
|
{
|
||||||
@ -415,7 +474,7 @@ clutter_backend_glx_ensure_context (ClutterBackend *backend,
|
|||||||
backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
||||||
CLUTTER_NOTE (MULTISTAGE, "Clearing all context");
|
CLUTTER_NOTE (MULTISTAGE, "Clearing all context");
|
||||||
|
|
||||||
glXMakeCurrent (backend_x11->xdpy, None, NULL);
|
glXMakeContextCurrent (backend_x11->xdpy, None, None, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -450,20 +509,21 @@ clutter_backend_glx_ensure_context (ClutterBackend *backend,
|
|||||||
CLUTTER_NOTE (MULTISTAGE,
|
CLUTTER_NOTE (MULTISTAGE,
|
||||||
"Received a stale stage, clearing all context");
|
"Received a stale stage, clearing all context");
|
||||||
|
|
||||||
glXMakeCurrent (backend_x11->xdpy, None, NULL);
|
glXMakeContextCurrent (backend_x11->xdpy, None, None, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLUTTER_NOTE (BACKEND,
|
CLUTTER_NOTE (BACKEND,
|
||||||
"MakeCurrent dpy: %p, window: 0x%x (%s), context: %p",
|
"MakeContextCurrent dpy: %p, window: 0x%x (%s), context: %p",
|
||||||
stage_x11->xdpy,
|
stage_x11->xdpy,
|
||||||
(int) stage_x11->xwin,
|
(int) stage_x11->xwin,
|
||||||
stage_x11->is_foreign_xwin ? "foreign" : "native",
|
stage_x11->is_foreign_xwin ? "foreign" : "native",
|
||||||
backend_glx->gl_context);
|
backend_glx->gl_context);
|
||||||
|
|
||||||
glXMakeCurrent (stage_x11->xdpy,
|
glXMakeContextCurrent (stage_x11->xdpy,
|
||||||
stage_x11->xwin,
|
stage_x11->xwin,
|
||||||
backend_glx->gl_context);
|
stage_x11->xwin,
|
||||||
|
backend_glx->gl_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clutter_x11_untrap_x_errors ())
|
if (clutter_x11_untrap_x_errors ())
|
||||||
@ -603,38 +663,6 @@ clutter_backend_glx_create_stage (ClutterBackend *backend,
|
|||||||
return stage_window;
|
return stage_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
static XVisualInfo *
|
|
||||||
clutter_backend_glx_get_visual_info (ClutterBackendX11 *backend_x11)
|
|
||||||
{
|
|
||||||
XVisualInfo *xvisinfo;
|
|
||||||
int attributes[] = {
|
|
||||||
GLX_RGBA,
|
|
||||||
GLX_DOUBLEBUFFER,
|
|
||||||
GLX_RED_SIZE, 1,
|
|
||||||
GLX_GREEN_SIZE, 1,
|
|
||||||
GLX_BLUE_SIZE, 1,
|
|
||||||
GLX_ALPHA_SIZE, 1,
|
|
||||||
GLX_STENCIL_SIZE, 1,
|
|
||||||
GLX_DEPTH_SIZE, 1,
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
if (backend_x11->xdpy == None || backend_x11->xscreen == None)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
CLUTTER_NOTE (BACKEND,
|
|
||||||
"Retrieving GL visual, dpy: %p, xscreen; %p (%d)",
|
|
||||||
backend_x11->xdpy,
|
|
||||||
backend_x11->xscreen,
|
|
||||||
backend_x11->xscreen_num);
|
|
||||||
|
|
||||||
xvisinfo = glXChooseVisual (backend_x11->xdpy,
|
|
||||||
backend_x11->xscreen_num,
|
|
||||||
attributes);
|
|
||||||
|
|
||||||
return xvisinfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_backend_glx_class_init (ClutterBackendGLXClass *klass)
|
clutter_backend_glx_class_init (ClutterBackendGLXClass *klass)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user