NGL  6.5
The NCCA Graphics Library
ngl::ShaderProgram Class Reference

#include <ShaderProgram.h>

+ Collaboration diagram for ngl::ShaderProgram:

Classes

struct  uniformData
 this structure holds information about the registered uniforms in the program id is the uniform location, name is the uniform name, type is the GLenum type More...
 

Public Member Functions

 ShaderProgram (std::string _name) noexcept
 create an OpenGL shader program it is initially empty and just has a name for id More...
 
 ~ShaderProgram ()
 dtor More...
 
void use () noexcept
 use this Shader object as the current Active shader once this is set it is active until unbind us called More...
 
void unbind () noexcept
 method to unbind the current Program Object this will set the shader to be the glUseProgram(0) default value More...
 
void attachShader (Shader *_shader) noexcept
 attach a shader to the ProgramObject More...
 
void bindAttribute (GLuint index, const std::string &_attribName) noexcept
 bind an attribute in the Program object to _index using attribname More...
 
void bindFragDataLocation (GLuint index, const std::string &_attribName) noexcept
 bind fragment output location in the Program object to _index using attribname More...
 
void link () noexcept
 link our program object with the attatched shaders if shader are not attached the program will report the linker errors More...
 
GLuint getID () const noexcept
 get the ProgramID for the Program More...
 
GLint getUniformLocation (const char *_name) const noexcept
 returns the ID of the uniform attribute called 'name'. More...
 
void printActiveUniforms () const noexcept
 lists the available uniforms for the shader (this was a pain because the compiler quietly gets rid of unused uniforms). method written by Richard Southern. More...
 
void printActiveAttributes () const noexcept
 lists the available Attributes for the shader (this was a pain because the compiler quietly gets rid of unused uniforms). method written by Richard Southern. More...
 
void printProperties () const noexcept
 calls the printActiveUniforms followed by Attribs method written by Richard Southern. More...
 
Set uniform argument values from the argument name
void setUniform1f (const char *_varname, float __v0) const noexcept
 sets '_varname' as a float More...
 
void setRegisteredUniform1f (const std::string &_varname, float _v0) const noexcept
 sets the registered uniform to a single float More...
 
void setUniform2f (const char *_varname, float _v0, float _v1) const noexcept
 sets '_varname' as a float2 More...
 
void setRegisteredUniform2f (const std::string &_varname, float _v0, float _v1) const noexcept
 sets the registered uniform to a single float More...
 
void setUniform3f (const char *_varname, float _v0, float _v1, float _v2) const noexcept
 sets '_varname' as a float3 More...
 
void setRegisteredUniform3f (const std::string &_varname, float _v0, float _v1, float _v2) const noexcept
 sets the registered uniform to a single float More...
 
void setUniform4f (const char *_varname, float _v0, float _v1, float _v2, float _v3) const noexcept
 sets '_varname' as a float4 More...
 
void setRegisteredUniform4f (const std::string &_varname, float _v0, float _v1, float _v2, float _v3) const noexcept
 sets the registered uniform to a single float More...
 
void setUniform1fv (const char *_varname, size_t _count, const float *_value) const noexcept
 sets '_varname' as a 1D float array More...
 
void setUniform2fv (const char *_varname, size_t _count, const float *_value) const noexcept
 sets '_varname' as a 2D float array More...
 
void setUniform3fv (const char *_varname, size_t _count, const float *_value) const noexcept
 sets '_varname' as a 3D float array More...
 
void setUniform4fv (const char *_varname, size_t _count, const float *_value) const noexcept
 sets '_varname' as a 4D float array More...
 
Set Program Integer Args

sets '_varname' as an int

Parameters
_varname- name of the uniform variable
_v0- new value for the variable
void setUniform1i (const char *_varname, GLint _v0) const noexcept
 
void setRegisteredUniform1i (const std::string &_varname, int _v0) const noexcept
 sets the registered uniform to a single int More...
 
void setRegisteredUniform2i (const std::string &_varname, int _v0, int _v1) const noexcept
 sets the registered uniform to a single int More...
 
void setRegisteredUniform3i (const std::string &_varname, int _v0, int _v1, int _v2) const noexcept
 sets the registered uniform to a single int More...
 
void setRegisteredUniform4i (const std::string &_varname, int _v0, int _v1, int _v2, int _v3) const noexcept
 sets the registered uniform to a single int More...
 
void setUniform2i (const char *_varname, GLint _v0, GLint _v1) const noexcept
 sets '_varname' as a int2 More...
 
void setUniform3i (const char *_varname, GLint _v0, GLint _v1, GLint _v2) const noexcept
 sets '_varname' as a int3 More...
 
void setUniform4i (const char *_varname, GLint _v0, GLint _v1, GLint _v2, GLint _v3) const noexcept
 sets '_varname' as a float4 More...
 
void setUniform1iv (const char *_varname, size_t _count, const GLint *_value) const noexcept
 sets '_varname' as a 1D int array More...
 
void setUniform2iv (const char *_varname, size_t _count, const GLint *_value) const noexcept
 sets '_varname' as a 2D int array More...
 
void setUniform3iv (const char *_varname, size_t _count, const GLint *_value) const noexcept
 sets '_varname' as a 3D int array More...
 
void setUniform4iv (const char *_varname, size_t _count, const GLint *_value) const noexcept
 sets '_varname' as a 4D int array More...
 
Set Program Matrix Args
void setUniformMatrix2fv (const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
 sets '_varname' as a 2D matrix array More...
 
void setUniformMatrix3fv (const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
 sets '_varname' as a 3D matrix array More...
 
void setRegisteredUniformMatrix3fv (const std::string &_varname, size_t _count, bool _transpose, const float *_value) const noexcept
 sets '_varname' as a 3D matrix array More...
 
void setUniformMatrix4fv (const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
 sets '_varname' as a 4D matrix array More...
 
void setRegisteredUniformMatrix4fv (const std::string &_varname, size_t _count, bool _transpose, const float *_value) const noexcept
 sets '_varname' as a 4D matrix array More...
 
Set Program Matrix Args (only available in OpenGL 2.1)
void setUniformMatrix2x3fv (const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
 sets '_varname' as a 2x3 matrix array More...
 
void setUniformMatrix2x4fv (const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
 sets '_varname' as a 2x4 matrix array More...
 
void setUniformMatrix3x2fv (const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
 sets '_varname' as a 3x2 matrix array More...
 
void setUniformMatrix3x4fv (const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
 sets '_varname' as a 3x4 matrix array More...
 
void setUniformMatrix4x2fv (const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
 sets '_varname' as a 4x2 matrix array More...
 
void setUniformMatrix4x3fv (const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
 sets '_varname' as a 4x3 matrix array More...
 
get program arguments
void getUniformfv (const char *_name, float *o_values) const noexcept
 gets the current value of the specified uniform var More...
 
void getUniformiv (const char *_name, int *o_values) const noexcept
 gets the current value of the specified uniform var More...
 

vertex array functions.

These functions simplify the binding of per-vertex data as a vertex array (or VBO).

bool m_linked
 flag to indicate if the current Program has been linked More...
 
std::vector< Shader * > m_shaders
 a list of the shader objects attached to the program More...
 
GLuint m_programID
 the program id for this program object More...
 
bool m_debugState
 debug mode flag More...
 
std::string m_programName
 text name of the current program used in lookup and debugging More...
 
std::unordered_map< std::string, GLuintm_attribs
 a list of attributes for this object, mapping name to ID number More...
 
std::unordered_map< std::string, uniformDatam_registeredUniforms
 a list of uniforms for this object, mapping name to ID number must be added by the user using the registerUniform method More...
 
bool m_active
 indicate if this program is the current active program More...
 
void enableAttribArray (const char *_name) const noexcept
 enables the specified varying array More...
 
void disableAttribArray (const char *_name) const noexcept
 disables the specified varying array More...
 
void autoRegisterUniforms () noexcept
 scan the shader source and find any uniforms and register them More...
 
void printRegisteredUniforms () const noexcept
 debug print the registered uniforms More...
 
void bindFragDataLocation (GLuint _colourNumber, const char *_name) noexcept
 bind the fragment shader output More...
 
GLuint getUniformBlockIndex (const std::string &_uniformBlockName) const noexcept
 get the index of a uniform bloc More...
 

Detailed Description

Definition at line 37 of file ShaderProgram.h.

Constructor & Destructor Documentation

ShaderProgram::ShaderProgram ( std::string  _name)
noexcept

create an OpenGL shader program it is initially empty and just has a name for id

Parameters
_namethe name of the Program Object

Definition at line 28 of file ShaderProgram.cpp.

References glCreateProgram.

ShaderProgram::~ShaderProgram ( )

dtor

Definition at line 46 of file ShaderProgram.cpp.

References glDeleteProgram, m_programID, and m_programName.

Member Function Documentation

void ShaderProgram::attachShader ( Shader _shader)
noexcept

attach a shader to the ProgramObject

Parameters
_shaderthe Shader object to attach
Note
we can attach many shaders to the ProgramObject.

Definition at line 68 of file ShaderProgram.cpp.

References glAttachShader, m_programID, and m_shaders.

void ShaderProgram::autoRegisterUniforms ( )
noexcept

scan the shader source and find any uniforms and register them

Definition at line 538 of file ShaderProgram.cpp.

References fmt::format(), GL_ACTIVE_UNIFORMS, GL_ZERO, glGetActiveUniform, glGetProgramiv, glGetUniformLocation, ngl::ShaderProgram::uniformData::loc, m_programID, m_registeredUniforms, ngl::ShaderProgram::uniformData::name, and ngl::ShaderProgram::uniformData::type.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ShaderProgram::bindAttribute ( GLuint  index,
const std::string _attribName 
)
noexcept

bind an attribute in the Program object to _index using attribname

Parameters
_indexthe index number we wish to bind to
_attribNamethe name of the attribute we wish to use

Definition at line 75 of file ShaderProgram.cpp.

References glBindAttribLocation, m_attribs, m_linked, m_programID, and ngl::NGLCheckGLError().

+ Here is the call graph for this function:

void ShaderProgram::bindFragDataLocation ( GLuint  index,
const std::string _attribName 
)
noexcept

bind fragment output location in the Program object to _index using attribname

Parameters
_indexthe index number we wish to bind to
_attribNamethe name of the attribute we wish to use

Definition at line 87 of file ShaderProgram.cpp.

References glBindFragDataLocation, m_attribs, m_linked, m_programID, and ngl::NGLCheckGLError().

+ Here is the call graph for this function:

void ShaderProgram::bindFragDataLocation ( GLuint  _colourNumber,
const char *  _name 
)
noexcept

bind the fragment shader output

Parameters
[in]_colourNumberThe color number to bind the user-defined varying out variable to
[in]_namethe name of the output variable to bind

Definition at line 525 of file ShaderProgram.cpp.

References glBindFragDataLocation, and m_programID.

void ShaderProgram::disableAttribArray ( const char *  _name) const
noexcept

disables the specified varying array

Parameters
_name- the name of the varying attr array to enable

Definition at line 517 of file ShaderProgram.cpp.

References getUniformLocation(), and glDisableVertexAttribArray.

+ Here is the call graph for this function:

void ShaderProgram::enableAttribArray ( const char *  _name) const
noexcept

enables the specified varying array

Parameters
_name- the name of the varying attr array to enable

Definition at line 503 of file ShaderProgram.cpp.

References glEnableVertexAttribArray, and m_attribs.

GLuint ngl::ShaderProgram::getID ( ) const
inlinenoexcept

get the ProgramID for the Program

Definition at line 90 of file ShaderProgram.h.

GLuint ShaderProgram::getUniformBlockIndex ( const std::string _uniformBlockName) const
noexcept

get the index of a uniform bloc

Parameters
[in]_uniformBlockNamethe name of the uniform block to get the id for
Returns
the id of the block

Definition at line 532 of file ShaderProgram.cpp.

References glGetUniformBlockIndex, and m_programID.

void ShaderProgram::getUniformfv ( const char *  _name,
float *  o_values 
) const
noexcept

gets the current value of the specified uniform var

Parameters
_name- name of the uniform variable to retrieve
o_values- the output value

Definition at line 490 of file ShaderProgram.cpp.

References getUniformLocation(), glGetUniformfv, and m_programID.

+ Here is the call graph for this function:

void ShaderProgram::getUniformiv ( const char *  _name,
int o_values 
) const
noexcept

gets the current value of the specified uniform var

Parameters
_name- name of the uniform variable to retrieve
o_values- the output value

Definition at line 496 of file ShaderProgram.cpp.

References getUniformLocation(), glGetUniformiv, and m_programID.

+ Here is the call graph for this function:

GLint ShaderProgram::getUniformLocation ( const char *  _name) const
noexcept

returns the ID of the uniform attribute called 'name'.

Returns
the uniform variable id

Definition at line 138 of file ShaderProgram.cpp.

References glGetUniformLocation, m_programID, and m_programName.

+ Here is the caller graph for this function:

void ShaderProgram::link ( )
noexcept

link our program object with the attatched shaders if shader are not attached the program will report the linker errors

Definition at line 102 of file ShaderProgram.cpp.

References autoRegisterUniforms(), GL_FALSE, GL_INFO_LOG_LENGTH, GL_LINK_STATUS, glGetProgramInfoLog, glGetProgramiv, glLinkProgram, glUseProgram, m_debugState, m_linked, m_programID, and m_programName.

+ Here is the call graph for this function:

void ShaderProgram::printActiveAttributes ( ) const
noexcept

lists the available Attributes for the shader (this was a pain because the compiler quietly gets rid of unused uniforms). method written by Richard Southern.

Definition at line 178 of file ShaderProgram.cpp.

References GL_ACTIVE_ATTRIBUTES, GL_FLOAT, GL_FLOAT_MAT2, GL_FLOAT_MAT2x3, GL_FLOAT_MAT2x4, GL_FLOAT_MAT3, GL_FLOAT_MAT3x2, GL_FLOAT_MAT3x4, GL_FLOAT_MAT4, GL_FLOAT_MAT4x2, GL_FLOAT_MAT4x3, GL_FLOAT_VEC2, GL_FLOAT_VEC3, GL_FLOAT_VEC4, glGetActiveAttrib, glGetProgramiv, and m_programID.

+ Here is the caller graph for this function:

void ShaderProgram::printActiveUniforms ( ) const
noexcept

lists the available uniforms for the shader (this was a pain because the compiler quietly gets rid of unused uniforms). method written by Richard Southern.

Definition at line 158 of file ShaderProgram.cpp.

References GL_ACTIVE_UNIFORMS, glGetActiveUniformName, glGetProgramiv, m_active, and m_programID.

+ Here is the caller graph for this function:

void ShaderProgram::printProperties ( ) const
noexcept

calls the printActiveUniforms followed by Attribs method written by Richard Southern.

Definition at line 150 of file ShaderProgram.cpp.

References printActiveAttributes(), and printActiveUniforms().

+ Here is the call graph for this function:

void ShaderProgram::printRegisteredUniforms ( ) const
noexcept

debug print the registered uniforms

Definition at line 582 of file ShaderProgram.cpp.

References GL_BOOL, GL_BOOL_VEC2, GL_BOOL_VEC3, GL_BOOL_VEC4, GL_DOUBLE, GL_DOUBLE_MAT2, GL_DOUBLE_MAT2x3, GL_DOUBLE_MAT2x4, GL_DOUBLE_MAT3, GL_DOUBLE_MAT3x2, GL_DOUBLE_MAT3x4, GL_DOUBLE_MAT4, GL_DOUBLE_MAT4x2, GL_DOUBLE_MAT4x3, GL_DOUBLE_VEC2, GL_DOUBLE_VEC3, GL_DOUBLE_VEC4, GL_FLOAT, GL_FLOAT_MAT2, GL_FLOAT_MAT2x3, GL_FLOAT_MAT2x4, GL_FLOAT_MAT3, GL_FLOAT_MAT3x2, GL_FLOAT_MAT3x4, GL_FLOAT_MAT4, GL_FLOAT_MAT4x2, GL_FLOAT_MAT4x3, GL_FLOAT_VEC2, GL_FLOAT_VEC3, GL_FLOAT_VEC4, GL_IMAGE_1D, GL_IMAGE_1D_ARRAY, GL_IMAGE_2D, GL_IMAGE_2D_ARRAY, GL_IMAGE_2D_MULTISAMPLE, GL_IMAGE_2D_MULTISAMPLE_ARRAY, GL_IMAGE_2D_RECT, GL_IMAGE_3D, GL_IMAGE_BUFFER, GL_IMAGE_CUBE, GL_INT, GL_INT_IMAGE_1D, GL_INT_IMAGE_1D_ARRAY, GL_INT_IMAGE_2D, GL_INT_IMAGE_2D_ARRAY, GL_INT_IMAGE_2D_MULTISAMPLE, GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY, GL_INT_IMAGE_2D_RECT, GL_INT_IMAGE_3D, GL_INT_IMAGE_BUFFER, GL_INT_IMAGE_CUBE, GL_INT_SAMPLER_1D, GL_INT_SAMPLER_1D_ARRAY, GL_INT_SAMPLER_2D, GL_INT_SAMPLER_2D_ARRAY, GL_INT_SAMPLER_2D_MULTISAMPLE, GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, GL_INT_SAMPLER_2D_RECT, GL_INT_SAMPLER_3D, GL_INT_SAMPLER_BUFFER, GL_INT_SAMPLER_CUBE, GL_INT_VEC2, GL_INT_VEC3, GL_INT_VEC4, GL_SAMPLER_1D, GL_SAMPLER_1D_ARRAY, GL_SAMPLER_1D_ARRAY_SHADOW, GL_SAMPLER_1D_SHADOW, GL_SAMPLER_2D, GL_SAMPLER_2D_ARRAY, GL_SAMPLER_2D_ARRAY_SHADOW, GL_SAMPLER_2D_MULTISAMPLE, GL_SAMPLER_2D_MULTISAMPLE_ARRAY, GL_SAMPLER_2D_RECT, GL_SAMPLER_2D_RECT_SHADOW, GL_SAMPLER_2D_SHADOW, GL_SAMPLER_3D, GL_SAMPLER_BUFFER, GL_SAMPLER_CUBE, GL_SAMPLER_CUBE_SHADOW, GL_UNSIGNED_INT, GL_UNSIGNED_INT_ATOMIC_COUNTER, GL_UNSIGNED_INT_IMAGE_1D, GL_UNSIGNED_INT_IMAGE_1D_ARRAY, GL_UNSIGNED_INT_IMAGE_2D, GL_UNSIGNED_INT_IMAGE_2D_ARRAY, GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE, GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY, GL_UNSIGNED_INT_IMAGE_2D_RECT, GL_UNSIGNED_INT_IMAGE_3D, GL_UNSIGNED_INT_IMAGE_BUFFER, GL_UNSIGNED_INT_IMAGE_CUBE, GL_UNSIGNED_INT_SAMPLER_1D, GL_UNSIGNED_INT_SAMPLER_1D_ARRAY, GL_UNSIGNED_INT_SAMPLER_2D, GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, GL_UNSIGNED_INT_SAMPLER_2D_RECT, GL_UNSIGNED_INT_SAMPLER_3D, GL_UNSIGNED_INT_SAMPLER_BUFFER, GL_UNSIGNED_INT_SAMPLER_CUBE, GL_UNSIGNED_INT_VEC2, GL_UNSIGNED_INT_VEC3, GL_UNSIGNED_INT_VEC4, m_programName, and m_registeredUniforms.

void ShaderProgram::setRegisteredUniform1f ( const std::string _varname,
float  _v0 
) const
noexcept

sets the registered uniform to a single float

Parameters
_varname- name of the uniform variable
_v0- new value for the variable

Definition at line 218 of file ShaderProgram.cpp.

References glUniform1f, and m_registeredUniforms.

void ShaderProgram::setRegisteredUniform1i ( const std::string _varname,
int  _v0 
) const
noexcept

sets the registered uniform to a single int

Parameters
_varname- name of the uniform variable
_v0- new value for the variable

Definition at line 315 of file ShaderProgram.cpp.

References glUniform1i, and m_registeredUniforms.

void ShaderProgram::setRegisteredUniform2f ( const std::string _varname,
float  _v0,
float  _v1 
) const
noexcept

sets the registered uniform to a single float

Parameters
_varname- name of the uniform variable
_v0- new value for the variable
_v1- new value for the variable

Definition at line 236 of file ShaderProgram.cpp.

References glUniform2f, and m_registeredUniforms.

void ShaderProgram::setRegisteredUniform2i ( const std::string _varname,
int  _v0,
int  _v1 
) const
noexcept

sets the registered uniform to a single int

Parameters
_varname- name of the uniform variable
_v0- new value for the variable
_v1- new value for the variable

Definition at line 327 of file ShaderProgram.cpp.

References glUniform2i, and m_registeredUniforms.

void ShaderProgram::setRegisteredUniform3f ( const std::string _varname,
float  _v0,
float  _v1,
float  _v2 
) const
noexcept

sets the registered uniform to a single float

Parameters
_varname- name of the uniform variable
_v0- new value for the variable
_v1- new value for the variable
_v2- new value for the variable

Definition at line 253 of file ShaderProgram.cpp.

References glUniform3f, and m_registeredUniforms.

void ShaderProgram::setRegisteredUniform3i ( const std::string _varname,
int  _v0,
int  _v1,
int  _v2 
) const
noexcept

sets the registered uniform to a single int

Parameters
_varname- name of the uniform variable
_v0- new value for the variable
_v1- new value for the variable
_v2- new value for the variable

Definition at line 340 of file ShaderProgram.cpp.

References glUniform3i, and m_registeredUniforms.

void ShaderProgram::setRegisteredUniform4f ( const std::string _varname,
float  _v0,
float  _v1,
float  _v2,
float  _v3 
) const
noexcept

sets the registered uniform to a single float

Parameters
_varname- name of the uniform variable
_v0- new value for the variable
_v1- new value for the variable
_v2- new value for the variable
_v3- new value for the variable

Definition at line 270 of file ShaderProgram.cpp.

References glUniform4f, and m_registeredUniforms.

void ShaderProgram::setRegisteredUniform4i ( const std::string _varname,
int  _v0,
int  _v1,
int  _v2,
int  _v3 
) const
noexcept

sets the registered uniform to a single int

Parameters
_varname- name of the uniform variable
_v0- new value for the variable
_v1- new value for the variable
_v2- new value for the variable
_v3- new value for the variable

Definition at line 351 of file ShaderProgram.cpp.

References glUniform4i, and m_registeredUniforms.

void ShaderProgram::setRegisteredUniformMatrix3fv ( const std::string _varname,
size_t  _count,
bool  _transpose,
const float *  _value 
) const
noexcept

sets '_varname' as a 3D matrix array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_transpose- if true will transpose the matrix values
_value- new value for the variable

Definition at line 418 of file ShaderProgram.cpp.

References glUniformMatrix3fv, and m_registeredUniforms.

void ShaderProgram::setRegisteredUniformMatrix4fv ( const std::string _varname,
size_t  _count,
bool  _transpose,
const float *  _value 
) const
noexcept

sets '_varname' as a 4D matrix array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_transpose- if true will transpose the matrix values
_value- new value for the variable

Definition at line 436 of file ShaderProgram.cpp.

References glUniformMatrix4fv, and m_registeredUniforms.

void ShaderProgram::setUniform1f ( const char *  _varname,
float  __v0 
) const
noexcept

sets '_varname' as a float

Parameters
_varname- name of the uniform variable
_v0- new value for the variable

Definition at line 212 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform1f.

+ Here is the call graph for this function:

void ShaderProgram::setUniform1fv ( const char *  _varname,
size_t  _count,
const float *  _value 
) const
noexcept

sets '_varname' as a 1D float array

Parameters
_varname- name of the uniform variable
count- num elements in the array
value- new value for the variable

Definition at line 282 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform1fv.

+ Here is the call graph for this function:

void ShaderProgram::setUniform1i ( const char *  _varname,
GLint  _v0 
) const
noexcept

Definition at line 308 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform1i.

+ Here is the call graph for this function:

void ShaderProgram::setUniform1iv ( const char *  _varname,
size_t  _count,
const GLint _value 
) const
noexcept

sets '_varname' as a 1D int array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_value- new value for the variable

Definition at line 380 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform1iv.

+ Here is the call graph for this function:

void ShaderProgram::setUniform2f ( const char *  _varname,
float  _v0,
float  _v1 
) const
noexcept

sets '_varname' as a float2

Parameters
_varname- name of the uniform variable
_v0- new value for the variable
_v1- new value for the variable

Definition at line 229 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform2f.

+ Here is the call graph for this function:

void ShaderProgram::setUniform2fv ( const char *  _varname,
size_t  _count,
const float *  _value 
) const
noexcept

sets '_varname' as a 2D float array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_value- new _value for the variable

Definition at line 288 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform2fv.

+ Here is the call graph for this function:

void ShaderProgram::setUniform2i ( const char *  _varname,
GLint  _v0,
GLint  _v1 
) const
noexcept

sets '_varname' as a int2

Parameters
_varname- name of the uniform variable
_v0- new value for the variable
_v1- new value for the variable

Definition at line 362 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform2i.

+ Here is the call graph for this function:

void ShaderProgram::setUniform2iv ( const char *  _varname,
size_t  _count,
const GLint _value 
) const
noexcept

sets '_varname' as a 2D int array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_value- new value for the variable

Definition at line 386 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform2iv.

+ Here is the call graph for this function:

void ShaderProgram::setUniform3f ( const char *  _varname,
float  _v0,
float  _v1,
float  _v2 
) const
noexcept

sets '_varname' as a float3

Parameters
_varname- name of the uniform variable
_v0- new value for the variable
_v1- new value for the variable
_v2- new value for the variable

Definition at line 248 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform3f.

+ Here is the call graph for this function:

void ShaderProgram::setUniform3fv ( const char *  _varname,
size_t  _count,
const float *  _value 
) const
noexcept

sets '_varname' as a 3D float array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_value- new _value for the variable

Definition at line 294 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform3fv.

+ Here is the call graph for this function:

void ShaderProgram::setUniform3i ( const char *  _varname,
GLint  _v0,
GLint  _v1,
GLint  _v2 
) const
noexcept

sets '_varname' as a int3

Parameters
_varname- name of the uniform variable
_v0- new value for the variable
_v1- new value for the variable
_v2- new value for the variable

Definition at line 368 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform3i.

+ Here is the call graph for this function:

void ShaderProgram::setUniform3iv ( const char *  _varname,
size_t  _count,
const GLint _value 
) const
noexcept

sets '_varname' as a 3D int array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_value- new value for the variable

Definition at line 391 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform3iv.

+ Here is the call graph for this function:

void ShaderProgram::setUniform4f ( const char *  _varname,
float  _v0,
float  _v1,
float  _v2,
float  _v3 
) const
noexcept

sets '_varname' as a float4

Parameters
_varname- name of the uniform variable
_v0- new value for the variable
_v1- new value for the variable
_v2- new value for the variable
_v3- new value for the variable

Definition at line 264 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform4f.

+ Here is the call graph for this function:

void ShaderProgram::setUniform4fv ( const char *  _varname,
size_t  _count,
const float *  _value 
) const
noexcept

sets '_varname' as a 4D float array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_value- new _value for the variable

Definition at line 300 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform4fv.

+ Here is the call graph for this function:

void ShaderProgram::setUniform4i ( const char *  _varname,
GLint  _v0,
GLint  _v1,
GLint  _v2,
GLint  _v3 
) const
noexcept

sets '_varname' as a float4

Parameters
_varname-name of the uniform variable
_v0- new value for the variable
_v1- new value for the variable
_v2- new value for the variable
_v3- new value for the variable

Definition at line 374 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform4i.

+ Here is the call graph for this function:

void ShaderProgram::setUniform4iv ( const char *  _varname,
size_t  _count,
const GLint _value 
) const
noexcept

sets '_varname' as a 4D int array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_value- new _value for the variable

Definition at line 397 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniform4iv.

+ Here is the call graph for this function:

void ShaderProgram::setUniformMatrix2fv ( const char *  _varname,
size_t  _count,
bool  _transpose,
const float *  _value 
) const
noexcept

sets '_varname' as a 2D matrix array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_transpose- if true will transpose the matrix values
_value- new value for the variable

Definition at line 404 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniformMatrix2fv.

+ Here is the call graph for this function:

void ShaderProgram::setUniformMatrix2x3fv ( const char *  _varname,
size_t  _count,
bool  _transpose,
const float *  _value 
) const
noexcept

sets '_varname' as a 2x3 matrix array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_transpose- if true will transpose the matrix values
_value- new value for the variable

Definition at line 451 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniformMatrix2x3fv.

+ Here is the call graph for this function:

void ShaderProgram::setUniformMatrix2x4fv ( const char *  _varname,
size_t  _count,
bool  _transpose,
const float *  _value 
) const
noexcept

sets '_varname' as a 2x4 matrix array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_transpose- if true will transpose the matrix values
_value- new value for the variable

Definition at line 457 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniformMatrix2x4fv.

+ Here is the call graph for this function:

void ShaderProgram::setUniformMatrix3fv ( const char *  _varname,
size_t  _count,
bool  _transpose,
const float *  _value 
) const
noexcept

sets '_varname' as a 3D matrix array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_transpose- if true will transpose the matrix values
_value- new value for the variable

Definition at line 410 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniformMatrix3fv.

+ Here is the call graph for this function:

void ShaderProgram::setUniformMatrix3x2fv ( const char *  _varname,
size_t  _count,
bool  _transpose,
const float *  _value 
) const
noexcept

sets '_varname' as a 3x2 matrix array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_transpose- if true will transpose the matrix values
_value- new value for the variable

Definition at line 463 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniformMatrix3x2fv.

+ Here is the call graph for this function:

void ShaderProgram::setUniformMatrix3x4fv ( const char *  _varname,
size_t  _count,
bool  _transpose,
const float *  _value 
) const
noexcept

sets '_varname' as a 3x4 matrix array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_transpose- if true will transpose the matrix values
_value- new value for the variable

Definition at line 470 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniformMatrix3x4fv.

+ Here is the call graph for this function:

void ShaderProgram::setUniformMatrix4fv ( const char *  _varname,
size_t  _count,
bool  _transpose,
const float *  _value 
) const
noexcept

sets '_varname' as a 4D matrix array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_transpose- if true will transpose the matrix values
_value- new value for the variable

Definition at line 429 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniformMatrix4fv.

+ Here is the call graph for this function:

void ShaderProgram::setUniformMatrix4x2fv ( const char *  _varname,
size_t  _count,
bool  _transpose,
const float *  _value 
) const
noexcept

sets '_varname' as a 4x2 matrix array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_transpose- if true will transpose the matrix values
_value- new value for the variable

Definition at line 476 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniformMatrix4x2fv.

+ Here is the call graph for this function:

void ShaderProgram::setUniformMatrix4x3fv ( const char *  _varname,
size_t  _count,
bool  _transpose,
const float *  _value 
) const
noexcept

sets '_varname' as a 4x3 matrix array

Parameters
_varname- name of the uniform variable
_count- num elements in the array
_transpose- if true will transpose the matrix values
_value- new value for the variable

Definition at line 483 of file ShaderProgram.cpp.

References getUniformLocation(), and glUniformMatrix4x3fv.

+ Here is the call graph for this function:

void ShaderProgram::unbind ( )
noexcept

method to unbind the current Program Object this will set the shader to be the glUseProgram(0) default value

Note
if we don't use this we will lose the m_active state values and we will not be able to check the current active state etc so use this once shader is finished.

Definition at line 61 of file ShaderProgram.cpp.

References glUseProgram, and m_active.

void ShaderProgram::use ( )
noexcept

use this Shader object as the current Active shader once this is set it is active until unbind us called

Definition at line 52 of file ShaderProgram.cpp.

References glUseProgram, m_active, and m_programID.

+ Here is the caller graph for this function:

Member Data Documentation

bool ngl::ShaderProgram::m_active
private

indicate if this program is the current active program

Definition at line 523 of file ShaderProgram.h.

std::unordered_map<std::string, GLuint > ngl::ShaderProgram::m_attribs
private

a list of attributes for this object, mapping name to ID number

Definition at line 502 of file ShaderProgram.h.

bool ngl::ShaderProgram::m_debugState
private

debug mode flag

Definition at line 494 of file ShaderProgram.h.

bool ngl::ShaderProgram::m_linked
private

flag to indicate if the current Program has been linked

Definition at line 482 of file ShaderProgram.h.

GLuint ngl::ShaderProgram::m_programID
private

the program id for this program object

Definition at line 490 of file ShaderProgram.h.

std::string ngl::ShaderProgram::m_programName
private

text name of the current program used in lookup and debugging

Definition at line 498 of file ShaderProgram.h.

std::unordered_map<std::string, uniformData> ngl::ShaderProgram::m_registeredUniforms
private

a list of uniforms for this object, mapping name to ID number must be added by the user using the registerUniform method

Definition at line 519 of file ShaderProgram.h.

std::vector<Shader *> ngl::ShaderProgram::m_shaders
private

a list of the shader objects attached to the program

Definition at line 486 of file ShaderProgram.h.


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