Class for handling shaders. More...
#include <pmp/viewers/shader.h>
Public Member Functions | |
| ~Shader () | |
| Default destructor, clears all shaders. | |
| bool | is_valid () const |
| Indicate if shader is valid. | |
| void | source (const char *vshader, const char *fshader) |
| Get source from strings, compile, and link vertex and fragment shader. | |
| void | load (const char *vfile, const char *ffile, const char *gfile=nullptr, const char *tcfile=nullptr, const char *tefile=nullptr) |
| Load from file, compile, and link vertex and fragment shader, and optional geometry and tessellation shaders. | |
| void | use () |
| Enable/bind this shader program. | |
| void | disable () |
| Disable/unbind this shader program. | |
| void | bind_attribute (const char *name, GLuint index) |
| Bind attribute to location. | |
| void | set_uniform (const char *name, float value) |
| Upload float uniform. | |
| void | set_uniform (const char *name, int value) |
| Upload int uniform. | |
| void | set_uniform (const char *name, const vec2 &vec) |
| Upload vec2 uniform. | |
| void | set_uniform (const char *name, const vec3 &vec) |
| Upload vec3 uniform. | |
| void | set_uniform (const char *name, const vec4 &vec) |
| Upload vec4 uniform. | |
| void | set_uniform (const char *name, const mat3 &mat) |
| Upload mat3 uniform. | |
| void | set_uniform (const char *name, const mat4 &mat) |
| Upload mat4 uniform. | |
Class for handling shaders.
| void load | ( | const char * | vfile, |
| const char * | ffile, | ||
| const char * | gfile = nullptr, |
||
| const char * | tcfile = nullptr, |
||
| const char * | tefile = nullptr |
||
| ) |
Load from file, compile, and link vertex and fragment shader, and optional geometry and tessellation shaders.
Unused shaders should be nullptr.
| vfile | string with the address to the vertex shader |
| ffile | string with the address to the fragment shader |
| gfile | filename of geometry shader |
| tcfile | filename of tessellation control shader |
| tefile | filename of tessellation evaluation shader |
Upload mat3 uniform.
| name | string of the uniform name |
| mat | the value for the uniform |
Upload mat4 uniform.
| name | string of the uniform name |
| mat | the value for the uniform |
Upload vec2 uniform.
| name | string of the uniform name |
| vec | the value for the uniform |
Upload vec3 uniform.
| name | string of the uniform name |
| vec | the value for the uniform |
Upload vec4 uniform.
| name | string of the uniform name |
| vec | the value for the uniform |
Upload float uniform.
| name | string of the uniform name |
| value | the value for the uniform |
Upload int uniform.
| name | string of the uniform name |
| value | the value for the uniform |