gst_glsl_stage_new_default_fragment returns NULL

Samuel Hurst samuelh at
Thu Aug 31 13:19:59 UTC 2017

Hi All,

I'm currently trying to debug some code I've been given that is using
the client-draw-callback in glimagesinkelement to overlay some
dynamically created graphics on a video. The first time it's being
called, it follows a code path that seems to be setting up shaders for
the overlayed graphics, but it seems that a call to
gst_glsl_stage_new_default_fragment(ctx) is returning NULL and causing
repercussions later on.

The documentation for this function is seemingly non-existent, and this
isn't my code, so I'm a bit lost as to what could possibly be going
wrong here. Does anyone have any pointers they can give me on how to
debug what's going wrong here?

For reference, this seems to work okay on a desktop, but when trying to
run it on a Raspberry Pi (and hence OpenGL ES 2.0) it seems to fail.
I've pulled out the bits of the code that deal with setting up the
textures, right up until the failure, and you can find this attached.

Thanks in advance,
-------------- next part --------------
GLuint texture = 0;
GLuint width = 0;
GLuint height = 0;
GstVideoFrame v_frame;
GstVideoInfo v_info;
GstBuffer *buf = gst_sample_get_buffer (sample);
GstCaps *caps = gst_sample_get_caps (sample);
GstGLFuncs *funcs = ctx->gl_vtable;
GLenum err;

gst_video_info_from_caps (&v_info, caps);

if (!gst_video_frame_map (&v_frame, &v_info, buf, (GstMapFlags) (GST_MAP_READ | GST_MAP_GL))) {
  g_warning ("Failed to map the video buffer");
  return TRUE;

texture = *(guint *)[0];
width = GST_VIDEO_INFO_WIDTH(&v_info);
height = GST_VIDEO_INFO_HEIGHT(&v_info);


// Create an FBO
GLuint fbo = 0;
funcs->GenFramebuffers (1, &fbo);
err = funcs->GetError();
if (err != GL_NO_ERROR) {
  GST_ERROR("GenFramebuffers failed with error: %s", gl_err_to_str(err));
  return FALSE;

// Create a shader and relevant matrices for rendering textures
GstGLSLStage *frag_stage, *vert_stage;
GError *error = NULL;

if (!gl_utils_data.shader) {

  vert_stage = gst_glsl_stage_new_with_string(ctx, GL_VERTEX_SHADER, GST_GLSL_VERSION_NONE, GST_GLSL_PROFILE_ES|GST_GLSL_PROFILE_COMPATIBILITY, texture_vertex_shader);

  if (!vert_stage) {
      GST_ERROR ("Failed to create vertex shader stage");

  frag_stage = gst_glsl_stage_new_default_fragment(ctx);

  if (!vert_stage || !frag_stage) {
      GST_ERROR("Failed to create shader stages");
      if (vert_stage) gst_object_unref(vert_stage);
      if (frag_stage) gst_object_unref(frag_stage);
      if (errorp) *errorp = GL_INVALID_OPERATION;
      return 1;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the gstreamer-devel mailing list