static void init (gpointer data) { GstGLContext *context = data; /* has to be called in the thread that is going to use the framebuffer */ fbo = gst_gl_framebuffer_new (context); gst_gl_framebuffer_generate (fbo, 320, 240, &fbo_id, &rbo); fail_if (fbo == NULL || fbo_id == 0, "failed to create framebuffer object"); gst_gl_context_gen_texture (context, &tex, GST_VIDEO_FORMAT_RGBA, 320, 240); fail_if (tex == 0, "failed to create texture"); #if GST_GL_HAVE_GLES2 if (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2) { shader = gst_gl_shader_new (context); fail_if (shader == NULL, "failed to create shader object"); gst_gl_shader_set_vertex_source (shader, vertex_shader_str_gles2); gst_gl_shader_set_fragment_source (shader, fragment_shader_str_gles2); error = NULL; gst_gl_shader_compile (shader, &error); fail_if (error != NULL, "Error compiling shader %s\n", error ? error->message : "Unknown Error"); shader_attr_position_loc = gst_gl_shader_get_attribute_location (shader, "a_position"); shader_attr_texture_loc = gst_gl_shader_get_attribute_location (shader, "a_texCoord"); } #endif }
/* Called by gltestsrc and glfilter */ void gst_gl_context_del_fbo (GstGLContext * context, GLuint fbo, GLuint depth_buffer) { GstGLFramebuffer *frame = gst_gl_framebuffer_new (context); DelFBO data = { frame, fbo, depth_buffer }; gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _del_fbo, &data); gst_object_unref (frame); }
gboolean gst_gl_context_gen_fbo (GstGLContext * context, gint width, gint height, GLuint * fbo, GLuint * depthbuffer) { GstGLFramebuffer *frame = gst_gl_framebuffer_new (context); GenFBO data = { frame, width, height, fbo, depthbuffer }; gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _gen_fbo, &data); gst_object_unref (frame); return TRUE; }
gboolean gst_gl_context_use_fbo_v2 (GstGLContext * context, gint texture_fbo_width, gint texture_fbo_height, GLuint fbo, GLuint depth_buffer, GLuint texture_fbo, GLCB_V2 cb, gpointer stuff) { GstGLFramebuffer *frame = gst_gl_framebuffer_new (context); UseFBO2 data = { frame, texture_fbo_width, texture_fbo_height, fbo, depth_buffer, texture_fbo, cb, stuff }; gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _use_fbo_v2, &data); gst_object_unref (frame); return TRUE; }
/* ..everything here has to be simplified! */ gboolean gst_gl_context_use_fbo (GstGLContext * context, gint texture_fbo_width, gint texture_fbo_height, GLuint fbo, GLuint depth_buffer, GLuint texture_fbo, GLCB cb, gint input_tex_width, gint input_tex_height, GLuint input_tex, gdouble proj_param1, gdouble proj_param2, gdouble proj_param3, gdouble proj_param4, GstGLDisplayProjection projection, gpointer stuff) { GstGLFramebuffer *frame = gst_gl_framebuffer_new (context); UseFBO data = { frame, texture_fbo_width, texture_fbo_height, fbo, depth_buffer, texture_fbo, cb, input_tex_width, input_tex_height, input_tex, proj_param1, proj_param2, proj_param3, proj_param4, projection, stuff }; gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _use_fbo, &data); gst_object_unref (frame); return TRUE; }