106 const char* fragment_path,
107 const char** defines,
int count);
151 #define SHADER_SAFE_DESTROY(s) \
Common OpenGL definitions, RAII helpers, and utilities.
GLuint shader_load_compute(const char *compute_path)
Helper to load a compute program from disk.
Definition: shader.c:589
void shader_set_vec4_loc(GLint loc, const float *val)
Definition: shader.c:862
void shader_set_int(Shader *shader, const char *name, int val)
Definition: shader.c:794
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.
Definition: shader.c:698
void shader_set_int_loc(GLint loc, int val)
Definition: shader.c:842
void shader_destroy(Shader *shader)
Destroys the shader wrapper and deletes the GL program.
Definition: shader.c:719
void shader_set_vec2(Shader *shader, const char *name, const float *val)
Definition: shader.c:810
void shader_set_float_loc(GLint loc, float val)
Definition: shader.c:847
void shader_set_vec3(Shader *shader, const char *name, const float *val)
Definition: shader.c:818
void shader_set_vec3_loc(GLint loc, const float *val)
Definition: shader.c:857
void shader_set_mat4(Shader *shader, const char *name, const float *val)
Definition: shader.c:834
GLint shader_get_uniform_location(Shader *shader, const char *name)
Retrieves a uniform location via binary search on the cache.
Definition: shader.c:750
GLuint shader_compile(const char *path, GLenum type)
Compiles a single shader stage from a file.
Definition: shader.c:523
void shader_set_vec4(Shader *shader, const char *name, const float *val)
Definition: shader.c:826
void shader_set_vec2_loc(GLint loc, const float *val)
Definition: shader.c:852
@ SHADER_WARNING_THROTTLE_LIMIT
Definition: shader.h:12
Shader * shader_load_compute_program(const char *compute_path)
Loads a compute program and caches its uniforms.
Definition: shader.c:713
Shader * shader_load(const char *vertex_path, const char *fragment_path)
Loads a linked program and caches all its active uniforms.
Definition: shader.c:693
char * shader_read_file(const char *path)
Reads a shader file into RAM, processing all includes.
Definition: shader.c:489
void shader_use(Shader *shader)
Activates the program for subsequent draw calls (glUseProgram).
Definition: shader.c:743
GLuint shader_load_program(const char *vertex_path, const char *fragment_path)
Helper to load a classic Vertex+Fragment program from disk.
Definition: shader.c:583
void shader_set_mat4_loc(GLint loc, const float *val)
Definition: shader.c:867
void shader_set_float(Shader *shader, const char *name, float val)
Definition: shader.c:802
char * shader_read_file_with_defines(const char *path, const char **defines, int count)
Reads a shader file and injects defines.
Definition: shader.c:414
Wrapper for an OpenGL program with uniform caching and automatic cleanup.
Definition: shader.h:71
bool silent_warnings
Definition: shader.h:78
int entry_count
Definition: shader.h:75
char * name
Definition: shader.h:73
int warning_count
Definition: shader.h:79
GLuint program
Definition: shader.h:72
UniformEntry * entries
Definition: shader.h:74
int entry_capacity
Definition: shader.h:76
Cached uniform metadata for fast lookup.
Definition: shader.h:61
GLint location
Definition: shader.h:63
char * name
Definition: shader.h:62