<div dir="ltr">Hi Matt,<div><div><br><div>1. Actually I don't use the result of 

'gst_gl_display_egl_new_with_egl_display()', I only use:</div><div><i>state->x_gst_display = gst_gl_display_x11_new_with_display(state->xdisplay);</i></div><div>And then use <i>state-></i><i>x_gst_display in </i>gst_gl_context_new_wrapped, gst_gl_display_create_context and gst_gl_display_add_context functions.</div><div>Please see create_gst_shared_context() function.</div><div>Is this wrong?</div><div><br></div><div>2. I'm using the following environment variables for advertising that to GStreamer, isn't this the same?</div><div><font size="1">export GST_GL_WINDOW=x11</font></div><font size="1">export GST_GL_PLATFORM=egl<br>export GST_GL_API=gles2</font></div><div><font size="1"><br></font></div><div>3. Thanks for the info. I've changed save_gst_tga:</div><div><font size="1">const GstGLFuncs *gl = state->sharedContext->gl_vtable;<br>gl->ReadPixels( 0, 0, 300, 300, GL_RGBA, GL_UNSIGNED_BYTE, buffer1 );</font></div><div><font size="1">// ... Save the buffer.</font><br><div><div><br></div></div></div><div>4. Got it, thanks. Removed activate.</div></div><div><br></div><div>Best Regards,</div><div>Lusine</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 17, 2021 at 10:21 AM Matthew Waters <<a href="mailto:ystreet00@gmail.com">ystreet00@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    1. Don't do '<span>gst_gl_display_egl_new_with_egl_display()'
      yourself manually.  You want to use
      gst_gl_display_egl_from_gl_display() from the X11-wrapped
      GstGLDisplay.<br>
    </span><span>2. You are creating an OpenGL ES 2.0
      context but not advertising that to GStreamer with
      gst_gl_display_filter_gl_api().  GStreamer may be creating another
      context type.  GST_DEBUG=<a href="http://3.gl" target="_blank">3.gl</a>*:7 will tell you.<br>
      3. You are not using the OpenGL context-specific function
      pointers.  Each OpenGL context can return completely different
      OpenGL function pointers that are specific to each OpenGL
      context.  Calling the wrong function pointers is undefined
      behaviour.  This is gst_gl_context->gl_vtable for GStreamer.<br>
      4. There is no need to call </span><span>gst_gl_context_activate()
      in save_gst_tga().  gst_gl_context_thread_add() runs your function
      on the correct thread with the correct OpenGL context current
      already.  If you change that, you must reset of course.<br>
      5. A gl tracing tool would also help you drill down into exactly
      what is happening.  e.g. apitrace.<br>
      <br>
      Cheers<br>
      -Matt</span><br>
    <br>
    <div>On 17/9/21 2:23 am, Lusine Hayrapetyan
      via gstreamer-devel wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">Hi Folks,
        <div><br>
        </div>
        <div>I'm experimenting with gstreamer context sharing mechanism.</div>
        <div>I have <i>EGLContext context; </i>and creating gstreamer
          shared context from it with gst_gl_display_create_context()</div>
        <div><br>
        </div>
        <div>Then I want to access the texture which is created in <i>EGLContext</i>
          from gstreamer shared context.</div>
        <div>That is why I'm using gst_gl_context_thread_add to activate
          shared context and save the texture:<br>
        </div>
        <div><br>
        </div>
        <div> gst_gl_context_thread_add(<br>
                  state->sharedContext,<br>
                  (GstGLContextThreadFunc)save_gst_tga,<br>
                  state<br>
              );<br>
        </div>
        <div><br>
        </div>
        <div>// Activate gstreamer context and save the texture to tga
          file.</div>
        <div>static bool save_gst_tga(GstGLContext * context,
          APP_STATE_T * state)<br>
          {<br>
              if (!gst_gl_context_activate(state->sharedContext,
          true))<br>
                  g_print("gst_gl_context_activate(true) returned error
          %d\n", eglGetError());<br>
          <br>
              // Gstreamer context is activated in gstreamer thread, now
          save the texture.</div>
        <div>    // But this produces an empty file!!!<br>
              return save_tga(state, "tga_file_gst.tga");<br>
          }<br>
        </div>
        <div><br>
        </div>
        <div>
          <div>In save_gst_tga I activate gstreamer shared context and
            save the texture but it's empty. Am I missing something?</div>
          <div>I've posted the whole code here:</div>
          <div><a href="https://github.com/LusineH/gstreamer_shared_context/blob/main/testegl.c" target="_blank">https://github.com/LusineH/gstreamer_shared_context/blob/main/testegl.c</a><br>
          </div>
          <div><br>
          </div>
          <div>Regards,</div>
          <div>Lusine</div>
        </div>
      </div>
    </blockquote>
    <br>
  </div>

</blockquote></div>