return flags;
}
+static gboolean
+clutter_backend_glx_create_context (ClutterBackend *backend,
+ gboolean is_offscreen,
+ GError **error)
+{
+ ClutterBackendGLX *backend_glx = CLUTTER_BACKEND_GLX (backend);
+ ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
+
+ if (backend_glx->gl_context == None)
+ {
+ XVisualInfo *xvisinfo;
+
+ xvisinfo =
+ clutter_backend_x11_get_visual_info (backend_x11, is_offscreen);
+
+ CLUTTER_NOTE (GL, "Creating GL Context (display: %p, %s)",
+ backend_x11->xdpy,
+ is_offscreen ? "offscreen" : "onscreen");
+
+ backend_glx->gl_context = glXCreateContext (backend_x11->xdpy,
+ xvisinfo,
+ 0,
+ is_offscreen ? False : True);
+
+ XFree (xvisinfo);
+
+ if (backend_glx->gl_context == None)
+ {
+ g_set_error (error, CLUTTER_INIT_ERROR,
+ CLUTTER_INIT_ERROR_BACKEND,
+ "Unable to create suitable %s GL context",
+ is_offscreen ? "offscreen" : "onscreen");
+ return FALSE;
+ }
+
+ if (!is_offscreen)
+ {
+ gboolean is_direct;
+
+ is_direct = glXIsDirect (backend_x11->xdpy,
+ backend_glx->gl_context);
+
+ CLUTTER_NOTE (GL, "Setting %s context",
+ is_direct ? "direct" : "indirect");
+ _cogl_set_indirect_context (!is_direct);
+ }
+ }
+
+ return TRUE;
+}
+
static void
clutter_backend_glx_ensure_context (ClutterBackend *backend,
ClutterStage *stage)
}
}
-static ClutterActor*
+static ClutterActor *
clutter_backend_glx_create_stage (ClutterBackend *backend,
ClutterStage *wrapper,
GError **error)
backend_class->add_options = clutter_backend_glx_add_options;
backend_class->get_features = clutter_backend_glx_get_features;
backend_class->redraw = clutter_backend_glx_redraw;
+ backend_class->create_context = clutter_backend_glx_create_context;
backend_class->ensure_context = clutter_backend_glx_ensure_context;
backendx11_class->get_visual_info = clutter_backend_glx_get_visual_info;
stage_x11->xwin = None;
}
+ if (stage_x11->xvisinfo != None)
+ {
+ XFree (stage_x11->xvisinfo);
+ stage_x11->xvisinfo = None;
+ }
+
XSync (stage_x11->xdpy, False);
clutter_x11_untrap_x_errors ();
{
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (actor);
ClutterStageGLX *stage_glx = CLUTTER_STAGE_GLX (actor);
+ ClutterBackend *backend;
ClutterBackendGLX *backend_glx;
ClutterBackendX11 *backend_x11;
gboolean is_offscreen;
g_object_get (stage_x11->wrapper, "offscreen", &is_offscreen, NULL);
- backend_glx = CLUTTER_BACKEND_GLX (clutter_get_default_backend ());
- backend_x11 = CLUTTER_BACKEND_X11 (clutter_get_default_backend ());
+ backend = clutter_get_default_backend ();
+ backend_glx = CLUTTER_BACKEND_GLX (backend);
+ backend_x11 = CLUTTER_BACKEND_X11 (backend);
if (G_LIKELY (!is_offscreen))
{
- if (stage_x11->xvisinfo != None)
- {
- XFree (stage_x11->xvisinfo);
- stage_x11->xvisinfo = None;
- }
+ GError *error;
stage_x11->xvisinfo =
clutter_backend_x11_get_visual_info (backend_x11, FALSE);
+
if (stage_x11->xvisinfo == None)
{
g_critical ("Unable to find suitable GL visual.");
clutter_stage_x11_fix_window_size (stage_x11);
clutter_stage_x11_set_wm_protocols (stage_x11);
- if (G_UNLIKELY (backend_glx->gl_context == None))
+ /* ask for a context; a no-op, if a context already exists */
+ error = NULL;
+ _clutter_backend_create_context (backend, FALSE, &error);
+ if (error)
{
- CLUTTER_NOTE (GL, "Creating GL Context");
- backend_glx->gl_context = glXCreateContext (stage_x11->xdpy,
- stage_x11->xvisinfo,
- 0,
- True);
-
- if (backend_glx->gl_context == None)
- {
- g_critical ("Unable to create suitable GL context.");
- goto fail;
- }
-
- _cogl_set_indirect_context (!glXIsDirect (stage_x11->xdpy,
- backend_glx->gl_context));
+ g_critical ("Unable to realize stage: %s", error->message);
+ g_error_free (error);
+ goto fail;
}
CLUTTER_NOTE (BACKEND, "Marking stage as realized");
}
else
{
+ GError *error;
+
if (stage_x11->xvisinfo != None)
{
XFree (stage_x11->xvisinfo);
stage_x11->xvisinfo =
clutter_backend_x11_get_visual_info (backend_x11, TRUE);
+
if (stage_x11->xvisinfo == None)
{
g_critical ("Unable to find suitable GL visual.");
goto fail;
}
-
stage_x11->xpixmap = XCreatePixmap (stage_x11->xdpy,
stage_x11->xwin_root,
stage_x11->xwin_width,
stage_x11->xvisinfo,
stage_x11->xpixmap);
- if (backend_glx->gl_context == None)
+ /* ask for a context; a no-op, if a context already exists
+ *
+ * FIXME: we probably need a seperate offscreen context here
+ * - though it likely makes most sense to drop offscreen stages
+ * and rely on FBO's instead and GLXPixmaps seems mostly broken
+ * anyway..
+ */
+ error = NULL;
+ _clutter_backend_create_context (backend, TRUE, &error);
+ if (error)
{
- CLUTTER_NOTE (GL, "Creating GL Context");
-
- /* FIXME: we probably need a seperate offscreen context here
- * - though it likely makes most sense to drop offscreen stages
- * and rely on FBO's instead and GLXPixmaps seems mostly broken
- * anyway..
- */
- backend_glx->gl_context = glXCreateContext (stage_x11->xdpy,
- stage_x11->xvisinfo,
- 0,
- False);
-
- if (backend_glx->gl_context == None)
- {
- g_critical ("Unable to create suitable GL context.");
- goto fail;
- }
+ g_critical ("Unable to realize stage: %s", error->message);
+ g_error_free (error);
+ goto fail;
}
CLUTTER_NOTE (BACKEND, "Marking stage as realized");