aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Primak <vyivel@eclair.cafe>2022-05-01 16:03:44 +0300
committerSimon Ser <contact@emersion.fr>2022-05-09 10:08:44 +0000
commit0326ceff903660809385e5d46e9239a4d98d9495 (patch)
treec4d4772774cf41288864e397a81d99a05776dc6e
parent12d84f8c36bb8e6e8ea5f7803a91d58d6a554e38 (diff)
examples/layer-shell: premultiply alpha
-rw-r--r--examples/layer-shell.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/layer-shell.c b/examples/layer-shell.c
index 56a8d4aa..f2e0aaa7 100644
--- a/examples/layer-shell.c
+++ b/examples/layer-shell.c
@@ -124,9 +124,10 @@ static void draw(void) {
glViewport(0, 0, width, height);
if (buttons) {
- glClearColor(1, 1, 1, alpha);
+ glClearColor(alpha, alpha, alpha, alpha);
} else {
- glClearColor(demo.color[0], demo.color[1], demo.color[2], alpha);
+ glClearColor(demo.color[0] * alpha, demo.color[1] * alpha,
+ demo.color[2] * alpha, alpha);
}
glClear(GL_COLOR_BUFFER_BIT);
@@ -151,7 +152,8 @@ static void draw_popup(void) {
eglMakeCurrent(egl_display, popup_egl_surface, popup_egl_surface, egl_context);
glViewport(0, 0, popup_width, popup_height);
- glClearColor(popup_red, 0.5f, 0.5f, popup_alpha);
+ glClearColor(popup_red * popup_alpha, 0.5f * popup_alpha,
+ 0.5f * popup_alpha, popup_alpha);
popup_alpha += alpha_mod;
if (popup_alpha < 0.01 || popup_alpha >= 1.0f) {
alpha_mod *= -1.0;