Tucano  0.1
A library for rapid prototyping with modern OpenGL and GLSL
Tucano::Shader Class Reference

A Shader object represents one GLSL program. More...

#include <shader.hpp>

Public Member Functions

void createProgramID (void)
 Copy Contructor Copies the shader codes and recompiles to generate new program. More...
 
void createShaders (void)
 Create the necessary shaders. More...
 
 Shader (string name, string vertex_shader_path, string fragment_shader_path, string geometry_shader_path="", string tessellation_evaluation_shader_path="", string tessellation_control_shader_path="")
 Constructor that receives the path for each shader separately. More...
 
 Shader (string name, string shader_dir)
 Constructors that searches a given directory for shaders with given name. More...
 
 Shader ()
 Empty constructor. More...
 
void setShaderName (string name)
 Sets the shader name, very useful for debugging. More...
 
string getShaderName (void)
 Returns a string with the shader name. More...
 
GLuint getShaderProgram (void)
 Returns the program identification handle. More...
 
GLuint getFragmentShader (void)
 Returns a handle to the fragment shader. More...
 
GLuint getVertexShader (void)
 Returns a handle to the vertex shader. More...
 
GLuint getGeometryShader (void)
 Returns a handle to the geometry shader. More...
 
GLuint getTessellationControlShader (void)
 Returns a handle to the tessellation control shader. More...
 
GLuint getTessellationEvaluationShader (void)
 Returns a handle to the tessellation evaluation shader. More...
 
GLuint getComputeShader (void)
 
void load (string name, string shader_dir="")
 Loads a shader given a directory and a name. Searches for all shader extensions in directory. More...
 
void linkProgram (void)
 Link shader program and check for link errors. More...
 
void initializeTF (int size, const char **varlist, GLenum buffer_mode=GL_INTERLEAVED_ATTRIBS)
 Initializes shader and prepares it to use Transform Feedback. More...
 
void initializeFromStrings (string in_vertex_code, string in_fragment_code, string in_geometry_code="", string in_tessellation_evaluation_code="", string in_tessellation_control_code="")
 Initializes shader directly from string, no files. More...
 
void initialize (void)
 Calls all the functions related to the shader initialization, i.e., creates, loads the shaders from the external files and links the shader program. More...
 
void setVertexShader (string &vertexShaderCode)
 Loads vertex code into shader program. More...
 
void readVertexCode (void)
 Reads the external file containing the vertex shader and loads it into the shader program. More...
 
void setTessellationControlShader (string &tessellationControlCode)
 Loads tessellation control code into shader program. More...
 
void readTessellationControlCode (void)
 Reads the external file containing the tessellation control shader and loads it into the shader program. More...
 
void setTessellationEvaluationShader (string &tessellationEvaluationCode)
 Loads tessellation evaluation code into shader program. More...
 
void readTessellationEvaluationCode (void)
 Reads the external file containing the tessellation evaluation shader and loads it into the shader program. More...
 
void setGeometryShader (string &geometryShaderCode)
 Loads geometry code into shader program. More...
 
void readGeometryCode (void)
 Reads the external file containing the geometry shader and loads it into the shader program. More...
 
void setFragmentShader (string &fragmentShaderCode)
 Loads fragment code into shader program. More...
 
void readFragmentCode (void)
 Reads the external file containing the fragment shader and loads it into the shader program. More...
 
void setComputeShader (string &computeShaderCode)
 Loads compute code into shader program. More...
 
void readComputeShaderCode (void)
 Reads the external file containing the compute shader code. More...
 
void reloadShaders (void)
 Reloads all shaders by reading the files again. More...
 
void bind (void)
 Enables the shader program for usage. More...
 
void unbind (void)
 Disables the shader program. More...
 
void getActiveAttributes (vector< string > &attribs)
 Detaches and deletes the shaders and the shader program. More...
 
GLint getUniformLocation (const GLchar *name) const
 
GLint getAttributeLocation (const GLchar *name) const
 
void setUniform (GLint location, GLint a, GLint b, GLint c, GLint d)
 Sets an uniform integer 4D vector (ivec4) given a location and the vector values. More...
 
void setUniform (GLint location, GLint a, GLint b, GLint c)
 Sets an uniform integer 3D vector (ivec3) given a location and the vector values. More...
 
void setUniform (GLint location, GLint a, GLint b)
 Sets an uniform integer 2D vector (ivec2) given a location and the vector values. More...
 
void setUniform (GLint location, GLint a)
 Sets an uniform integer given a location and the integer value. More...
 
void setUniform (const GLchar *name, GLint a, GLint b, GLint c, GLint d)
 Sets an uniform integer 4D vector (ivec4) given its name in the shader and the vector values. More...
 
void setUniform (const GLchar *name, GLint a, GLint b, GLint c)
 Sets an uniform integer 3D vector (ivec3) given its name in the shader and the vector values. More...
 
void setUniform (const GLchar *name, GLint a, GLint b)
 Sets an uniform integer 2D vector (ivec2) given its name in the shader and the vector values. More...
 
void setUniform (const GLchar *name, GLint a)
 Sets an uniform integer given its name in the shader and the integer value. More...
 
void setUniform (GLint location, const Eigen::Vector4i &vec)
 Sets an uniform integer 4D vector (ivec4) given a location and the vector with values. More...
 
void setUniform (GLint location, const Eigen::Vector3i &vec)
 Sets an uniform integer 3D vector (ivec3) given a location and the vector with values. More...
 
void setUniform (GLint location, const Eigen::Vector2i &vec)
 Sets an uniform integer 2D vector (ivec2) given a location and the vector with values. More...
 
void setUniform (const GLchar *name, const Eigen::Vector4i &vec)
 Sets an uniform integer 4D vector (ivec4) given its name in the shader and the vector with values. More...
 
void setUniform (const GLchar *name, const Eigen::Vector3i &vec)
 Sets an uniform integer 3D vector (ivec3) given its name in the shader and the vector with values. More...
 
void setUniform (const GLchar *name, const Eigen::Vector2i &vec)
 Sets an uniform integer 2D vector (ivec2) given its name in the shader and the vector with values. More...
 
void setUniform (GLint location, GLfloat a, GLfloat b, GLfloat c, GLfloat d)
 Sets an uniform float 4D vector (vec4) given a location and the vector values. More...
 
void setUniform (GLint location, GLfloat a, GLfloat b, GLfloat c)
 Sets an uniform float 3D vector (vec3) given a location and the vector values. More...
 
void setUniform (GLint location, GLfloat a, GLfloat b)
 Sets an uniform float 2D vector (vec2) given a location and the vector values. More...
 
void setUniform (GLint location, GLfloat a)
 Sets an uniform float given a location and the float value. More...
 
void setUniform (const GLchar *name, GLfloat a, GLfloat b, GLfloat c, GLfloat d)
 Sets an uniform float 4D vector (vec4) given its name in the shader and the vector values. More...
 
void setUniform (const GLchar *name, GLfloat a, GLfloat b, GLfloat c)
 Sets an uniform float 3D vector (vec3) given its name in the shader and the vector values. More...
 
void setUniform (const GLchar *name, GLfloat a, GLfloat b)
 Sets an uniform float 2D vector (vec4) given its name in the shader and the vector values. More...
 
void setUniform (const GLchar *name, GLfloat a)
 Sets an uniform float given its name in the shader and the float value. More...
 
void setUniform (GLint location, const Eigen::Vector4f &vec)
 Sets an uniform float 4D vector (vec4) given a location and the vector with values. More...
 
void setUniform (GLint location, const Eigen::Vector3f &vec)
 Sets an uniform float 3D vector (vec3) given a location and the vector with values. More...
 
void setUniform (GLint location, const Eigen::Vector2f &vec)
 Sets an uniform float 2D vector (vec2) given a location and the vector with values. More...
 
void setUniform (const GLchar *name, const Eigen::Vector4f &vec)
 Sets an uniform float 4D vector (vec4) given its name in the shader and the vector with values. More...
 
void setUniform (const GLchar *name, const Eigen::Vector3f &vec)
 Sets an uniform float 3D vector (vec3) given its name in the shader and the vector with values. More...
 
void setUniform (const GLchar *name, const Eigen::Vector2f &vec)
 Sets an uniform float 2D vector (vec2) given its name in the shader and the vector with values. More...
 
void setUniform (GLint location, GLdouble a, GLdouble b, GLdouble c, GLdouble d)
 Sets an uniform float 4D vector (vec4) given a location and the vector values as Double. The double values are converted to float. More...
 
void setUniform (GLint location, GLdouble a, GLdouble b, GLdouble c)
 Sets an uniform float 3D vector (vec3) given a location and the vector values as Double. The double values are converted to float. More...
 
void setUniform (GLint location, GLdouble a, GLdouble b)
 Sets an uniform float 2D vector (vec2) given a location and the vector values as Double. The double values are converted to float. More...
 
void setUniform (GLint location, GLdouble a)
 Sets an uniform float given a location and a double value that is converted to float. More...
 
void setUniform (const GLchar *name, GLdouble a, GLdouble b, GLdouble c, GLdouble d)
 Sets an uniform float 4D vector (vec4) given its name in the shader and the vector values as Double. More...
 
void setUniform (const GLchar *name, GLdouble a, GLdouble b, GLdouble c)
 Sets an uniform float 3D vector (vec3) given its name in the shader and the vector values as Double. More...
 
void setUniform (const GLchar *name, GLdouble a, GLdouble b)
 Sets an uniform float 2D vector (vec2) given its name in the shader and the vector values as Double. More...
 
void setUniform (const GLchar *name, GLdouble a)
 Sets an uniform float given its name in the shader and a double value that is converted to float. More...
 
void setUniform (GLint location, const Eigen::Vector4d vec)
 Sets an uniform float 4D vector (vec4) given a location and the double vector that is converted to float. More...
 
void setUniform (GLint location, const Eigen::Vector3d vec)
 Sets an uniform float 3D vector (vec3) given a location and the double vector that is converted to float. More...
 
void setUniform (GLint location, const Eigen::Vector2d vec)
 Sets an uniform float 2D vector (vec2) given a location and the double vector that is converted to float. More...
 
void setUniform (const GLchar *name, const Eigen::Vector4d vec)
 Sets an uniform float 4D vector (vec4) given its name in the shader and the double vector that is converted to float. More...
 
void setUniform (const GLchar *name, const Eigen::Vector3d vec)
 Sets an uniform float 3D vector (vec3) given its name in the shader and the double vector that is converted to float. More...
 
void setUniform (const GLchar *name, const Eigen::Vector2d vec)
 Sets an uniform float 2D vector (vec2) given its name in the shader and the double vector that is converted to float. More...
 
void setUniform (GLint location, const GLint *v, GLuint nvalues, GLsizei count=1)
 Sets a integer uniform vector value given its location and an array with the values. More...
 
void setUniform (GLint location, const GLfloat *v, GLuint nvalues, GLsizei count=1)
 Sets a float uniform vector value given its location and an array with the values. More...
 
void setUniform (const GLchar *name, const GLint *v, GLuint nvalues, GLsizei count=1)
 Sets a integer uniform vector value given its name in shader and an array with the values. More...
 
void setUniform (const GLchar *name, const GLfloat *v, GLuint nvalues, GLsizei count=1)
 Sets a float uniform vector value given its name in shader and an array with the values. More...
 
void setUniform (GLint location, const GLfloat *m, GLuint dim, GLboolean transpose=GL_FALSE, GLsizei count=1)
 Sets a uniform float matrix value given its location. More...
 
void setUniform (const GLchar *name, const GLfloat *m, GLuint dim, GLboolean transpose=GL_FALSE, GLsizei count=1)
 Sets a uniform float matrix value given its name in shader code. More...
 
void setUniform (GLint location, const Eigen::Matrix4f &matrix)
 Sets a uniform 4x4 float matrix value given its location and eigen 4x4 matrix. More...
 
void setUniform (GLint location, const Eigen::Matrix3f &matrix)
 Sets a uniform 3x3 float matrix value given its location and eigen 3x3 matrix. More...
 
void setUniform (GLint location, const Eigen::Matrix2f &matrix)
 Sets a uniform 2x2 float matrix value given its location and eigen 2x2 matrix. More...
 
void setUniform (const GLchar *name, const Eigen::Matrix4f &matrix)
 Sets a uniform 4x4 float matrix value given its name in shader and eigen 4x4 matrix. More...
 
void setUniform (const GLchar *name, const Eigen::Matrix3f &matrix)
 Sets a uniform 3x3 float matrix value given its name in shader and eigen 3x3 matrix. More...
 
void setUniform (const GLchar *name, const Eigen::Matrix2f &matrix)
 Sets a uniform 2x2 float matrix value given its name in shader and eigen 2x2 matrix. More...
 
void setUniform (GLint location, const Eigen::Affine3f &affine_matrix)
 Sets a uniform 4x4 float matrix value given its location and eigen 3x3 affine matrix. More...
 
void setUniform (GLint location, const Eigen::Affine2f &affine_matrix)
 Sets a uniform 3x3 float matrix value given its location and eigen 2x2 affine matrix. More...
 
void setUniform (const GLchar *name, const Eigen::Affine3f &affine_matrix)
 Sets a uniform 4x4 float matrix value given its name in shader and eigen 3x3 affine matrix. More...
 
void setUniform (const GLchar *name, const Eigen::Affine2f &affine_matrix)
 Sets a uniform 3x3 float matrix value given its name in shader and eigen 2x2 affine matrix. More...
 

Private Attributes

string shaderName
 Stores an user mainteined identification for the shader. If the shader is created with the autoloader, the name is equal to the filename, without extensions. More...
 
string vertexShaderPath
 Stores the path to the vertex shader file. More...
 
string tessellationControlShaderPath
 Stores the path to the tessellation control shader file. More...
 
string tessellationEvaluationShaderPath
 Stores the path to the tessellation evaluation shader file. More...
 
string geometryShaderPath
 Stores the path to the geometry shader file. More...
 
string fragmentShaderPath
 Stores the path to the fragment shader file. More...
 
string computeShaderPath
 Stores the paths to the compute shaders files. More...
 
string vertex_code
 Vertex shader code. More...
 
string fragment_code
 Fragment shader code. More...
 
string geometry_code
 Geometry shader code. More...
 
string tessellation_evaluation_code
 Tesselation evaluation code. More...
 
string tessellation_control_code
 Tesselation control code. More...
 
string compute_shader_code
 Compute shader code. More...
 
GLuint computeShader = 0
 Compute shader identifications. More...
 
GLuint vertexShader = 0
 Vertex Shader identification. More...
 
GLuint tessellationControlShader = 0
 Tessellation Control Shader identification. More...
 
GLuint tessellationEvaluationShader = 0
 Tessellation Evaluation Shader identification. More...
 
GLuint geometryShader = 0
 Geometry Shader identification. More...
 
GLuint fragmentShader = 0
 Fragment Shader identification. More...
 
GLuint shaderProgram = 0
 Shader program identification. More...
 
int debug_level = 1
 Debug level for outputing warnings and messages. More...
 
std::shared_ptr< GLuint > programID_sptr = 0
 Shared pointer for program ID. More...
 
std::shared_ptr< GLuint > vertexID_sptr = 0
 
std::shared_ptr< GLuint > fragID_sptr = 0
 
std::shared_ptr< GLuint > geomID_sptr = 0
 
std::shared_ptr< GLuint > tessEvalID_sptr = 0
 
std::shared_ptr< GLuint > tessContID_sptr = 0
 
std::shared_ptr< GLuint > computeID_sptr = 0
 

Detailed Description

A Shader object represents one GLSL program.

One object can store either the standard rendering pipeline shaders (vertex, geometry, fragment...) or a group of compute shaders. For convenience, it also stores a user defined name, making it easier to access the shaders from within the main program. The shader's name is the same as the shaders filenames, without the extensions.

Constructor & Destructor Documentation

Tucano::Shader::Shader ( string  name,
string  vertex_shader_path,
string  fragment_shader_path,
string  geometry_shader_path = "",
string  tessellation_evaluation_shader_path = "",
string  tessellation_control_shader_path = "" 
)
inline

Constructor that receives the path for each shader separately.

It must receive a vertex and a fragment shader, and optionally can receive a geometry shader.

Parameters
nameThe string to be set as shader identification. User mantained.
vertex_shader_pathString giving the path to the external file containing the vertex shader.
fragment_shader_pathString giving the path to the external file containing the fragment shader.
geometry_shader_pathString giving the path to the external file containing the geometry shader.
tessellation_evaluation_shader_pathString giving the path to the external file containing the tessellation evaluation shader.
tessellation_control_shader_pathString giving the path to the external file containing the tessellation control shader.
Tucano::Shader::Shader ( string  name,
string  shader_dir 
)
inline

Constructors that searches a given directory for shaders with given name.

Receives a directory and a shader name, searches for files with the same name and extesions vert, frag, geom and comp to auto load shaders.

Parameters
shader_dirDirectory containing shaders.
nameShader name, must be the same as the files name without extensions.
Tucano::Shader::Shader ( )
inline

Empty constructor.

Member Function Documentation

void Tucano::Shader::bind ( void  )
inline

Enables the shader program for usage.

After enabling a shader any OpenGL draw call will use it for rendering.

void Tucano::Shader::createProgramID ( void  )
inline

Copy Contructor Copies the shader codes and recompiles to generate new program.

Creates a program ID and sets a shared pointer to monitor it

void Tucano::Shader::createShaders ( void  )
inline

Create the necessary shaders.

void Tucano::Shader::getActiveAttributes ( vector< string > &  attribs)
inline

Detaches and deletes the shaders and the shader program.

Generates a list with all active attributes

Parameters
attribsVector of strings to hold attributes names
GLint Tucano::Shader::getAttributeLocation ( const GLchar *  name) const
inline

Returns the location of an attribute, such as a vertex attribute

Parameters
nameName of the attribute variable in the shader.
Returns
The attribute location, or -1 if the attribute was not found or has an invalid name.
GLuint Tucano::Shader::getComputeShader ( void  )
inline
Returns
Return the Compute Shader identification handle.
GLuint Tucano::Shader::getFragmentShader ( void  )
inline

Returns a handle to the fragment shader.

Returns
The Fragment Shader identification handle.
GLuint Tucano::Shader::getGeometryShader ( void  )
inline

Returns a handle to the geometry shader.

Returns
Return the Geometry Shader identification handle.
string Tucano::Shader::getShaderName ( void  )
inline

Returns a string with the shader name.

If the shader was created with the auto-loader, the name is the same as the shader file name. If not, it's user manteined.

Returns
The shader name.
GLuint Tucano::Shader::getShaderProgram ( void  )
inline

Returns the program identification handle.

Returns
Identification handle.
GLuint Tucano::Shader::getTessellationControlShader ( void  )
inline

Returns a handle to the tessellation control shader.

Returns
Return the Tessellation Control Shader identification handle.
GLuint Tucano::Shader::getTessellationEvaluationShader ( void  )
inline

Returns a handle to the tessellation evaluation shader.

Returns
Return the Tessellation Evaluation Shader identification handle.
GLint Tucano::Shader::getUniformLocation ( const GLchar *  name) const
inline

Given the name of a uniform used inside the shader, returns it's location.

Parameters
nameName of the uniform variable in shader.
Returns
The uniform location.
GLuint Tucano::Shader::getVertexShader ( void  )
inline

Returns a handle to the vertex shader.

Returns
The Vertex Shader identification handle.
void Tucano::Shader::initialize ( void  )
inline

Calls all the functions related to the shader initialization, i.e., creates, loads the shaders from the external files and links the shader program.

void Tucano::Shader::initializeFromStrings ( string  in_vertex_code,
string  in_fragment_code,
string  in_geometry_code = "",
string  in_tessellation_evaluation_code = "",
string  in_tessellation_control_code = "" 
)
inline

Initializes shader directly from string, no files.

Parameters
vertex_codeString containing vertex code.
fragment_codeString containing fragment code.
geometry_codeString containing geometry code, this is optional.
tessellation_evaluation_codeString containing tessellation evaluation code, this is optional.
tessellation_control_codeString containing tessellation control code, this is optional.
void Tucano::Shader::initializeTF ( int  size,
const char **  varlist,
GLenum  buffer_mode = GL_INTERLEAVED_ATTRIBS 
)
inline

Initializes shader and prepares it to use Transform Feedback.

To use Transform Feedbacks somes parameters must be set before linking the program. These parameters are the number and list of varyings to be set by the TF, and the type of buffer.

Parameters
sizeNumber of Transform Feedback varyings.
varlistList of varyings for TF.
buffer_modeCan be interleaved attributes or separate attributes (default is GL_INTERLEAVED_ATTRIBS).
void Tucano::Shader::linkProgram ( void  )
inline

Link shader program and check for link errors.

void Tucano::Shader::load ( string  name,
string  shader_dir = "" 
)
inline

Loads a shader given a directory and a name. Searches for all shader extensions in directory.

Receives a directory and a shader name, searches for files with the same name and extesions vert, frag, geom and comp to auto load shaders.

Parameters
shader_dirDirectory containing shaders.
nameShader name, must be the same as the files name without extensions.
void Tucano::Shader::readComputeShaderCode ( void  )
inline

Reads the external file containing the compute shader code.

void Tucano::Shader::readFragmentCode ( void  )
inline

Reads the external file containing the fragment shader and loads it into the shader program.

void Tucano::Shader::readGeometryCode ( void  )
inline

Reads the external file containing the geometry shader and loads it into the shader program.

void Tucano::Shader::readTessellationControlCode ( void  )
inline

Reads the external file containing the tessellation control shader and loads it into the shader program.

void Tucano::Shader::readTessellationEvaluationCode ( void  )
inline

Reads the external file containing the tessellation evaluation shader and loads it into the shader program.

void Tucano::Shader::readVertexCode ( void  )
inline

Reads the external file containing the vertex shader and loads it into the shader program.

void Tucano::Shader::reloadShaders ( void  )
inline

Reloads all shaders by reading the files again.

This feature enables runtime editing of the shader codes. After saving the text file after editing, the reload applies changes immediately.

void Tucano::Shader::setComputeShader ( string &  computeShaderCode)
inline

Loads compute code into shader program.

Parameters
computeShaderCodeString containing compute shader code
void Tucano::Shader::setFragmentShader ( string &  fragmentShaderCode)
inline

Loads fragment code into shader program.

Parameters
fragmentShaderCodeString containing fragment code.
void Tucano::Shader::setGeometryShader ( string &  geometryShaderCode)
inline

Loads geometry code into shader program.

Parameters
geometryShaderCodeString containing geometry code.
void Tucano::Shader::setShaderName ( string  name)
inline

Sets the shader name, very useful for debugging.

This constructor receives the path to the compute shader

Parameters
nameThe string as the shader name
compute_shader_pathString with the path to the external files containing the compute shader. Default destructor.
nameShader name
void Tucano::Shader::setTessellationControlShader ( string &  tessellationControlCode)
inline

Loads tessellation control code into shader program.

Parameters
tessellationControlShaderCodeString containing code
void Tucano::Shader::setTessellationEvaluationShader ( string &  tessellationEvaluationCode)
inline

Loads tessellation evaluation code into shader program.

Parameters
tessellationEvaluationShaderCodeString containing code
void Tucano::Shader::setUniform ( GLint  location,
GLint  a,
GLint  b,
GLint  c,
GLint  d 
)
inline

Sets an uniform integer 4D vector (ivec4) given a location and the vector values.

Parameters
locationLocation handle of uniform variable.
aFirst value of the ivec4.
bSecond value of the ivec4.
cThird value of the ivec4.
dFourth value of the ivec4.
void Tucano::Shader::setUniform ( GLint  location,
GLint  a,
GLint  b,
GLint  c 
)
inline

Sets an uniform integer 3D vector (ivec3) given a location and the vector values.

Parameters
locationLocation handle of uniform variable.
aFirst value of the ivec3.
bSecond value of the ivec3.
cThird value of the ivec3.
void Tucano::Shader::setUniform ( GLint  location,
GLint  a,
GLint  b 
)
inline

Sets an uniform integer 2D vector (ivec2) given a location and the vector values.

Parameters
locationLocation handle of uniform variable.
aFirst value of the vec2.
bSecond value of the vec2.
void Tucano::Shader::setUniform ( GLint  location,
GLint  a 
)
inline

Sets an uniform integer given a location and the integer value.

Parameters
locationLocation handle of uniform variable.
aInteger value.
void Tucano::Shader::setUniform ( const GLchar *  name,
GLint  a,
GLint  b,
GLint  c,
GLint  d 
)
inline

Sets an uniform integer 4D vector (ivec4) given its name in the shader and the vector values.

Parameters
nameName of uniform variable in the shader code.
aFirst value of the ivec4.
bSecond value of the ivec4.
cThird value of the ivec4.
dFourth value of the ivec4.
void Tucano::Shader::setUniform ( const GLchar *  name,
GLint  a,
GLint  b,
GLint  c 
)
inline

Sets an uniform integer 3D vector (ivec3) given its name in the shader and the vector values.

Parameters
nameName of uniform variable in the shader code.
aFirst value of the ivec3.
bSecond value of the ivec3.
cThird value of the ivec3.
void Tucano::Shader::setUniform ( const GLchar *  name,
GLint  a,
GLint  b 
)
inline

Sets an uniform integer 2D vector (ivec2) given its name in the shader and the vector values.

Parameters
nameName of uniform variable in the shader code.
aFirst value of the ivec2.
bSecond value of the ivec2.
void Tucano::Shader::setUniform ( const GLchar *  name,
GLint  a 
)
inline

Sets an uniform integer given its name in the shader and the integer value.

Parameters
nameName of uniform variable in the shader code.
aInteger value.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Vector4i &  vec 
)
inline

Sets an uniform integer 4D vector (ivec4) given a location and the vector with values.

Parameters
locationLocation handle of uniform variable.
vec4D integer vector.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Vector3i &  vec 
)
inline

Sets an uniform integer 3D vector (ivec3) given a location and the vector with values.

Parameters
locationLocation handle of uniform variable.
vec3D integer vector.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Vector2i &  vec 
)
inline

Sets an uniform integer 2D vector (ivec2) given a location and the vector with values.

Parameters
locationLocation handle of uniform variable.
vec2D integer vector.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Vector4i &  vec 
)
inline

Sets an uniform integer 4D vector (ivec4) given its name in the shader and the vector with values.

Parameters
nameName of uniform variable in the shader code.
vec4D integer vector.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Vector3i &  vec 
)
inline

Sets an uniform integer 3D vector (ivec3) given its name in the shader and the vector with values.

Parameters
nameName of uniform variable in the shader code.
vec3D integer vector.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Vector2i &  vec 
)
inline

Sets an uniform integer 2D vector (ivec2) given its name in the shader and the vector with values.

Parameters
nameName of uniform variable in the shader code.
vec2D integer vector.
void Tucano::Shader::setUniform ( GLint  location,
GLfloat  a,
GLfloat  b,
GLfloat  c,
GLfloat  d 
)
inline

Sets an uniform float 4D vector (vec4) given a location and the vector values.

Parameters
locationLocation handle of uniform variable.
aFirst value of the vec4.
bSecond value of the vec4.
cThird value of the vec4.
dFourth value of the vec4.
void Tucano::Shader::setUniform ( GLint  location,
GLfloat  a,
GLfloat  b,
GLfloat  c 
)
inline

Sets an uniform float 3D vector (vec3) given a location and the vector values.

Parameters
locationLocation handle of uniform variable.
aFirst value of the vec3.
bSecond value of the vec3.
cThird value of the vec3.
void Tucano::Shader::setUniform ( GLint  location,
GLfloat  a,
GLfloat  b 
)
inline

Sets an uniform float 2D vector (vec2) given a location and the vector values.

Parameters
locationLocation handle of uniform variable.
aFirst value of the vec2.
bSecond value of the vec2.
void Tucano::Shader::setUniform ( GLint  location,
GLfloat  a 
)
inline

Sets an uniform float given a location and the float value.

Parameters
locationLocation handle of uniform variable.
aFloat value.
void Tucano::Shader::setUniform ( const GLchar *  name,
GLfloat  a,
GLfloat  b,
GLfloat  c,
GLfloat  d 
)
inline

Sets an uniform float 4D vector (vec4) given its name in the shader and the vector values.

Parameters
nameName of uniform variable in the shader code.
aFirst value of the vec4.
bSecond value of the vec4.
cThird value of the vec4.
dFourth value of the vec4.
void Tucano::Shader::setUniform ( const GLchar *  name,
GLfloat  a,
GLfloat  b,
GLfloat  c 
)
inline

Sets an uniform float 3D vector (vec3) given its name in the shader and the vector values.

Parameters
nameName of uniform variable in the shader code.
aFirst value of the vec3.
bSecond value of the vec3.
cThird value of the vec3.
void Tucano::Shader::setUniform ( const GLchar *  name,
GLfloat  a,
GLfloat  b 
)
inline

Sets an uniform float 2D vector (vec4) given its name in the shader and the vector values.

Parameters
nameName of uniform variable in the shader code.
aFirst value of the vec2.
bSecond value of the vec2.
void Tucano::Shader::setUniform ( const GLchar *  name,
GLfloat  a 
)
inline

Sets an uniform float given its name in the shader and the float value.

Parameters
nameName of uniform variable in the shader code.
aFloat value.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Vector4f &  vec 
)
inline

Sets an uniform float 4D vector (vec4) given a location and the vector with values.

Parameters
locationLocation handle of uniform variable.
vec4D float vector.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Vector3f &  vec 
)
inline

Sets an uniform float 3D vector (vec3) given a location and the vector with values.

Parameters
locationLocation handle of uniform variable.
vec3D float vector.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Vector2f &  vec 
)
inline

Sets an uniform float 2D vector (vec2) given a location and the vector with values.

Parameters
locationLocation handle of uniform variable.
vec2D float vector.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Vector4f &  vec 
)
inline

Sets an uniform float 4D vector (vec4) given its name in the shader and the vector with values.

Parameters
nameName of uniform variable in the shader code.
vec4D float vector.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Vector3f &  vec 
)
inline

Sets an uniform float 3D vector (vec3) given its name in the shader and the vector with values.

Parameters
nameName of uniform variable in the shader code.
vec3D float vector.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Vector2f &  vec 
)
inline

Sets an uniform float 2D vector (vec2) given its name in the shader and the vector with values.

Parameters
nameName of uniform variable in the shader code.
vec2D float vector.
void Tucano::Shader::setUniform ( GLint  location,
GLdouble  a,
GLdouble  b,
GLdouble  c,
GLdouble  d 
)
inline

Sets an uniform float 4D vector (vec4) given a location and the vector values as Double. The double values are converted to float.

Parameters
locationLocation handle of uniform variable.
aFirst value of the vec4.
bSecond value of the vec4.
cThird value of the vec4.
dFourth value of the vec4.
void Tucano::Shader::setUniform ( GLint  location,
GLdouble  a,
GLdouble  b,
GLdouble  c 
)
inline

Sets an uniform float 3D vector (vec3) given a location and the vector values as Double. The double values are converted to float.

Parameters
locationLocation handle of uniform variable.
aFirst value of the vec3.
bSecond value of the vec3.
cThird value of the vec3.
void Tucano::Shader::setUniform ( GLint  location,
GLdouble  a,
GLdouble  b 
)
inline

Sets an uniform float 2D vector (vec2) given a location and the vector values as Double. The double values are converted to float.

Parameters
locationLocation handle of uniform variable.
aFirst value of the vec2.
bSecond value of the vec2.
void Tucano::Shader::setUniform ( GLint  location,
GLdouble  a 
)
inline

Sets an uniform float given a location and a double value that is converted to float.

Parameters
locationLocation handle of uniform variable.
aDouble value.
void Tucano::Shader::setUniform ( const GLchar *  name,
GLdouble  a,
GLdouble  b,
GLdouble  c,
GLdouble  d 
)
inline

Sets an uniform float 4D vector (vec4) given its name in the shader and the vector values as Double.

The double values are converted to float.

Parameters
nameName of uniform variable in the shader code.
aFirst value of the vec4.
bSecond value of the vec4.
cThird value of the vec4.
dFourth value of the vec4.
void Tucano::Shader::setUniform ( const GLchar *  name,
GLdouble  a,
GLdouble  b,
GLdouble  c 
)
inline

Sets an uniform float 3D vector (vec3) given its name in the shader and the vector values as Double.

The double values are converted to float.

Parameters
nameName of uniform variable in the shader code.
aFirst value of the vec3.
bSecond value of the vec3.
cThird value of the vec3.
void Tucano::Shader::setUniform ( const GLchar *  name,
GLdouble  a,
GLdouble  b 
)
inline

Sets an uniform float 2D vector (vec2) given its name in the shader and the vector values as Double.

The double values are converted to float.

Parameters
nameName of uniform variable in the shader code.
aFirst value of the vec2.
bSecond value of the vec2.
void Tucano::Shader::setUniform ( const GLchar *  name,
GLdouble  a 
)
inline

Sets an uniform float given its name in the shader and a double value that is converted to float.

Parameters
nameName of uniform variable in the shader code.
aDouble value.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Vector4d  vec 
)
inline

Sets an uniform float 4D vector (vec4) given a location and the double vector that is converted to float.

Parameters
locationLocation handle of uniform variable.
vec4D double vector.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Vector3d  vec 
)
inline

Sets an uniform float 3D vector (vec3) given a location and the double vector that is converted to float.

Parameters
locationLocation handle of uniform variable.
vec3D double vector.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Vector2d  vec 
)
inline

Sets an uniform float 2D vector (vec2) given a location and the double vector that is converted to float.

Parameters
locationLocation handle of uniform variable.
vec2D double vector.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Vector4d  vec 
)
inline

Sets an uniform float 4D vector (vec4) given its name in the shader and the double vector that is converted to float.

Parameters
nameName of uniform variable in the shader code.
vec4D double vector.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Vector3d  vec 
)
inline

Sets an uniform float 3D vector (vec3) given its name in the shader and the double vector that is converted to float.

Parameters
nameName of uniform variable in the shader code.
vec3D double vector.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Vector2d  vec 
)
inline

Sets an uniform float 2D vector (vec2) given its name in the shader and the double vector that is converted to float.

Parameters
nameName of uniform variable in the shader code.
vec2D double vector.
void Tucano::Shader::setUniform ( GLint  location,
const GLint *  v,
GLuint  nvalues,
GLsizei  count = 1 
)
inline

Sets a integer uniform vector value given its location and an array with the values.

The vector will be passed as int, ivec2, ivec3, or ivec4 depending on the number of values.

Parameters
locationLocation handle of uniform variable.
vInteger array holding the values.
nvaluesNumber of elements per vector.
countNumber of vectors.
void Tucano::Shader::setUniform ( GLint  location,
const GLfloat *  v,
GLuint  nvalues,
GLsizei  count = 1 
)
inline

Sets a float uniform vector value given its location and an array with the values.

The vector will be passed as float, vec2, vec3, or vec4 depending on the number of values.

Parameters
locationLocation handle of uniform variable.
vFloat array holding the values.
nvaluesNumber of values in the vector v.
nvaluesNumber of elements per vector.
countNumber of vectors.
void Tucano::Shader::setUniform ( const GLchar *  name,
const GLint *  v,
GLuint  nvalues,
GLsizei  count = 1 
)
inline

Sets a integer uniform vector value given its name in shader and an array with the values.

The vector will be passed as int, ivec2, ivec3, or ivec4 depending on the number of values.

Parameters
nameName of uniform variable in the shader code.
vInteger array holding the values.
nvaluesNumber of elements per vector.
countNumber of vectors.
void Tucano::Shader::setUniform ( const GLchar *  name,
const GLfloat *  v,
GLuint  nvalues,
GLsizei  count = 1 
)
inline

Sets a float uniform vector value given its name in shader and an array with the values.

The vector will be passed as float, vec2, vec3, or vec4 depending on the number of values.

Parameters
nameName of uniform variable in the shader code.
vFloat array holding the values.
nvaluesNumber of values in the vector v.
nvaluesNumber of elements per vector.
countNumber of vectors.
void Tucano::Shader::setUniform ( GLint  location,
const GLfloat *  m,
GLuint  dim,
GLboolean  transpose = GL_FALSE,
GLsizei  count = 1 
)
inline

Sets a uniform float matrix value given its location.

The uniform matrix is assumed to be a mat2, mat3, or mat4 depending on the given dimension.

Parameters
locationLocation handle of uniform variable.
mMatrix value with dim^2 values
dimDimension of the matrix m.
transposeIf transpose is GL_FALSE, each matrix is assumed to be supplied in in column major order, otherwise is in row major order.
countNumber of elements of the uniform matrix array to be modified. a count of 1 should be used if modifying the value of a single matrix.
void Tucano::Shader::setUniform ( const GLchar *  name,
const GLfloat *  m,
GLuint  dim,
GLboolean  transpose = GL_FALSE,
GLsizei  count = 1 
)
inline

Sets a uniform float matrix value given its name in shader code.

The uniform matrix is assumed to be a mat2, mat3, or mat4 depending on the given dimension.

Parameters
nameName of uniform variable in the shader code.
mMatrix value with dim^2 values
dimDimension of the matrix m.
transposeIf transpose is GL_FALSE, each matrix is assumed to be supplied in in column major order, otherwise is in row major order.
countNumber of elements of the uniform matrix array to be modified. a count of 1 should be used if modifying the value of a single matrix.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Matrix4f &  matrix 
)
inline

Sets a uniform 4x4 float matrix value given its location and eigen 4x4 matrix.

Parameters
locationLocation handle of uniform variable.
matrix4x4 float matrix.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Matrix3f &  matrix 
)
inline

Sets a uniform 3x3 float matrix value given its location and eigen 3x3 matrix.

Parameters
locationLocation handle of uniform variable.
matrix3x3 float matrix.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Matrix2f &  matrix 
)
inline

Sets a uniform 2x2 float matrix value given its location and eigen 2x2 matrix.

Parameters
locationLocation handle of uniform variable.
matrix2x2 float matrix.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Matrix4f &  matrix 
)
inline

Sets a uniform 4x4 float matrix value given its name in shader and eigen 4x4 matrix.

Parameters
nameName of uniform variable in the shader code.
matrix4x4 float matrix.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Matrix3f &  matrix 
)
inline

Sets a uniform 3x3 float matrix value given its name in shader and eigen 3x3 matrix.

Parameters
nameName of uniform variable in the shader code.
matrix3x3 float matrix.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Matrix2f &  matrix 
)
inline

Sets a uniform 2x2 float matrix value given its name in shader and eigen 2x2 matrix.

Parameters
nameName of uniform variable in the shader code.
matrix2x2 float matrix.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Affine3f &  affine_matrix 
)
inline

Sets a uniform 4x4 float matrix value given its location and eigen 3x3 affine matrix.

Parameters
locationLocation handle of uniform variable.
affine_matrix3x3 float affine matrix.
void Tucano::Shader::setUniform ( GLint  location,
const Eigen::Affine2f &  affine_matrix 
)
inline

Sets a uniform 3x3 float matrix value given its location and eigen 2x2 affine matrix.

Parameters
locationLocation handle of uniform variable.
affine_matrix2x2 float affine matrix.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Affine3f &  affine_matrix 
)
inline

Sets a uniform 4x4 float matrix value given its name in shader and eigen 3x3 affine matrix.

Parameters
nameName of uniform variable in the shader code.
affine_matrix3x3 float affine matrix.
void Tucano::Shader::setUniform ( const GLchar *  name,
const Eigen::Affine2f &  affine_matrix 
)
inline

Sets a uniform 3x3 float matrix value given its name in shader and eigen 2x2 affine matrix.

Parameters
nameName of uniform variable in the shader code.
affine_matrix2x2 float affine matrix.
void Tucano::Shader::setVertexShader ( string &  vertexShaderCode)
inline

Loads vertex code into shader program.

Parameters
vertexShaderCodeString containing code
void Tucano::Shader::unbind ( void  )
inline

Disables the shader program.

Member Data Documentation

string Tucano::Shader::compute_shader_code
private

Compute shader code.

std::shared_ptr< GLuint > Tucano::Shader::computeID_sptr = 0
private
GLuint Tucano::Shader::computeShader = 0
private

Compute shader identifications.

string Tucano::Shader::computeShaderPath
private

Stores the paths to the compute shaders files.

int Tucano::Shader::debug_level = 1
private

Debug level for outputing warnings and messages.

std::shared_ptr< GLuint > Tucano::Shader::fragID_sptr = 0
private
string Tucano::Shader::fragment_code
private

Fragment shader code.

GLuint Tucano::Shader::fragmentShader = 0
private

Fragment Shader identification.

string Tucano::Shader::fragmentShaderPath
private

Stores the path to the fragment shader file.

string Tucano::Shader::geometry_code
private

Geometry shader code.

GLuint Tucano::Shader::geometryShader = 0
private

Geometry Shader identification.

string Tucano::Shader::geometryShaderPath
private

Stores the path to the geometry shader file.

std::shared_ptr< GLuint > Tucano::Shader::geomID_sptr = 0
private
std::shared_ptr< GLuint > Tucano::Shader::programID_sptr = 0
private

Shared pointer for program ID.

string Tucano::Shader::shaderName
private

Stores an user mainteined identification for the shader. If the shader is created with the autoloader, the name is equal to the filename, without extensions.

GLuint Tucano::Shader::shaderProgram = 0
private

Shader program identification.

std::shared_ptr< GLuint > Tucano::Shader::tessContID_sptr = 0
private
string Tucano::Shader::tessellation_control_code
private

Tesselation control code.

string Tucano::Shader::tessellation_evaluation_code
private

Tesselation evaluation code.

GLuint Tucano::Shader::tessellationControlShader = 0
private

Tessellation Control Shader identification.

string Tucano::Shader::tessellationControlShaderPath
private

Stores the path to the tessellation control shader file.

GLuint Tucano::Shader::tessellationEvaluationShader = 0
private

Tessellation Evaluation Shader identification.

string Tucano::Shader::tessellationEvaluationShaderPath
private

Stores the path to the tessellation evaluation shader file.

std::shared_ptr< GLuint > Tucano::Shader::tessEvalID_sptr = 0
private
string Tucano::Shader::vertex_code
private

Vertex shader code.

std::shared_ptr< GLuint > Tucano::Shader::vertexID_sptr = 0
private
GLuint Tucano::Shader::vertexShader = 0
private

Vertex Shader identification.

string Tucano::Shader::vertexShaderPath
private

Stores the path to the vertex shader file.


The documentation for this class was generated from the following file: