From a59229b6d83057650b320e44ad1f2e74f6fceac7 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 25 Sep 2021 16:01:54 -0700 Subject: shader: introduce shader_active_uniforms() The existing shader api only supports caller-provided uniforms and attributes at instantiation time, with no ability to introspect what uniforms are actually actively present in a given shader. This commit adds introspection of the active uniforms for a given shader at creation time, as well as when reloaded, keeping the information around to be accessed via shader_active_uniforms(). The immediate impetus for this is supporting runtime discovery of uniforms present in the shader source, with the intention of exposing these as sequencer tracks for external manipulation. --- src/pig.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/pig.c') diff --git a/src/pig.c b/src/pig.c index 6c11c67..6161b8d 100644 --- a/src/pig.c +++ b/src/pig.c @@ -72,10 +72,12 @@ static void randomize_color(v3f_t *color) static void pig_uniforms_func(shader_t *shader, void *uniforms_ctxt, void *render_ctxt, unsigned n_uniforms, const int *uniforms, const m4f_t *model_x, float alpha) { - play_t *play = render_ctxt; - pig_t *pig = uniforms_ctxt; - unsigned t0, t1; - float r = randf(); + play_t *play = render_ctxt; + pig_t *pig = uniforms_ctxt; + unsigned t0, t1; + float r = randf(); + const shader_uniform_t *active_uniforms; + int n_active_uniforms; if (play_ticks_elapsed(play, PLAY_TICKS_TIMER2, 1000)) { if (shader_reload_files(shader) < 0) -- cgit v1.2.3