Add time uniform to old glx glsl shaders (#330)
This commit is contained in:
parent
def63f9a56
commit
9547d7af70
|
@ -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 {};
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <xcb/render.h>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue