Class for handling shaders.
More...
#include <pmp/visualization/shader.h>
|
| ~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 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.
◆ load()
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.
- Parameters
-
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 |
◆ set_uniform() [1/6]
void set_uniform |
( |
const char * |
name, |
|
|
const mat3 & |
mat |
|
) |
| |
Upload mat3 uniform.
- Parameters
-
name | string of the uniform name |
mat | the value for the uniform |
◆ set_uniform() [2/6]
void set_uniform |
( |
const char * |
name, |
|
|
const mat4 & |
mat |
|
) |
| |
Upload mat4 uniform.
- Parameters
-
name | string of the uniform name |
mat | the value for the uniform |
◆ set_uniform() [3/6]
void set_uniform |
( |
const char * |
name, |
|
|
const vec3 & |
vec |
|
) |
| |
Upload vec3 uniform.
- Parameters
-
name | string of the uniform name |
vec | the value for the uniform |
◆ set_uniform() [4/6]
void set_uniform |
( |
const char * |
name, |
|
|
const vec4 & |
vec |
|
) |
| |
Upload vec4 uniform.
- Parameters
-
name | string of the uniform name |
vec | the value for the uniform |
◆ set_uniform() [5/6]
void set_uniform |
( |
const char * |
name, |
|
|
float |
value |
|
) |
| |
Upload float uniform.
- Parameters
-
name | string of the uniform name |
value | the value for the uniform |
◆ set_uniform() [6/6]
void set_uniform |
( |
const char * |
name, |
|
|
int |
value |
|
) |
| |
Upload int uniform.
- Parameters
-
name | string of the uniform name |
value | the value for the uniform |
◆ source()
void source |
( |
const char * |
vshader, |
|
|
const char * |
fshader |
|
) |
| |
Get source from strings, compile, and link vertex and fragment shader.
- Parameters
-
vshader | string with the address to the vertex shader |
fshader | string with the address to the fragment shader |