From 86c084f1af0b8b657643e92fc806bcfdf4d53e45 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Sun, 19 Oct 2014 08:09:37 +0400 Subject: [PATCH] glx: ask for a GL3 core context --- gst-libs/gst/gl/gstglcolorconvert.c | 2 +- gst-libs/gst/gl/x11/gstglcontext_glx.c | 30 +++++++++++++++----------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c index 5b758fd9ae..b75b1eab0b 100644 --- a/gst-libs/gst/gl/gstglcolorconvert.c +++ b/gst-libs/gst/gl/gstglcolorconvert.c @@ -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, diff --git a/gst-libs/gst/gl/x11/gstglcontext_glx.c b/gst-libs/gst/gl/x11/gstglcontext_glx.c index 6c52f431d3..7c3c23e82b 100644 --- a/gst-libs/gst/gl/x11/gstglcontext_glx.c +++ b/gst-libs/gst/gl/x11/gstglcontext_glx.c @@ -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 (!context_glx->glx_context || x_error != 0) { - GST_DEBUG ("Failed to create an Opengl 3 context. trying a legacy one"); + if (x_error != 0) + context_glx->glx_context = NULL; + context_glx->priv->context_api = GST_GL_API_OPENGL3; + } + + 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 =