From 46202d58d385bd0fdaf1fc1f174c994609717807 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 5 Feb 2020 14:52:14 +0100 Subject: [PATCH] opengl: apply subpictures alpha The new subpictures renderer did not apply the alpha value. Signed-off-by: Jean-Baptiste Kempf --- modules/video_output/opengl/sub_renderer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/video_output/opengl/sub_renderer.c b/modules/video_output/opengl/sub_renderer.c index 2bea0b149c..f91e663eec 100644 --- a/modules/video_output/opengl/sub_renderer.c +++ b/modules/video_output/opengl/sub_renderer.c @@ -75,6 +75,7 @@ struct vlc_gl_sub_renderer } aloc; struct { GLint sampler; + GLint alpha; } uloc; GLuint *buffer_objects; @@ -159,9 +160,12 @@ CreateProgram(vlc_object_t *obj, const opengl_vtable_t *vt) "#version 100\n" "precision mediump float;\n" "uniform sampler2D sampler;\n" + "uniform float alpha;\n" "varying vec2 tex_coords;\n" "void main() {\n" - " gl_FragColor = texture2D(sampler, tex_coords);\n" + " vec4 color = texture2D(sampler, tex_coords);\n" + " color.a *= alpha;\n" + " gl_FragColor = color;\n" "}\n"; GLuint program = 0; @@ -222,6 +226,7 @@ FetchLocations(struct vlc_gl_sub_renderer *sr) #define GET_ULOC(x, str) GET_LOC(Uniform, x, str) #define GET_ALOC(x, str) GET_LOC(Attrib, x, str) GET_ULOC(sr->uloc.sampler, "sampler"); + GET_ULOC(sr->uloc.alpha, "alpha"); GET_ALOC(sr->aloc.vertex_pos, "vertex_pos"); GET_ALOC(sr->aloc.tex_coords_in, "tex_coords_in"); @@ -448,6 +453,8 @@ vlc_gl_sub_renderer_Draw(struct vlc_gl_sub_renderer *sr) assert(glr->texture != 0); vt->BindTexture(interop->tex_target, glr->texture); + vt->Uniform1f(sr->uloc.alpha, glr->alpha); + vt->BindBuffer(GL_ARRAY_BUFFER, sr->buffer_objects[2 * i]); vt->BufferData(GL_ARRAY_BUFFER, sizeof(textureCoord), textureCoord, GL_STATIC_DRAW); vt->EnableVertexAttribArray(sr->aloc.tex_coords_in); -- 2.11.4.GIT