Shader management

The shader object stores a shader, and assosiated state. Relinquish will edit the shaders to create and vectorize uniform blocks to make it possible to speed up rendring if the hardware supports it. Relinquish always tries to use the most efective renedering path for the hardware available. All uniform data can be set either indivudualy as state stored in the shader or be given as memory blocks.


RShader *r_shader_create(char *debug_output, uint output_size, char **shaders, uint *stages, uint stage_count, char *name, char *instance_block);

Description: Creates a shader from anumbert of shaders. The fuinction returns NULL if it fails to build a shader. The function accepts a pointer to a debug_output buffer of output_size to wich any error message will be written. shaders is an array of poinerts to the null terminated tesxt strings storing the GLSL shader code. Stages indicates the type of each shader, and stage_count the number of shaders and stages to be compiled. Name, is the name of the shader and is only used for debugging purpouses. instance_block is the name of the uniform block (if there are more then one) that should be vectorized so that mult instance draws can be done with different uniform values. If NULL is given the first uniform block is used. If the shader doesnt have any uniform blocks one will be created automaticly that includes all uniforms. It is recomended not to have any textures in the instance uniform block for preformance reasons.


RShader *r_shader_create_simple(char *debug_output, uint output_size, char *vertex, char *fragment, char *name);

Description: This is aconvinience function wrapping r_shader_create that assumes onliu one vertex and one fragment shader.


RShader *r_shader_create_from_file(char *debug_output, uint output_size, char *vertex_file, char *fragment_file, char *name);

Description: Same as r_shader_create_simple, but loads the two shaders from files.


void r_shader_destroy(RShader *shader);

Description: Destroy a shader


boolean r_shader_set(RShader *shader);

Description: Set the current shader to be used when drawing


void r_shader_texture_set(RShader *shader, uint slot, uint texture_id);

Description: Binds a texture to a shader. "Slot" corresponds to the texture sample in thje order that they appear in the shader. It is recomended to use r_shader_uniform_texture_set instead of this function.