Convert from x-raw-gl to a texture

Jorge jorgefm at cirsa.com
Mon Apr 1 08:42:10 PDT 2013


Hi,

I would like to integrate the next pipeline 

filesrc location=video.mp4 ! qtdemux ! ffdec_h264 ! glupload ! appsink

in my C++ code. Now I can get the frames in x-raw-gl format, through the
appsink "new-buffer" callback, because glupload is able to convert the
x-raw-yuv to the x-raw-gl format. I thought that the GstBuffer that I get in
the callback can be copied to a texture previously created with some code
like:

static void on_new_buffer( GstElement *sink, void *data )
{
  GstBuffer *buffer;

  // Retrieve the buffer.
  g_signal_emit_by_name( sink, "pull-buffer", &buffer );
  if( !buffer )
    return;

  // update the texture content.
  glBindTexture( GL_TEXTURE_2D, tex_id );
  glTexSubImage2D( GL_TEXTURE_2D,
                   0,
                   0,
                   0,
                   tex_width, tex_height,
                   GL_RGBA,
                   GL_UNSIGNED_BYTE,
                   (GLubyte*)GST_BUFFER_DATA(buffer) );

  gst_buffer_unref( buffer );
}


The texture was created as:

  tex_w = 1366;
  tex_h = 768;

  // Create an OpenGL texture for the image.
  glEnable( GL_TEXTURE_2D );
  glGenTextures( 1, &tex_id );
  glBindTexture( GL_TEXTURE_2D, tex_id );
  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
  glTexImage2D( GL_TEXTURE_2D,
                0,
                GL_RGBA8,
                tex_w, tex_h,
                0,
                GL_RGBA,
                GL_UNSIGNED_BYTE,
                NULL );


But when I paint the texture is black.

Any hint is welcome!




--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Convert-from-x-raw-gl-to-a-texture-tp4659352.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list