$darkmode
High-level OpenGL shader management with metadata and uniform caching. More...
Go to the source code of this file.
Data Structures | |
| struct | UniformEntry |
| Cached uniform metadata for fast lookup. More... | |
| struct | Shader |
| Wrapper for an OpenGL program with uniform caching and automatic cleanup. More... | |
Macros | |
| #define | SHADER_SAFE_DESTROY(s) |
| Idempotent shader destruction macro. Sets the pointer to NULL after calling shader_destroy. More... | |
Enumerations | |
| enum | { SHADER_WARNING_THROTTLE_LIMIT = 10 } |
Functions | |
| GLuint | shader_compile (const char *path, GLenum type) |
| Compiles a single shader stage from a file. More... | |
| char * | shader_read_file (const char *path) |
| Reads a shader file into RAM, processing all includes. More... | |
| char * | shader_read_file_with_defines (const char *path, const char **defines, int count) |
| Reads a shader file and injects defines. More... | |
| GLuint | shader_load_program (const char *vertex_path, const char *fragment_path) |
| Helper to load a classic Vertex+Fragment program from disk. More... | |
| GLuint | shader_load_compute (const char *compute_path) |
| Helper to load a compute program from disk. More... | |
| Shader * | shader_load (const char *vertex_path, const char *fragment_path) |
| Loads a linked program and caches all its active uniforms. More... | |
| Shader * | shader_load_compute_program (const char *compute_path) |
| Loads a compute program and caches its uniforms. More... | |
| Shader * | shader_load_with_defines (const char *vertex_path, const char *fragment_path, const char **defines, int count) |
Special loader that injects #define directives before compilation. More... | |
| void | shader_destroy (Shader *shader) |
| Destroys the shader wrapper and deletes the GL program. More... | |
| void | shader_use (Shader *shader) |
Activates the program for subsequent draw calls (glUseProgram). More... | |
| GLint | shader_get_uniform_location (Shader *shader, const char *name) |
| Retrieves a uniform location via binary search on the cache. More... | |
| void | shader_set_int (Shader *shader, const char *name, int val) |
| void | shader_set_float (Shader *shader, const char *name, float val) |
| void | shader_set_vec2 (Shader *shader, const char *name, const float *val) |
| void | shader_set_vec3 (Shader *shader, const char *name, const float *val) |
| void | shader_set_vec4 (Shader *shader, const char *name, const float *val) |
| void | shader_set_mat4 (Shader *shader, const char *name, const float *val) |
| void | shader_set_int_loc (GLint loc, int val) |
| void | shader_set_float_loc (GLint loc, float val) |
| void | shader_set_vec2_loc (GLint loc, const float *val) |
| void | shader_set_vec3_loc (GLint loc, const float *val) |
| void | shader_set_vec4_loc (GLint loc, const float *val) |
| void | shader_set_mat4_loc (GLint loc, const float *val) |
High-level OpenGL shader management with metadata and uniform caching.
| #define SHADER_SAFE_DESTROY | ( | s | ) |
Idempotent shader destruction macro. Sets the pointer to NULL after calling shader_destroy.
| GLuint shader_compile | ( | const char * | path, |
| GLenum | type | ||
| ) |
Compiles a single shader stage from a file.
Supports recursive @header inclusion syntax.
| path | Path to the shader source file. |
| type | GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, or GL_COMPUTE_SHADER. |
| void shader_destroy | ( | Shader * | shader | ) |
Destroys the shader wrapper and deletes the GL program.
| shader | Pointer to the object to free. |
| GLint shader_get_uniform_location | ( | Shader * | shader, |
| const char * | name | ||
| ) |
Retrieves a uniform location via binary search on the cache.
| shader | Pointer to the wrapper. |
| name | Uniform identifier. |
| Shader* shader_load | ( | const char * | vertex_path, |
| const char * | fragment_path | ||
| ) |
Loads a linked program and caches all its active uniforms.
| vertex_path | Path to vertex source. |
| fragment_path | Path to fragment source. |
| GLuint shader_load_compute | ( | const char * | compute_path | ) |
Helper to load a compute program from disk.
| Shader* shader_load_compute_program | ( | const char * | compute_path | ) |
Loads a compute program and caches its uniforms.
| compute_path | Path to compute source. |
| GLuint shader_load_program | ( | const char * | vertex_path, |
| const char * | fragment_path | ||
| ) |
Helper to load a classic Vertex+Fragment program from disk.
| Shader* shader_load_with_defines | ( | const char * | vertex_path, |
| const char * | fragment_path, | ||
| const char ** | defines, | ||
| int | count | ||
| ) |
Special loader that injects #define directives before compilation.
| vertex_path | Vertex source. |
| fragment_path | Fragment source. |
| defines | Array of macro strings (e.g. "BLOOM_ENABLED"). |
| count | Number of macros. |
| char* shader_read_file | ( | const char * | path | ) |
Reads a shader file into RAM, processing all includes.
| path | Absolute or relative path. |
| char* shader_read_file_with_defines | ( | const char * | path, |
| const char ** | defines, | ||
| int | count | ||
| ) |
Reads a shader file and injects defines.
| path | Path to source. |
| defines | Array of macro strings. |
| count | Number of macros. |
| void shader_set_float | ( | Shader * | shader, |
| const char * | name, | ||
| float | val | ||
| ) |
| void shader_set_float_loc | ( | GLint | loc, |
| float | val | ||
| ) |
| void shader_set_int | ( | Shader * | shader, |
| const char * | name, | ||
| int | val | ||
| ) |
| void shader_set_int_loc | ( | GLint | loc, |
| int | val | ||
| ) |
| void shader_set_mat4 | ( | Shader * | shader, |
| const char * | name, | ||
| const float * | val | ||
| ) |
| void shader_set_mat4_loc | ( | GLint | loc, |
| const float * | val | ||
| ) |
| void shader_set_vec2 | ( | Shader * | shader, |
| const char * | name, | ||
| const float * | val | ||
| ) |
| void shader_set_vec2_loc | ( | GLint | loc, |
| const float * | val | ||
| ) |
| void shader_set_vec3 | ( | Shader * | shader, |
| const char * | name, | ||
| const float * | val | ||
| ) |
| void shader_set_vec3_loc | ( | GLint | loc, |
| const float * | val | ||
| ) |
| void shader_set_vec4 | ( | Shader * | shader, |
| const char * | name, | ||
| const float * | val | ||
| ) |
| void shader_set_vec4_loc | ( | GLint | loc, |
| const float * | val | ||
| ) |
| void shader_use | ( | Shader * | shader | ) |
Activates the program for subsequent draw calls (glUseProgram).
| shader | Pointer to the wrapper. |