MyGL
All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
ShaderProgram Class Reference

Class for creating shader programs. More...

#include <ShaderProgram.hpp>

Public Member Functions

MYGL_EXPORT ShaderProgram () noexcept=default
 Creates an empty shader program, it is not usable as is.
 
template<typename... Shaders>
void addShaders (Shader shader, Shaders... shaders)
 Adds one ore more shaders to this program.
 
MYGL_EXPORT bool link ()
 Links all the added shaders to create a usable shader program.
 
MYGL_EXPORT bool isUsable () const noexcept
 Tells wether the shader program is usable.
 
MYGL_EXPORT void use () const
 Sets this program to be the active shader program.
 
Uniform related functions

These functions are used to modify a shader's uniform value, they take the uniform's name and the new value as parameters.

Note
You can use these functions to set boolean uniforms, as integral types are implicitely converted to bool in glsl (0 or 0.0 is converted to false, anything else is converted to true)
Parameters
nameThe uniform's name
valueThe new value to assign to the uniform
v0,value(s)The new values to assign
MYGL_EXPORT void setMat4 (const std::string &name, const glm::mat4 &value) const
 Sets the value of a 4x4 matrix uniform.
 
Int uniform functions
MYGL_EXPORT void setInt (const std::string &name, const glm::ivec1 &value) const
 Sets the value of an integer uniform.
 
MYGL_EXPORT void setInt (const std::string &name, const glm::ivec2 &value) const
 Sets the value of a 2 component integer vector (ivec2) uniform.
 
MYGL_EXPORT void setInt (const std::string &name, const glm::ivec3 &value) const
 Sets the value of a 3 component integer vector (ivec3) uniform.
 
MYGL_EXPORT void setInt (const std::string &name, const glm::ivec4 &value) const
 Sets the value of a 4 component integer vector (ivec4) uniform.
 
template<typename... Args>
void setInt (const std::string &name, int v0, Args... values) const
 Sets the value of an integer uniform using multiple values.
 
Unsigned int uniform functions
MYGL_EXPORT void setUInt (const std::string &name, const glm::uvec1 &value) const
 Sets the value of an unsigned integer uniform.
 
MYGL_EXPORT void setUInt (const std::string &name, const glm::uvec2 &value) const
 Sets the value of a 2 component unsigned integer vector (uvec2) uniform.
 
MYGL_EXPORT void setUInt (const std::string &name, const glm::uvec3 &value) const
 Sets the value of a 3 component unsigned integer vector (uvec3) uniform.
 
MYGL_EXPORT void setUInt (const std::string &name, const glm::uvec4 &value) const
 Sets the value of a 4 component unsigned integer vector (uvec4) uniform.
 
template<typename... Args>
void setUInt (const std::string &name, unsigned int v0, Args... values) const
 Sets the value of an unsigned integer uniform using multiple values.
 
Float uniform functions
MYGL_EXPORT void setFloat (const std::string &name, const glm::vec1 &value) const
 Sets the value of a float uniform.
 
MYGL_EXPORT void setFloat (const std::string &name, const glm::vec2 &value) const
 Sets the value of a 2 component float vector (vec2) uniform.
 
MYGL_EXPORT void setFloat (const std::string &name, const glm::vec3 &value) const
 Sets the value of a 3 component float vector (vec3) uniform.
 
MYGL_EXPORT void setFloat (const std::string &name, const glm::vec4 &value) const
 Sets the value of a 4 component float vector (vec4) uniform.
 
template<typename... Args>
void setFloat (const std::string &name, float v0, Args... values) const
 Sets the value of a float uniform using multiple values.
 

Friends

MYGL_EXPORT friend bool operator== (const ShaderProgram &lhs, const ShaderProgram &rhs) noexcept
 
MYGL_EXPORT friend bool operator!= (const ShaderProgram &lhs, const ShaderProgram &rhs) noexcept
 

Detailed Description

Class for creating shader programs.

Definition at line 19 of file ShaderProgram.hpp.

Member Function Documentation

◆ addShaders()

template<typename... Shaders>
void addShaders ( Shader shader,
Shaders... shaders )
inline

Adds one ore more shaders to this program.

Parameters
shader,shadersThe shaders to add to this program

Definition at line 178 of file ShaderProgram.hpp.

◆ isUsable()

MYGL_EXPORT bool isUsable ( ) const
noexcept

Tells wether the shader program is usable.

Returns
true if the program can be used

◆ link()

MYGL_EXPORT bool link ( )

Links all the added shaders to create a usable shader program.

Returns
True if the linking was successful, false otherwise

◆ setFloat()

template<typename... Args>
void setFloat ( const std::string & name,
float v0,
Args... values ) const
inline

Sets the value of a float uniform using multiple values.

Parameters
nameThe uniform's name
v0The first value
valuesThe remaining values (up to 3)

Definition at line 208 of file ShaderProgram.hpp.

◆ setInt()

template<typename... Args>
void setInt ( const std::string & name,
int v0,
Args... values ) const
inline

Sets the value of an integer uniform using multiple values.

Parameters
nameThe uniform's name
v0The first value
valuesThe remaining values (up to 3)

Definition at line 198 of file ShaderProgram.hpp.

◆ setUInt()

template<typename... Args>
void setUInt ( const std::string & name,
unsigned int v0,
Args... values ) const
inline

Sets the value of an unsigned integer uniform using multiple values.

Parameters
nameThe uniform's name
v0The first value
valuesThe remaining values (up to 3)

Definition at line 203 of file ShaderProgram.hpp.


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