Convert from x-raw-gl to a texture

Matthew Waters waters.matthew00 at gmail.com
Wed Apr 3 04:19:36 PDT 2013


On 02/04/13 02:42, Jorge wrote:
> 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 format video/x-raw-gl is already a texture.  To get that texture 
from outside gst-plugins-gl is where things become interesting. Perhaps 
an example is better (I have no idea whether it works, but it shows the 
idea):

http://cgit.freedesktop.org/gstreamer/gst-plugins-gl/tree/tests/examples/clutter/cluttershare.c?h=0.10

The example tries to display gstgl textures with clutter.  There is one 
main thing that you need to be careful of when mixing gst-plugins-gl and 
other openGL libraries/applications. gst-plugins-gl creates its own 
openGL thread that it runs its gl functions is.  This allows seperation 
between gst-gl and other gl libraries/application however increases the 
barrier for integration.  Some extra code is needed to merge two gl 
libraries/application and share the gl context as shown in the example.
> 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.
>


-- 
-Matt



More information about the gstreamer-devel mailing list