Created
November 9, 2021 02:17
-
-
Save Elv13/26677d8f2ea9b1fe5263385c4c29ace5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/common.h b/src/common.h | |
index 193bc2a..74013da 100644 | |
--- a/src/common.h | |
+++ b/src/common.h | |
@@ -109,6 +109,13 @@ typedef struct glx_prog_main { | |
GLint unifm_tex; | |
/// Location of uniform "time" in window GLSL program. | |
GLint unifm_time; | |
+ /// Location of the uniform "resolution" in window GLSL program. | |
+ GLint unifm_win_resolution; | |
+ GLint unifm_root_resolution; | |
+ /// Location of uniform "texcoord" in rounded-corners GLSL program. | |
+ GLint unifm_texcoord; | |
+ /// Location of uniform "texsize" in rounded-corners GLSL program. | |
+ GLint unifm_texsize; | |
} glx_prog_main_t; | |
#define GLX_PROG_MAIN_INIT \ | |
diff --git a/src/opengl.c b/src/opengl.c | |
index 5d2d66c..03ea54f 100644 | |
--- a/src/opengl.c | |
+++ b/src/opengl.c | |
@@ -225,6 +225,10 @@ static void glx_free_prog_main(glx_prog_main_t *pprogram) { | |
pprogram->unifm_opacity = -1; | |
pprogram->unifm_invert_color = -1; | |
pprogram->unifm_tex = -1; | |
+ pprogram->unifm_win_resolution = -1; | |
+ pprogram->unifm_root_resolution = -1; | |
+ pprogram->unifm_texcoord = -1; | |
+ pprogram->unifm_texsize = -1; | |
} | |
/** | |
@@ -596,6 +600,11 @@ bool glx_load_prog_main(const char *vshader_str, const char *fshader_str, | |
P_GET_UNIFM_LOC("invert_color", unifm_invert_color); | |
P_GET_UNIFM_LOC("tex", unifm_tex); | |
P_GET_UNIFM_LOC("time", unifm_time); | |
+ P_GET_UNIFM_LOC("window_resolution", unifm_win_resolution); | |
+ P_GET_UNIFM_LOC("root_resolution", unifm_root_resolution); | |
+ P_GET_UNIFM_LOC("texture_coords", unifm_texcoord); | |
+ P_GET_UNIFM_LOC("texture_size", unifm_texsize); | |
+ | |
#undef P_GET_UNIFM_LOC | |
gl_check_err(); | |
@@ -1420,7 +1429,20 @@ bool glx_render(session_t *ps, const glx_texture_t *ptex, int x, int y, int dx, | |
if (pprogram->unifm_time >= 0) | |
glUniform1f(pprogram->unifm_time, (float)ts.tv_sec * 1000.0f + | |
(float)ts.tv_nsec / 1.0e6f); | |
- } | |
+ if (pprogram->unifm_win_resolution >= 0) { | |
+ glUniform2f(pprogram->unifm_win_resolution, (float)width, (float)height); | |
+ } | |
+ if (pprogram->unifm_root_resolution >= 0) { | |
+ glUniform2f(pprogram->unifm_root_resolution, (float)ps->root_width, | |
+ (float)ps->root_height); | |
+ } | |
+ if (pprogram->unifm_texcoord >= 0) { | |
+ glUniform2f(pprogram->unifm_texcoord, (float)dx, (float)dy); | |
+ } | |
+ if (pprogram->unifm_texsize >= 0) { | |
+ glUniform2f(pprogram->unifm_texsize, (float)width, (float)height); | |
+ } | |
+ } | |
// log_trace("Draw: %d, %d, %d, %d -> %d, %d (%d, %d) z %d", x, y, width, height, | |
// dx, dy, ptex->width, ptex->height, z); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment