gleffects: support gl3 whereever gles2 is supported

This commit is contained in:
Matthew Waters 2014-11-12 23:48:32 +11:00 committed by Tim-Philipp Müller
parent 7ffe6fa93e
commit a82db7eb9e
4 changed files with 17 additions and 36 deletions

View file

@ -44,8 +44,7 @@ gst_gl_effects_identity_callback (gint width, gint height, guint texture,
gl->LoadIdentity ();
}
#endif
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (context)) {
if (USING_GLES2 (context) || USING_OPENGL3 (context)) {
GstGLShader *shader =
g_hash_table_lookup (effects->shaderstable, "identity0");
@ -67,12 +66,10 @@ gst_gl_effects_identity_callback (gint width, gint height, guint texture,
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);
}

View file

@ -45,8 +45,7 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
shader = gst_gl_shader_new (context);
g_hash_table_insert (effects->shaderstable, (gchar *) "mirror0", shader);
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (context)) {
if (USING_GLES2 (context) || USING_OPENGL3 (context)) {
if (!gst_gl_shader_compile_with_default_v_and_check (shader,
mirror_fragment_source_gles2, &filter->draw_attr_position_loc,
&filter->draw_attr_texture_loc)) {
@ -57,7 +56,6 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
return;
}
}
#endif
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (context)) {
if (!gst_gl_shader_compile_and_check (shader,
@ -82,18 +80,12 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE0);
if (USING_OPENGL (context))
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (filter->context)) {
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
}
#endif
gst_gl_filter_draw_texture (filter, texture, width, height);
}

View file

@ -45,8 +45,7 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
shader = gst_gl_shader_new (context);
g_hash_table_insert (effects->shaderstable, (gchar *) "squeeze0", shader);
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (context)) {
if (USING_GLES2 (context) || USING_OPENGL3 (context)) {
if (!gst_gl_shader_compile_with_default_v_and_check (shader,
squeeze_fragment_source_gles2, &filter->draw_attr_position_loc,
&filter->draw_attr_texture_loc)) {
@ -57,7 +56,6 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
return;
}
}
#endif
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (context)) {
if (!gst_gl_shader_compile_and_check (shader,
@ -81,18 +79,12 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE0);
if (USING_OPENGL (context))
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (filter->context)) {
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
}
#endif
gst_gl_filter_draw_texture (filter, texture, width, height);
}

View file

@ -78,19 +78,19 @@ const gchar *mirror_fragment_source_opengl =
" gl_FragColor = color * gl_Color;"
"}";
#endif
#if GST_GL_HAVE_GLES2
const gchar *mirror_fragment_source_gles2 =
"precision mediump float;"
"varying vec2 v_texCoord;"
"#ifdef GL_ES\n"
"precision mediump float;\n"
"#endif\n"
"varying vec2 v_texcoord;"
"uniform sampler2D tex;"
"void main () {"
" vec2 texturecoord = v_texCoord.xy;"
" vec2 texturecoord = v_texcoord.xy;"
" float normcoord = texturecoord.x - 0.5;"
" normcoord *= sign (normcoord);"
" texturecoord.x = normcoord + 0.5;"
" gl_FragColor = texture2D (tex, texturecoord);"
"}";
#endif
/* Squeeze effect */
#if GST_GL_HAVE_OPENGL
@ -106,13 +106,14 @@ const gchar *squeeze_fragment_source_opengl =
" gl_FragColor = texture2D (tex, texturecoord);"
"}";
#endif
#if GST_GL_HAVE_GLES2
const gchar *squeeze_fragment_source_gles2 =
"precision mediump float;"
"varying vec2 v_texCoord;"
"#ifdef GL_ES\n"
"precision mediump float;\n"
"#endif\n"
"varying vec2 v_texcoord;"
"uniform sampler2D tex;"
"void main () {"
" vec2 texturecoord = v_texCoord.xy;"
" vec2 texturecoord = v_texcoord.xy;"
" vec2 normcoord = texturecoord - 0.5;"
" float r = length (normcoord);"
" r = pow(r, 0.40)*1.3;"
@ -120,7 +121,6 @@ const gchar *squeeze_fragment_source_gles2 =
" texturecoord = (normcoord + 0.5);"
" gl_FragColor = texture2D (tex, texturecoord);"
"}";
#endif
/* Stretch Effect */
const gchar *stretch_fragment_source =