diff --git a/src/common.h b/src/common.h index df9c7f5..d229bf4 100644 --- a/src/common.h +++ b/src/common.h @@ -107,10 +107,15 @@ typedef struct glx_prog_main { GLint unifm_invert_color; /// Location of uniform "tex" in window GLSL program. GLint unifm_tex; + /// Location of uniform "time" in window GLSL program. + GLint unifm_time; } glx_prog_main_t; #define GLX_PROG_MAIN_INIT \ - { .prog = 0, .unifm_opacity = -1, .unifm_invert_color = -1, .unifm_tex = -1, } + { \ + .prog = 0, .unifm_opacity = -1, .unifm_invert_color = -1, \ + .unifm_tex = -1, .unifm_time = -1 \ + } #else struct glx_prog_main {}; diff --git a/src/opengl.c b/src/opengl.c index e5a57ca..0a80c6d 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -442,6 +443,7 @@ bool glx_load_prog_main(const char *vshader_str, const char *fshader_str, P_GET_UNIFM_LOC("opacity", unifm_opacity); P_GET_UNIFM_LOC("invert_color", unifm_invert_color); P_GET_UNIFM_LOC("tex", unifm_tex); + P_GET_UNIFM_LOC("time", unifm_time); #undef P_GET_UNIFM_LOC gl_check_err(); @@ -1029,12 +1031,16 @@ bool glx_render(session_t *ps, const glx_texture_t *ptex, int x, int y, int dx, // Programmable path assert(pprogram->prog); glUseProgram(pprogram->prog); + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); if (pprogram->unifm_opacity >= 0) glUniform1f(pprogram->unifm_opacity, (float)opacity); if (pprogram->unifm_invert_color >= 0) glUniform1i(pprogram->unifm_invert_color, neg); if (pprogram->unifm_tex >= 0) glUniform1i(pprogram->unifm_tex, 0); + if (pprogram->unifm_time >= 0) + glUniform1f(pprogram->unifm_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", x, y, width, height,