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/shader.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/shader.h') diff --git a/src/shader.h b/src/shader.h index b52189a..a7df2ec 100644 --- a/src/shader.h +++ b/src/shader.h @@ -19,6 +19,12 @@ typedef struct shader_t shader_t; +typedef struct shader_uniform_t { + char *name; + GLenum type; + int location; +} shader_uniform_t; + unsigned int shader_pair_new_bare(const char *vs_src, const char *fs_src); shader_t * shader_pair_new(const char *vs_src, const char *fs_src, unsigned n_uniforms, const char **uniforms, unsigned n_attributes, const char **attributes); shader_t * shader_pair_new_files(const char *vs_path, const char *fs_path, unsigned n_uniforms, const char **uniforms, unsigned n_attributes, const char **attributes); @@ -26,5 +32,6 @@ void shader_ref(shader_t *shader); shader_t * shader_free(shader_t *shader); void shader_use(shader_t *shader, unsigned *res_n_uniforms, int **res_uniform_locations, unsigned *res_n_attributes, int **res_attribute_locations); int shader_reload_files(shader_t *shader); +void shader_active_uniforms(shader_t *shader, int *res_n_uniforms, const shader_uniform_t **res_uniforms); #endif -- cgit v1.2.3