From c95152e83e85d81acbb4bb11f0282ad1d52251c5 Mon Sep 17 00:00:00 2001 From: Bernd Busse Date: Sat, 24 Oct 2020 12:53:12 +0200 Subject: [PATCH] backend: gl_common: add `time` uniform to (custom) window shader --- src/backend/gl/gl_common.c | 8 ++++++++ src/backend/gl/gl_common.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/backend/gl/gl_common.c b/src/backend/gl/gl_common.c index e8aa3d87..c139b6c3 100644 --- a/src/backend/gl/gl_common.c +++ b/src/backend/gl/gl_common.c @@ -6,6 +6,7 @@ #include #include #include +#include #include // for xcb_render_fixed_t, XXX #include "backend/backend.h" @@ -416,6 +417,12 @@ static void _gl_compose(backend_t *base, struct backend_image *img, GLuint targe } glUniform1f(win_shader->uniform_border_width, (float)border_width); } + if (win_shader->uniform_time >= 0) { + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + glUniform1f(win_shader->uniform_time, + (float)ts.tv_sec * 1000.0f + (float)ts.tv_nsec / 1.0e6f); + } // log_trace("Draw: %d, %d, %d, %d -> %d, %d (%d, %d) z %d\n", // x, y, width, height, dx, dy, ptex->width, ptex->height, z); @@ -916,6 +923,7 @@ static bool gl_win_shader_from_stringv(const char **vshader_strv, bind_uniform(ret, max_brightness); bind_uniform(ret, corner_radius); bind_uniform(ret, border_width); + bind_uniform(ret, time); gl_check_err(); diff --git a/src/backend/gl/gl_common.h b/src/backend/gl/gl_common.h index bf07c080..c5d22597 100644 --- a/src/backend/gl/gl_common.h +++ b/src/backend/gl/gl_common.h @@ -39,6 +39,7 @@ typedef struct { GLint uniform_max_brightness; GLint uniform_corner_radius; GLint uniform_border_width; + GLint uniform_time; } gl_win_shader_t; // Program and uniforms for brightness shader