backend: gl_common: add `time` uniform to (custom) window shader

This commit is contained in:
Bernd Busse 2020-10-24 12:53:12 +02:00 committed by Yuxuan Shui
parent 81768f4a11
commit c95152e83e
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
2 changed files with 9 additions and 0 deletions

View File

@ -6,6 +6,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <xcb/render.h> // 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();

View File

@ -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