[vlc-devel] [PATCH v2 16/29] opengl: apply subpictures alpha

Romain Vimont rom1v at videolabs.io
Thu Feb 6 16:52:22 CET 2020


On Thu, Feb 06, 2020 at 04:32:48PM +0100, Alexandre Janniaux wrote:
> Hi,
> 
> Comments inline,
> 
> On Thu, Feb 06, 2020 at 02:17:45PM +0100, Romain Vimont wrote:
> > The new subpictures renderer did not apply the alpha value.
> > ---
> >  modules/video_output/opengl/sub_renderer.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/modules/video_output/opengl/sub_renderer.c b/modules/video_output/opengl/sub_renderer.c
> > index 2bea0b149c..ec9afe3d60 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,11 @@ 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"
> > +        "  gl_FragColor = vec4(1.0, 1.0, 1.0, alpha) * color;\n"
> 
> It might be cleaner with:
> 
> gl_FragColor = vec4(color.rgb, color.a * alpha);
> 
> or
> 
> color.a *= alpha;
> gl_FragColor = color;

Yes, I agree. I changed to this version.

Thank you

> 
> >          "}\n";
> >
> >      GLuint program = 0;
> > @@ -222,6 +225,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 +452,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.25.0
> >
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list