From dd80a406045680ddd1258b1b9974b5faa95eb960 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 12 Nov 2014 23:48:32 +1100 Subject: [PATCH] gleffects: support gl3 whereever gles2 is supported --- ext/gl/effects/gstgleffectidentity.c | 5 +---- ext/gl/effects/gstgleffectmirror.c | 14 +++----------- ext/gl/effects/gstgleffectsqueeze.c | 14 +++----------- ext/gl/effects/gstgleffectssources.c | 20 ++++++++++---------- 4 files changed, 17 insertions(+), 36 deletions(-) diff --git a/ext/gl/effects/gstgleffectidentity.c b/ext/gl/effects/gstgleffectidentity.c index 5cf06e0..4e1cb04 100644 --- a/ext/gl/effects/gstgleffectidentity.c +++ b/ext/gl/effects/gstgleffectidentity.c @@ -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); } diff --git a/ext/gl/effects/gstgleffectmirror.c b/ext/gl/effects/gstgleffectmirror.c index 35f87e1..06c9473 100644 --- a/ext/gl/effects/gstgleffectmirror.c +++ b/ext/gl/effects/gstgleffectmirror.c @@ -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); - gl->Enable (GL_TEXTURE_2D); + 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); } diff --git a/ext/gl/effects/gstgleffectsqueeze.c b/ext/gl/effects/gstgleffectsqueeze.c index 421ef27..6a723f8 100644 --- a/ext/gl/effects/gstgleffectsqueeze.c +++ b/ext/gl/effects/gstgleffectsqueeze.c @@ -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); - gl->Enable (GL_TEXTURE_2D); + 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); } diff --git a/ext/gl/effects/gstgleffectssources.c b/ext/gl/effects/gstgleffectssources.c index 0b4d2d6..3786503 100644 --- a/ext/gl/effects/gstgleffectssources.c +++ b/ext/gl/effects/gstgleffectssources.c @@ -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 = -- 2.7.4