[874/906] filter: implement draw_texture for GLES2

(taken from gleffects)
This commit is contained in:
Matthew Waters 2014-01-30 07:49:20 +11:00
parent 4386cc1c6b
commit 0c1a77ca6c
18 changed files with 139 additions and 161 deletions

View file

@ -1089,8 +1089,8 @@ gst_gl_filter_render_to_target (GstGLFilter * filter, gboolean resize,
in_height = out_height;
}
GST_LOG ("rendering to target. in:%ux%u out:%ux%u", in_width, in_height,
out_width, out_height);
GST_LOG ("rendering to target. in %u, %ux%u out %u, %ux%u", input, in_width,
in_height, target, out_width, out_height);
gst_gl_context_use_fbo (filter->context,
out_width, out_height,
@ -1099,22 +1099,23 @@ gst_gl_filter_render_to_target (GstGLFilter * filter, gboolean resize,
in_width, 0, in_height, GST_GL_DISPLAY_PROJECTION_ORTHO2D, data);
}
#if GST_GL_HAVE_OPENGL
static void
_draw_with_shader_cb (gint width, gint height, guint texture, gpointer stuff)
{
GstGLFilter *filter = GST_GL_FILTER (stuff);
GstGLFuncs *gl = filter->context->gl_vtable;
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
#if GST_GL_HAVE_OPENGL
if (gst_gl_context_get_gl_api (filter->context) & GST_GL_API_OPENGL) {
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
gst_gl_shader_use (filter->default_shader);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, texture);
gl->Disable (GL_TEXTURE_2D);
gst_gl_shader_set_uniform_1i (filter->default_shader, "tex", 1);
gst_gl_shader_set_uniform_1f (filter->default_shader, "width", width);
@ -1143,9 +1144,6 @@ void
gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter,
gboolean resize, GLuint input, GLuint target, GstGLShader * shader)
{
g_return_if_fail (gst_gl_context_get_gl_api (filter->context) &
GST_GL_API_OPENGL);
filter->default_shader = shader;
gst_gl_filter_render_to_target (filter, resize, input, target,
_draw_with_shader_cb, filter);
@ -1164,36 +1162,69 @@ void
gst_gl_filter_draw_texture (GstGLFilter * filter, GLuint texture,
guint width, guint height)
{
GstGLFuncs *gl = filter->context->gl_vtable;
GLfloat verts[] = { -1.0f, -1.0f,
1.0f, -1.0f,
1.0f, 1.0f,
-1.0f, 1.0f
};
GLfloat texcoords[] = { 0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f
};
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
GST_DEBUG ("drawing texture:%u dimensions:%ux%u", texture, width, height);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, texture);
#if GST_GL_HAVE_OPENGL
if (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL) {
GLfloat verts[] = { -1.0f, -1.0f,
1.0f, -1.0f,
1.0f, 1.0f,
-1.0f, 1.0f
};
GLfloat texcoords[] = { 0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f
};
gl->ClientActiveTexture (GL_TEXTURE0);
gl->ActiveTexture (GL_TEXTURE0);
gl->EnableClientState (GL_VERTEX_ARRAY);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, texture);
gl->VertexPointer (2, GL_FLOAT, 0, &verts);
gl->TexCoordPointer (2, GL_FLOAT, 0, &texcoords);
gl->ClientActiveTexture (GL_TEXTURE0);
gl->DrawArrays (GL_TRIANGLE_FAN, 0, 4);
gl->EnableClientState (GL_VERTEX_ARRAY);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
gl->DisableClientState (GL_VERTEX_ARRAY);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
gl->VertexPointer (2, GL_FLOAT, 0, &verts);
gl->TexCoordPointer (2, GL_FLOAT, 0, &texcoords);
gl->DrawArrays (GL_TRIANGLE_FAN, 0, 4);
gl->DisableClientState (GL_VERTEX_ARRAY);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
}
#endif
#if GST_GL_HAVE_GLES2
if (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2) {
const GLfloat vVertices[] = {
-1.0f, -1.0f, 0.0f,
0.0f, 0.0f,
1.0, -1.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f
};
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
/* glClear (GL_COLOR_BUFFER_BIT); */
/* Load the vertex position */
gl->VertexAttribPointer (filter->draw_attr_position_loc, 3, GL_FLOAT,
GL_FALSE, 5 * sizeof (GLfloat), vVertices);
/* Load the texture coordinate */
gl->VertexAttribPointer (filter->draw_attr_texture_loc, 2, GL_FLOAT,
GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
gl->EnableVertexAttribArray (filter->draw_attr_position_loc);
gl->EnableVertexAttribArray (filter->draw_attr_texture_loc);
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
}
#endif
}
#endif /* GST_GL_HAVE_OPENGL */

View file

@ -82,6 +82,11 @@ struct _GstGLFilter
GstGLContext *context;
GstGLContext *other_context;
#if GST_GL_HAVE_GLES2
GLint draw_attr_position_loc;
GLint draw_attr_texture_loc;
#endif
};
/**
@ -125,12 +130,10 @@ gboolean gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
void gst_gl_filter_render_to_target (GstGLFilter *filter, gboolean resize, GLuint input,
GLuint target, GLCB func, gpointer data);
#if GST_GL_HAVE_OPENGL
void gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter, gboolean resize,
GLuint input, GLuint target, GstGLShader *shader);
void gst_gl_filter_draw_texture (GstGLFilter *filter, GLuint texture, guint width, guint height);
#endif /* GST_GL_HAVE_OPENGL */
G_END_DECLS

View file

@ -29,7 +29,8 @@ gst_gl_effects_bulge_callback (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "bulge0");
@ -61,7 +62,7 @@ gst_gl_effects_bulge_callback (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void

View file

@ -29,7 +29,8 @@ gst_gl_effects_fisheye_callback (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "fisheye0");
@ -61,7 +62,7 @@ gst_gl_effects_fisheye_callback (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void

View file

@ -32,7 +32,8 @@ gst_gl_effects_glow_step_one (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "glow0");
@ -62,7 +63,7 @@ gst_gl_effects_glow_step_one (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
static void
@ -71,7 +72,8 @@ gst_gl_effects_glow_step_two (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "glow1");
@ -108,7 +110,7 @@ gst_gl_effects_glow_step_two (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7, gauss_kernel);
gst_gl_shader_set_uniform_1f (shader, "height", height);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void
@ -117,7 +119,8 @@ gst_gl_effects_glow_step_three (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "glow2");
@ -149,7 +152,7 @@ gst_gl_effects_glow_step_three (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7, gauss_kernel);
gst_gl_shader_set_uniform_1f (shader, "width", width);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void
@ -158,7 +161,8 @@ gst_gl_effects_glow_step_four (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "glow3");
@ -197,7 +201,7 @@ gst_gl_effects_glow_step_four (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1f (shader, "beta", (gfloat) 1 / 3.5f);
gst_gl_shader_set_uniform_1i (shader, "blend", 1);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void

View file

@ -65,9 +65,9 @@ gst_gl_effects_identity_callback (gint width, gint height, guint texture,
error = NULL;
gst_gl_shader_use (NULL);
} else {
effects->draw_attr_position_loc =
filter->draw_attr_position_loc =
gst_gl_shader_get_attribute_location (shader, "a_position");
effects->draw_attr_texture_loc =
filter->draw_attr_texture_loc =
gst_gl_shader_get_attribute_location (shader, "a_texCoord");
}
}
@ -82,7 +82,7 @@ gst_gl_effects_identity_callback (gint width, gint height, guint texture,
}
#endif
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void

View file

@ -30,7 +30,8 @@ gst_gl_effects_luma_to_curve (GstGLEffects * effects,
gint curve_index, gint width, gint height, GLuint texture)
{
GstGLShader *shader;
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "lumamap0");
@ -86,7 +87,7 @@ gst_gl_effects_luma_to_curve (GstGLEffects * effects,
gl->Disable (GL_TEXTURE_1D);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
static void

View file

@ -63,9 +63,9 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
("%s", gst_gl_context_get_error ()), (NULL));
} else {
effects->draw_attr_position_loc =
filter->draw_attr_position_loc =
gst_gl_shader_get_attribute_location (shader, "a_position");
effects->draw_attr_texture_loc =
filter->draw_attr_texture_loc =
gst_gl_shader_get_attribute_location (shader, "a_texCoord");
}
}
@ -107,7 +107,7 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
}
#endif
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void

View file

@ -30,7 +30,8 @@ gst_gl_effects_rgb_to_curve (GstGLEffects * effects,
gint curve_index, gint width, gint height, GLuint texture)
{
GstGLShader *shader;
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "rgbmap0");
@ -86,7 +87,7 @@ gst_gl_effects_rgb_to_curve (GstGLEffects * effects,
gl->Disable (GL_TEXTURE_1D);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
static void

View file

@ -29,7 +29,8 @@ gst_gl_effects_sin_callback (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "sin0");
@ -58,7 +59,7 @@ gst_gl_effects_sin_callback (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void

View file

@ -29,7 +29,8 @@ gst_gl_effects_square_callback (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "square0");
@ -61,7 +62,7 @@ gst_gl_effects_square_callback (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void

View file

@ -63,9 +63,9 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
("%s", gst_gl_context_get_error ()), (NULL));
} else {
effects->draw_attr_position_loc =
filter->draw_attr_position_loc =
gst_gl_shader_get_attribute_location (shader, "a_position");
effects->draw_attr_texture_loc =
filter->draw_attr_texture_loc =
gst_gl_shader_get_attribute_location (shader, "a_texCoord");
}
}
@ -106,7 +106,7 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
}
#endif
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void

View file

@ -29,7 +29,8 @@ gst_gl_effects_stretch_callback (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "stretch0");
@ -61,7 +62,7 @@ gst_gl_effects_stretch_callback (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void

View file

@ -29,7 +29,8 @@ gst_gl_effects_tunnel_callback (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "tunnel0");
@ -61,7 +62,7 @@ gst_gl_effects_tunnel_callback (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void

View file

@ -29,7 +29,8 @@ gst_gl_effects_twirl_callback (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "twirl0");
@ -61,7 +62,7 @@ gst_gl_effects_twirl_callback (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void

View file

@ -44,7 +44,8 @@ gst_gl_effects_xray_step_two (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray1");
@ -81,7 +82,7 @@ gst_gl_effects_xray_step_two (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1fv (shader, "kernel", 9, gauss_kernel);
gst_gl_shader_set_uniform_1f (shader, "width", width);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
static void
@ -90,7 +91,8 @@ gst_gl_effects_xray_step_three (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray2");
@ -122,7 +124,7 @@ gst_gl_effects_xray_step_three (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1fv (shader, "kernel", 9, gauss_kernel);
gst_gl_shader_set_uniform_1f (shader, "height", height);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
/* multipass separable sobel */
@ -132,7 +134,8 @@ gst_gl_effects_xray_desaturate (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray_desat");
@ -162,7 +165,7 @@ gst_gl_effects_xray_desaturate (gint width, gint height, guint texture,
gl->Disable (GL_TEXTURE_2D);
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
static void
@ -171,7 +174,8 @@ gst_gl_effects_xray_sobel_hconv (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_hconv");
@ -203,7 +207,7 @@ gst_gl_effects_xray_sobel_hconv (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
gst_gl_shader_set_uniform_1f (shader, "width", width);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
static void
@ -212,7 +216,8 @@ gst_gl_effects_xray_sobel_vconv (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_vconv");
@ -244,7 +249,7 @@ gst_gl_effects_xray_sobel_vconv (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
gst_gl_shader_set_uniform_1f (shader, "height", height);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
static void
@ -253,7 +258,8 @@ gst_gl_effects_xray_sobel_length (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_len");
@ -284,7 +290,7 @@ gst_gl_effects_xray_sobel_length (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
gst_gl_shader_set_uniform_1i (shader, "invert", TRUE);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
/* end of sobel passes */
@ -295,7 +301,8 @@ gst_gl_effects_xray_step_five (gint width, gint height, guint texture,
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray4");
@ -333,7 +340,7 @@ gst_gl_effects_xray_step_five (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1f (shader, "alpha", (gfloat) 0.5f);
gst_gl_shader_set_uniform_1i (shader, "blend", 1);
gst_gl_effects_draw_texture (effects, texture, width, height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
void

View file

@ -267,75 +267,6 @@ gst_gl_effects_class_init (GstGLEffectsClass * klass)
"Filippo Argiolas <filippo.argiolas@gmail.com>");
}
void
gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex, guint width,
guint height)
{
GstGLContext *context = GST_GL_FILTER (effects)->context;
GstGLFuncs *gl = context->gl_vtable;
#if GST_GL_HAVE_OPENGL
if (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL) {
GLfloat verts[] = { -1.0f, -1.0f,
1.0f, -1.0f,
1.0f, 1.0f,
-1.0f, 1.0f
};
GLfloat texcoords[] = { 0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f
};
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, tex);
gl->EnableClientState (GL_VERTEX_ARRAY);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
gl->VertexPointer (2, GL_FLOAT, 0, &verts);
gl->TexCoordPointer (2, GL_FLOAT, 0, &texcoords);
gl->DrawArrays (GL_TRIANGLE_FAN, 0, 4);
gl->DisableClientState (GL_VERTEX_ARRAY);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
}
#endif
#if GST_GL_HAVE_GLES2
if (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2) {
const GLfloat vVertices[] = {
-1.0f, -1.0f, 0.0f,
0.0f, 0.0f,
1.0, -1.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f
};
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
/* glClear (GL_COLOR_BUFFER_BIT); */
/* Load the vertex position */
gl->VertexAttribPointer (effects->draw_attr_position_loc, 3, GL_FLOAT,
GL_FALSE, 5 * sizeof (GLfloat), vVertices);
/* Load the texture coordinate */
gl->VertexAttribPointer (effects->draw_attr_texture_loc, 2, GL_FLOAT,
GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
gl->EnableVertexAttribArray (effects->draw_attr_position_loc);
gl->EnableVertexAttribArray (effects->draw_attr_texture_loc);
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
}
#endif
gst_gl_context_clear_shader (context);
}
static void
set_horizontal_swap (GstGLContext * context, gpointer data)
{

View file

@ -66,11 +66,6 @@ struct _GstGLEffects
GHashTable *shaderstable;
gboolean horizontal_swap; /* switch left to right */
#if GST_GL_HAVE_GLES2
GLint draw_attr_position_loc;
GLint draw_attr_texture_loc;
#endif
};
struct _GstGLEffectsClass
@ -88,8 +83,6 @@ enum
GType gst_gl_effects_get_type (void);
void gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex, guint width, guint height);
void gst_gl_effects_identity (GstGLEffects *effects);
void gst_gl_effects_mirror (GstGLEffects *effects);
void gst_gl_effects_squeeze (GstGLEffects *effects);