예제 #1
0
/* Called in the gl thread */
static void
gst_glimage_sink_thread_init_redisplay (GstGLImageSink * gl_sink)
{
  gl_sink->redisplay_shader = gst_gl_shader_new (gl_sink->context);

  if (!gst_gl_shader_compile_with_default_vf_and_check
      (gl_sink->redisplay_shader, &gl_sink->redisplay_attr_position_loc,
          &gl_sink->redisplay_attr_texture_loc))
    gst_glimage_sink_cleanup_glthread (gl_sink);
}
예제 #2
0
static void
_compile_identity_shader (GstGLContext * context, GstGLColorscale * colorscale)
{
  GstGLFilter *filter = GST_GL_FILTER (colorscale);

  colorscale->shader = gst_gl_shader_new (context);

  if (!gst_gl_shader_compile_with_default_vf_and_check (colorscale->shader,
          &filter->draw_attr_position_loc, &filter->draw_attr_texture_loc)) {
    gst_gl_context_clear_shader (context);
    gst_object_unref (colorscale->shader);
    colorscale->shader = NULL;
  }
}
예제 #3
0
static void
gst_gl_effects_identity_callback (gint width, gint height, guint texture,
    gpointer data)
{
  GstGLEffects *effects = GST_GL_EFFECTS (data);
  GstGLFilter *filter = GST_GL_FILTER (effects);
  GstGLContext *context = filter->context;
  GstGLFuncs *gl = context->gl_vtable;

#if GST_GL_HAVE_OPENGL
  if (USING_OPENGL (context)) {
    gl->MatrixMode (GL_PROJECTION);
    gl->LoadIdentity ();
  }
#endif
#if GST_GL_HAVE_GLES2
  if (USING_GLES2 (context)) {
    GstGLShader *shader =
        g_hash_table_lookup (effects->shaderstable, "identity0");

    if (!shader) {
      shader = gst_gl_shader_new (context);
      g_hash_table_insert (effects->shaderstable, (gchar *) "identity0",
          shader);

      if (!gst_gl_shader_compile_with_default_vf_and_check (shader,
              &filter->draw_attr_position_loc,
              &filter->draw_attr_texture_loc)) {
        /* gst gl context error is already set */
        GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
            ("Failed to initialize identity shader, %s",
                gst_gl_context_get_error ()), (NULL));
        return;
      }
    }
    gst_gl_shader_use (shader);

    gl->ActiveTexture (GL_TEXTURE0);
    gl->Enable (GL_TEXTURE_2D);
    gl->BindTexture (GL_TEXTURE_2D, texture);

    gst_gl_shader_set_uniform_1i (shader, "tex", 0);
  }
#endif

  gst_gl_filter_draw_texture (filter, texture, width, height);
}