GitHub link
PMP
The Polygon Mesh Processing Library
Shader Class Reference

shader class for easy handling of the shader

#include <pmp/visualization/Shader.h>

Public Member Functions

 Shader ()
 default constructor
 
 ~Shader ()
 default destructor
 
bool is_valid () const
 is shader valid (ID != 0)
 
bool source (const char *vshader, const char *fshader)
 get source from strings, compile, and link vertex and fragment shader, More...
 
bool 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. More...
 
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 More...
 
void set_uniform (const char *name, int value)
 upload int uniform More...
 
void set_uniform (const char *name, const vec3 &vec)
 upload vec3 uniform More...
 
void set_uniform (const char *name, const vec4 &vec)
 upload vec4 uniform More...
 
void set_uniform (const char *name, const mat3 &mat)
 upload mat3 uniform More...
 
void set_uniform (const char *name, const mat4 &mat)
 upload mat4 uniform More...
 

Member Function Documentation

◆ load()

bool load ( const char *  vfile,
const char *  ffile,
const char *  gfile = nullptr,
const char *  tcfile = nullptr,
const char *  tefile = nullptr 
)

unused shaders should be NULL.

Parameters
vfilestring with the adress to the vertex shader
ffilestring with the adress to the fragment shader
gfilefilename of geometry shader
tcfilefilename of tessellation control shader
tefilefilename of tessellation evaluation shader

◆ set_uniform() [1/6]

void set_uniform ( const char *  name,
const mat3 mat 
)
Parameters
namestring of the uniform name
matthe value for the uniform

◆ set_uniform() [2/6]

void set_uniform ( const char *  name,
const mat4 mat 
)
Parameters
namestring of the uniform name
matthe value for the uniform

◆ set_uniform() [3/6]

void set_uniform ( const char *  name,
const vec3 vec 
)
Parameters
namestring of the uniform name
vecthe value for the uniform

◆ set_uniform() [4/6]

void set_uniform ( const char *  name,
const vec4 vec 
)
Parameters
namestring of the uniform name
vecthe value for the uniform

◆ set_uniform() [5/6]

void set_uniform ( const char *  name,
float  value 
)
Parameters
namestring of the uniform name
valuethe value for the uniform

◆ set_uniform() [6/6]

void set_uniform ( const char *  name,
int  value 
)
Parameters
namestring of the uniform name
valuethe value for the uniform

◆ source()

bool source ( const char *  vshader,
const char *  fshader 
)
Parameters
vshaderstring with the adress to the vertex shader
fshaderstring with the adress to the fragment shader