glx: ask for a GL3 core context
authorMatthew Waters <matthew@centricular.com>
Sun, 19 Oct 2014 04:09:37 +0000 (08:09 +0400)
committerMatthew Waters <matthew@centricular.com>
Thu, 27 Nov 2014 22:14:25 +0000 (09:14 +1100)
gst-libs/gst/gl/gstglcolorconvert.c
gst-libs/gst/gl/x11/gstglcontext_glx.c

index 5b758fd..b75b1ea 100644 (file)
@@ -1178,7 +1178,7 @@ _init_convert_fbo (GstGLColorConvert * convert)
   /* setup the render buffer for depth */
   gl->GenRenderbuffers (1, &convert->depth_buffer);
   gl->BindRenderbuffer (GL_RENDERBUFFER, convert->depth_buffer);
-  if (USING_OPENGL (convert->context)) {
+  if (USING_OPENGL (convert->context) || USING_OPENGL3 (convert->context)) {
     gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT,
         out_width, out_height);
     gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8,
index 6c52f43..7c3c23e 100644 (file)
@@ -145,7 +145,7 @@ gst_gl_context_glx_create_context (GstGLContext * context,
   GstGLDisplay *display;
   gboolean create_context;
   const char *glx_exts;
-  int x_error;
+  int x_error = 0;
   Display *device;
   guintptr external_gl_context = 0;
 
@@ -176,8 +176,8 @@ gst_gl_context_glx_create_context (GstGLContext * context,
   if (create_context && context_glx->priv->glXCreateContextAttribsARB) {
     int context_attribs_3[] = {
       GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
-      GLX_CONTEXT_MINOR_VERSION_ARB, 0,
-      //GLX_CONTEXT_FLAGS_ARB        , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
+      GLX_CONTEXT_MINOR_VERSION_ARB, 1,
+      GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
 #if !defined(GST_DISABLE_GST_DEBUG)
       GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
 #endif
@@ -190,17 +190,23 @@ gst_gl_context_glx_create_context (GstGLContext * context,
       None
     };
 
-    gst_gl_window_x11_trap_x_errors ();
-    context_glx->glx_context =
-        context_glx->priv->glXCreateContextAttribsARB (device,
-        context_glx->priv->fbconfigs[0], (GLXContext) external_gl_context, True,
-        context_attribs_3);
+    if (gl_api & GST_GL_API_OPENGL3) {
+      GST_DEBUG_OBJECT (window, "trying to create a GL 3.1 core context");
+      gst_gl_window_x11_trap_x_errors ();
+      context_glx->glx_context =
+          context_glx->priv->glXCreateContextAttribsARB (device,
+          context_glx->priv->fbconfigs[0], (GLXContext) external_gl_context,
+          True, context_attribs_3);
 
-    x_error = gst_gl_window_x11_untrap_x_errors ();
-    context_glx->priv->context_api = GST_GL_API_OPENGL;
+      x_error = gst_gl_window_x11_untrap_x_errors ();
+
+      if (x_error != 0)
+        context_glx->glx_context = NULL;
+      context_glx->priv->context_api = GST_GL_API_OPENGL3;
+    }
 
-    if (!context_glx->glx_context || x_error != 0) {
-      GST_DEBUG ("Failed to create an Opengl 3 context. trying a legacy one");
+    if (gl_api & GST_GL_API_OPENGL && context_glx->glx_context == NULL) {
+      GST_DEBUG_OBJECT (window, "trying to create a GL 1.4 context");
 
       gst_gl_window_x11_trap_x_errors ();
       context_glx->glx_context =