[vlc-commits] opengl: apply subpictures alpha

Romain Vimont git at videolan.org
Thu Feb 13 23:12:59 CET 2020


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Wed Feb  5 14:52:14 2020 +0100| [46202d58d385bd0fdaf1fc1f174c994609717807] | committer: Jean-Baptiste Kempf

opengl: apply subpictures alpha

The new subpictures renderer did not apply the alpha value.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=46202d58d385bd0fdaf1fc1f174c994609717807
---

 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);



More information about the vlc-commits mailing list