1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00

Use premultiplied alpha for all colors + improve painting of thin lines

This commit is contained in:
Emil Ernerfeldt
2020-05-11 17:57:11 +02:00
parent 4fcea59929
commit 3860807e29
6 changed files with 130 additions and 48 deletions

View File

@@ -97,7 +97,7 @@ impl Painter {
if (v_pos.x > v_clip_rect.z) { discard; }
if (v_pos.y > v_clip_rect.w) { discard; }
gl_FragColor = v_color;
gl_FragColor.a *= texture2D(u_sampler, v_tc).a;
gl_FragColor *= texture2D(u_sampler, v_tc).a;
}
"#,
)?;
@@ -163,7 +163,7 @@ impl Painter {
let gl = &self.gl;
gl.enable(Gl::BLEND);
gl.blend_func(Gl::SRC_ALPHA, Gl::ONE_MINUS_SRC_ALPHA);
gl.blend_func(Gl::ONE, Gl::ONE_MINUS_SRC_ALPHA); // premultiplied alpha
gl.use_program(Some(&self.program));
gl.active_texture(Gl::TEXTURE0);
gl.bind_texture(Gl::TEXTURE_2D, Some(&self.texture));