From 170ac41a87d6becc720e4ec4aee32c5fa57267cc Mon Sep 17 00:00:00 2001 From: Lubosz Sarnecki Date: Thu, 18 Jun 2015 14:15:01 +0200 Subject: [PATCH] glcompositionoverlay: Add compatibility for GL contexts without glGenVertexArrays https://bugzilla.gnome.org/show_bug.cgi?id=745107 --- gst-libs/gst/gl/gstglcompositionoverlay.c | 35 ++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/gl/gstglcompositionoverlay.c b/gst-libs/gst/gl/gstglcompositionoverlay.c index e5f7b9b213..e1268cb3fb 100644 --- a/gst-libs/gst/gl/gstglcompositionoverlay.c +++ b/gst-libs/gst/gl/gstglcompositionoverlay.c @@ -123,6 +123,25 @@ gst_gl_composition_overlay_finalize (GObject * object) G_OBJECT_CLASS (gst_gl_composition_overlay_parent_class)->finalize (object); } +static void +gst_gl_composition_overlay_bind_vertex_buffer (GstGLCompositionOverlay * + overlay) +{ + const GstGLFuncs *gl = overlay->context->gl_vtable; + gl->BindBuffer (GL_ARRAY_BUFFER, overlay->position_buffer); + gl->VertexAttribPointer (overlay->position_attrib, 4, GL_FLOAT, GL_FALSE, + 4 * sizeof (GLfloat), NULL); + + gl->BindBuffer (GL_ARRAY_BUFFER, overlay->texcoord_buffer); + gl->VertexAttribPointer (overlay->texcoord_attrib, 2, GL_FLOAT, GL_FALSE, + 2 * sizeof (GLfloat), NULL); + + gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, overlay->index_buffer); + + gl->EnableVertexAttribArray (overlay->position_attrib); + gl->EnableVertexAttribArray (overlay->texcoord_attrib); +} + static void gst_gl_composition_overlay_init_vertex_buffer (GstGLContext * context, gpointer overlay_pointer) @@ -144,8 +163,10 @@ gst_gl_composition_overlay_init_vertex_buffer (GstGLContext * context, }; /* *INDENT-ON* */ - gl->GenVertexArrays (1, &overlay->vao); - gl->BindVertexArray (overlay->vao); + if (gl->GenVertexArrays) { + gl->GenVertexArrays (1, &overlay->vao); + gl->BindVertexArray (overlay->vao); + } gl->GenBuffers (1, &overlay->position_buffer); gl->BindBuffer (GL_ARRAY_BUFFER, overlay->position_buffer); @@ -173,7 +194,9 @@ gst_gl_composition_overlay_init_vertex_buffer (GstGLContext * context, gl->EnableVertexAttribArray (overlay->position_attrib); gl->EnableVertexAttribArray (overlay->texcoord_attrib); - gl->BindVertexArray (0); + if (gl->GenVertexArrays) { + gl->BindVertexArray (0); + } gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0); gl->BindBuffer (GL_ARRAY_BUFFER, 0); @@ -321,7 +344,11 @@ gst_gl_composition_overlay_draw (GstGLCompositionOverlay * overlay, GstGLShader * shader) { const GstGLFuncs *gl = overlay->context->gl_vtable; - gl->BindVertexArray (overlay->vao); + if (gl->GenVertexArrays) + gl->BindVertexArray (overlay->vao); + else + gst_gl_composition_overlay_bind_vertex_buffer (overlay); + if (overlay->texture_id != -1) gl->BindTexture (GL_TEXTURE_2D, overlay->texture_id); gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);