CUGL 2.3
Cornell University Game Library
|
#include <CUShader.h>
Public Member Functions | |
Shader () | |
~Shader () | |
virtual void | dispose () |
bool | init (const std::string vsource, std::string fsource) |
void | bind () |
void | unbind () |
bool | isReady () const |
bool | isBound () const |
const std::string | getVertSource () const |
const std::string | getFragSource () const |
GLuint | getProgram () const |
std::vector< std::string > | getAttributes () const |
GLint | getAttributeLocation (const std::string name) const |
GLint | getAttributeSize (const std::string name) const |
GLenum | getAttributeType (const std::string name) const |
GLint | getOutputLocation (const std::string name) const |
std::vector< std::string > | getUniforms () const |
GLint | getUniformLocation (const std::string name) const |
GLint | getUniformSize (const std::string name) const |
GLenum | getUniformType (const std::string name) const |
std::vector< std::string > | getSamplers () const |
GLint | getSamplerLocation (const std::string name) const |
void | setSampler (GLint pos, GLuint bpoint) |
void | setSampler (const std::string name, GLuint bpoint) |
void | setSampler (GLint pos, const std::shared_ptr< Texture > &texture) |
void | setSampler (const std::string name, const std::shared_ptr< Texture > &texture) |
GLuint | getSampler (GLint pos) const |
GLuint | getSampler (const std::string name) const |
std::vector< std::string > | getUniformBlocks () const |
std::vector< std::string > | getUniformsForBlock (GLint pos) const |
std::vector< std::string > | getUniformsForBlock (std::string name) const |
void | setUniformBlock (GLint pos, GLuint bpoint) |
void | setUniformBlock (const std::string name, GLuint bpoint) |
void | setUniformBlock (GLint pos, const std::shared_ptr< UniformBuffer > &buffer) |
void | setUniformBlock (const std::string name, const std::shared_ptr< UniformBuffer > &buffer) |
GLuint | getUniformBlock (GLint pos) const |
GLuint | getUniformBlock (const std::string name) const |
void | setUniformVec2 (GLint pos, const Vec2 vec) |
void | setUniformVec2 (const std::string name, const Vec2 vec) |
bool | getUniformVec2 (GLint pos, Vec2 &vec) const |
bool | getUniformVec2 (const std::string name, Vec2 &vec) const |
void | setUniformVec3 (GLint pos, const Vec3 vec) |
void | setUniformVec3 (const std::string name, const Vec3 vec) |
bool | getUniformVec3 (GLint pos, Vec3 &vec) const |
bool | getUniformVec3 (const std::string name, Vec3 &vec) const |
void | setUniformVec4 (GLint pos, const Vec4 vec) |
void | setUniformVec4 (const std::string name, const Vec4 vec) |
bool | getUniformVec4 (GLint pos, Vec4 &vec) const |
bool | getUniformVec4 (const std::string name, Vec4 &vec) const |
void | setUniformColor4 (GLint pos, const Color4 color) |
void | setUniformColor4 (const std::string name, const Color4 color) |
bool | getUniformColor4 (GLint pos, Color4 &color) const |
bool | getUniformColor4 (const std::string name, Color4 &color) const |
void | setUniformColor4f (GLint pos, const Color4f color) |
void | setUniformColor4f (const std::string name, const Color4f color) |
bool | getUniformColor4f (GLint pos, Color4f &color) const |
bool | getUniformColor4f (const std::string name, Color4f &color) const |
void | setUniformMat4 (GLint pos, const Mat4 &mat) |
void | setUniformMat4 (const std::string name, const Mat4 &mat) |
bool | getUniformMat4 (GLint pos, Mat4 &mat) const |
bool | getUniformMat4 (const std::string name, Mat4 &mat) const |
void | setUniformAffine2 (GLint pos, const Affine2 &mat) |
void | setUniformAffine2 (const std::string name, const Affine2 &mat) |
bool | getUniformAffine2 (GLint pos, Affine2 &mat) const |
bool | getUniformAffine2 (const std::string name, Affine2 &mat) const |
void | setUniformQuaternion (GLint pos, const Quaternion &quat) |
void | setUniformQuaternion (const std::string name, const Quaternion &quat) |
bool | getUniformQuaternion (GLint pos, Quaternion &quat) const |
bool | getUniformQuaternion (const std::string name, Quaternion &quat) const |
void | setUniform1f (GLint pos, GLfloat v0) |
void | setUniform1f (const std::string name, GLfloat v0) |
void | setUniform2f (GLint pos, GLfloat v0, GLfloat v1) |
void | setUniform2f (const std::string name, GLfloat v0, GLfloat v1) |
void | setUniform3f (GLint pos, GLfloat v0, GLfloat v1, GLfloat v2) |
void | setUniform3f (const std::string name, GLfloat v0, GLfloat v1, GLfloat v2) |
void | setUniform4f (GLint pos, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) |
void | setUniform4f (const std::string name, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) |
void | setUniform1i (GLint pos, GLint v0) |
void | setUniform1i (const std::string name, GLint v0) |
void | setUniform2i (GLint pos, GLint v0, GLint v1) |
void | setUniform2i (const std::string name, GLint v0, GLint v1) |
void | setUniform3i (GLint pos, GLint v0, GLint v1, GLint v2) |
void | setUniform3i (const std::string name, GLint v0, GLint v1, GLint v2) |
void | setUniform4i (GLint pos, GLint v0, GLint v1, GLint v2, GLint v3) |
void | setUniform4i (const std::string name, GLint v0, GLint v1, GLint v2, GLint v3) |
void | setUniform1ui (GLint pos, GLuint v0) |
void | setUniform1ui (const std::string name, GLuint v0) |
void | setUniform2ui (GLint pos, GLuint v0, GLuint v1) |
void | setUniform2ui (const std::string name, GLuint v0, GLuint v1) |
void | setUniform3ui (GLint pos, GLuint v0, GLuint v1, GLuint v2) |
void | setUniform3ui (const std::string name, GLuint v0, GLuint v1, GLuint v2) |
void | setUniform4ui (GLint pos, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
void | setUniform4ui (const std::string name, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
void | setUniform1fv (GLint pos, GLsizei count, const GLfloat *value) |
void | setUniform1fv (const std::string name, GLsizei count, const GLfloat *value) |
void | setUniform2fv (GLint pos, GLsizei count, const GLfloat *value) |
void | setUniform2fv (const std::string name, GLsizei count, const GLfloat *value) |
void | setUniform3fv (GLint pos, GLsizei count, const GLfloat *value) |
void | setUniform3fv (const std::string name, GLsizei count, const GLfloat *value) |
void | setUniform4fv (GLint pos, GLsizei count, const GLfloat *value) |
void | setUniform4fv (const std::string name, GLsizei count, const GLfloat *value) |
void | setUniform1iv (GLint pos, GLsizei count, const GLint *value) |
void | setUniform1iv (const std::string name, GLsizei count, const GLint *value) |
void | setUniform2iv (GLint pos, GLsizei count, const GLint *value) |
void | setUniform2iv (const std::string name, GLsizei count, const GLint *value) |
void | setUniform3iv (GLint pos, GLsizei count, const GLint *value) |
void | setUniform3iv (const std::string name, GLsizei count, const GLint *value) |
void | setUniform4iv (GLint pos, GLsizei count, const GLint *value) |
void | setUniform4iv (const std::string name, GLsizei count, const GLint *value) |
void | setUniform1uiv (GLint pos, GLsizei count, const GLuint *value) |
void | setUniform1uiv (const std::string name, GLsizei count, const GLuint *value) |
void | setUniform2uiv (GLint pos, GLsizei count, const GLuint *value) |
void | setUniform2uiv (const std::string name, GLsizei count, const GLuint *value) |
void | setUniform3uiv (GLint pos, GLsizei count, const GLuint *value) |
void | setUniform3uiv (const std::string name, GLsizei count, const GLuint *value) |
void | setUniform4uiv (GLint pos, GLsizei count, const GLuint *value) |
void | setUniform4uiv (const std::string name, GLsizei count, const GLuint *value) |
void | setUniformMatrix2fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix2fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix3fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix3fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix4fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix4fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix2x3fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix2x3fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix3x2fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix3x2fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix2x4fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix2x4fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix4x2fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix4x2fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix3x4fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix3x4fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix4x3fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
void | setUniformMatrix4x3fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false) |
bool | getUniformfv (GLint pos, GLsizei size, GLfloat *value) const |
bool | getUniformfv (const std::string name, GLsizei size, GLfloat *value) const |
bool | getUniformiv (GLint pos, GLsizei size, GLint *value) const |
bool | getUniformiv (const std::string name, GLsizei size, GLint *value) const |
bool | getUniformuiv (GLint pos, GLsizei size, GLuint *value) const |
bool | getUniformuiv (const std::string name, GLsizei size, GLuint *value) const |
Static Public Member Functions | |
static std::shared_ptr< Shader > | alloc (const std::string vsource, std::string fsource) |
Protected Attributes | |
GLuint | _program |
GLuint | _vertShader |
GLuint | _fragShader |
std::string | _vertSource |
std::string | _fragSource |
std::unordered_map< std::string, GLenum > | _attribtypes |
std::unordered_map< GLint, std::string > | _attribnames |
std::unordered_map< std::string, GLint > | _attribsizes |
std::unordered_map< std::string, GLenum > | _uniformtypes |
std::unordered_map< GLint, std::string > | _uniformnames |
std::unordered_map< std::string, GLint > | _uniformsizes |
std::unordered_map< GLint, std::string > | _uniblocknames |
std::unordered_map< std::string, GLint > | _uniblocksizes |
std::unordered_map< GLint, GLint > | _uniblockfields |
This class defines a GLSL shader.
This class compiles and links any well-defined GLSL shader. It also has methods for querying and binding the shader. The class is written to be agnostic about whether we are using OpenGL or OpenGLES.
However, a shader cannot be used by itself. To use a shader, it must first be attached to a VertexBuffer
. When using a shader, with a vertex buffer keep in mind the "performance hit" hierarchy. From our experiments, the cost of changing data in a rendering phase going from most expensive to cheapest is as follows:
By vertex stream we mean the act of loading data into a vertex buffer. Since the cost of swapping a vertex buffer is more expensive that reloading data into it, a vertex buffer should only be swapped when the format of the vertex data changes.
Uniforms tend to be fairly cheap. However, some uniforms are samplers and those are incredibly expensive to change. A sampler is a uniform that is bound to a texture bind point. Because of how textures are loaded, it is (much) cheaper to activate a texture to an existing bind point than it is to change the bind point used in the shader.
Even the most basic uniforms are by no means cheap. The best case graphics performance is when you can load the vertex buffer once and then call a single draw command for all of the vertices (the difference is an order of magnitude).
Therefore, any properties that space only a few vertices (e.g. quads) should be pushed into the vertex data itself. For example, it is faster to transform quads in the CPU than it is in the GPU.
Because of the limitations of OpenGLES, this class only supports vertex and fragment shaders – it does not support tesselation or geometry shaders.
Furthermore, keep in mind that Apple has deprecated OpenGL. MacOS devices are stuck at OpenGL 4.1 and iOS devices are stuck at OpenGLES 3.0. So it is not safe to use any shader more recent than version 140 on desktop/laptop and version 300 on mobile.
Another side effect of OpenGLES is that this class does not support explicit binding of multiple output locations (glBindFragDataLocation). If a shader has multiple output targets, then these must be explicitly managed inside the shader with the layout keyword. Otherwise, the output bind points from the appropriate query methods.
|
inline |
Creates an uninitialized shader with no source.
You must initialize the shader to add a source and compile it.
|
inline |
Deletes this shader, disposing all resources.
|
inlinestatic |
Returns a new shader with the given vertex and fragment source.
The shader will compile the vertex and fragment sources and link them together. When compilation is complete, the shader will be bound and active.
vsource | The source string for the vertex shader. |
fsource | The source string for the fragment shader. |
void cugl::Shader::bind | ( | ) |
Binds this shader, making it active.
Once bound, any OpenGL calls will then be sent to this shader. This call is reentrant, and may safely be called on an active shader.
|
virtual |
Deletes the OpenGL shader and resets all attributes.
You must reinitialize the shader to use it.
GLint cugl::Shader::getAttributeLocation | ( | const std::string | name | ) | const |
Returns the program offset of the given attribute
If name is not a valid attribute, this method returns -1.
name | The attribute variable name |
std::vector< std::string > cugl::Shader::getAttributes | ( | ) | const |
Returns a vector of all attribute variables in this shader
GLint cugl::Shader::getAttributeSize | ( | const std::string | name | ) | const |
Returns the size (in bytes) of the given attribute
If name is not a valid attribute, this method returns -1.
name | The attribute variable name |
GLenum cugl::Shader::getAttributeType | ( | const std::string | name | ) | const |
Returns the type of the given attribute
If name is not a valid attribute, this method returns GL_FALSE.
name | The attribute variable name |
|
inline |
Returns the source string for the fragment shader.
The string is empty if not defined.
GLint cugl::Shader::getOutputLocation | ( | const std::string | name | ) | const |
Returns the program offset of the given output variable.
An output variable is a variable in a fragment shader that writes to a texture. All shaders have at least one output variable. However, shaders can have more than one output variable, particularly when used in conjunction with a RenderTarget
. This method is helpful for getting the number and names of these variables for setting up a RenderTarget.
To explicit set the program offset of an output variable, the shader should use the layout keyword in GLSL. Because of compatibility issues with Apple products (iOS, MacOS), it is not possible to get much information about output variables other than their location.
If name is not a valid output variable, this method returns -1.
name | The output variable name |
|
inline |
Returns the OpenGL program associated with this shader.
This method will return 0 if the program is not initialized.
GLuint cugl::Shader::getSampler | ( | const std::string | name | ) | const |
Returns the texture bindpoint associated with the given sampler variable.
The shader does not track the actual texture associated with this bindpoint, only the bindpoint itself. It is up to the software developer to keep track of what texture is currently at that bindpoint.
name | The name of the sampler variable |
GLuint cugl::Shader::getSampler | ( | GLint | pos | ) | const |
Returns the texture bindpoint associated with the given sampler variable.
The shader does not track the actual texture associated with this bindpoint, only the bindpoint itself. It is up to the software developer to keep track of what texture is currently at that bindpoint.
pos | The location of the sampler in the shader |
GLint cugl::Shader::getSamplerLocation | ( | const std::string | name | ) | const |
Returns the program offset of the given sampler variable
A sampler is a variable attached to a texture. All samplers are also uniforms. Therefore this method has the same effect as the method getUniformLocation
.
If name is not a valid sampler, this method returns -1.
name | The sampler variable name |
std::vector< std::string > cugl::Shader::getSamplers | ( | ) | const |
Returns a vector of all samplers used by this shader
A sampler is a variable attached to a texture. All samplers are also uniforms. Therefore this vector is a subset of the names returned by getUniforms
.
bool cugl::Shader::getUniformAffine2 | ( | const std::string | name, |
Affine2 & | mat | ||
) | const |
Returns true if it can access the given uniform as an affine transform.
Affine transforms are read from a shader as a 3x3 matrix on homogenous coordinates. This method will only succeed if the shader is actively bound. It assumes that the shader variable is a mat3 (or larger).
name | The name of the uniform |
mat | The object to store the result |
bool cugl::Shader::getUniformAffine2 | ( | GLint | pos, |
Affine2 & | mat | ||
) | const |
Returns true if it can access the given uniform as an affine transform.
Affine transforms are read from a shader as a 3x3 matrix on homogenous coordinates. This method will only succeed if the shader is actively bound. It assumes that the shader variable is a mat3 (or larger).
pos | The location of the uniform in the shader |
mat | The object to store the result |
GLuint cugl::Shader::getUniformBlock | ( | const std::string | name | ) | const |
Returns the buffer bindpoint associated with the given uniform block.
The shader does not track the actual uniform buffer associated with this bindpoint, only the bindpoint itself. It is up to the software developer to keep track of what uniform buffer is currently at that bindpoint.
name | The name of the uniform block in the shader |
GLuint cugl::Shader::getUniformBlock | ( | GLint | pos | ) | const |
Returns the buffer bindpoint associated with the given uniform block.
The shader does not track the actual uniform buffer associated with this bindpoint, only the bindpoint itself. It is up to the software developer to keep track of what uniform buffer is currently at that bindpoint.
pos | The location of the uniform block in the shader |
std::vector< std::string > cugl::Shader::getUniformBlocks | ( | ) | const |
Returns a vector of all uniform blocks used by this shader
A uniform block is a variable attached to a uniform buffer. It is not the same as a normal uniform and cannot be treated as such. In this case the uniform values are set in the UniformBuffer
object and not the shader.
bool cugl::Shader::getUniformColor4 | ( | const std::string | name, |
Color4 & | color | ||
) | const |
Returns true if it can access the given uniform as a color.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a vec4 (or larger).
name | The name of the uniform |
color | The object to store the result |
bool cugl::Shader::getUniformColor4 | ( | GLint | pos, |
Color4 & | color | ||
) | const |
Returns true if it can access the given uniform as a color.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a vec4 (or larger).
pos | The location of the uniform in the shader |
color | The object to store the result |
bool cugl::Shader::getUniformColor4f | ( | const std::string | name, |
Color4f & | color | ||
) | const |
Returns true if it can access the given uniform as a color.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a vec4 (or larger).
name | The name of the uniform |
color | The object to store the result |
bool cugl::Shader::getUniformColor4f | ( | GLint | pos, |
Color4f & | color | ||
) | const |
Returns true if it can access the given uniform as a color.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a vec4 (or larger).
pos | The location of the uniform in the shader |
color | The object to store the result |
bool cugl::Shader::getUniformfv | ( | const std::string | name, |
GLsizei | size, | ||
GLfloat * | value | ||
) | const |
Gets the given uniform as an array of float values
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
size | The available size of the value array |
value | The array to receive the values |
bool cugl::Shader::getUniformfv | ( | GLint | pos, |
GLsizei | size, | ||
GLfloat * | value | ||
) | const |
Gets the given uniform as an array of float values
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
size | The available size of the value array |
value | The array to receive the values |
bool cugl::Shader::getUniformiv | ( | const std::string | name, |
GLsizei | size, | ||
GLint * | value | ||
) | const |
Gets the given uniform as an array of integer values
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
size | The available size of the value array |
value | The array to receive the values |
bool cugl::Shader::getUniformiv | ( | GLint | pos, |
GLsizei | size, | ||
GLint * | value | ||
) | const |
Gets the given uniform as an array of integer values
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
size | The available size of the value array |
value | The array to receive the values |
GLint cugl::Shader::getUniformLocation | ( | const std::string | name | ) | const |
Returns the program offset of the given uniform
If name is not a valid uniform, this method returns -1.
name | The uniform variable name |
bool cugl::Shader::getUniformMat4 | ( | const std::string | name, |
Mat4 & | mat | ||
) | const |
Returns true if it can access the given uniform as a matrix.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a mat4 (or larger).
name | The name of the uniform |
mat | The object to store the result |
bool cugl::Shader::getUniformMat4 | ( | GLint | pos, |
Mat4 & | mat | ||
) | const |
Returns true if it can access the given uniform as a matrix.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a mat4 (or larger).
pos | The location of the uniform in the shader |
mat | The object to store the result |
bool cugl::Shader::getUniformQuaternion | ( | const std::string | name, |
Quaternion & | quat | ||
) | const |
Returns true if it can access the given uniform as a quaternion.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a vec4 (or larger).
name | The name of the uniform |
quat | The quaternion to store the result |
bool cugl::Shader::getUniformQuaternion | ( | GLint | pos, |
Quaternion & | quat | ||
) | const |
Returns true if it can access the given uniform as a quaternion.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a vec4 (or larger).
pos | The location of the uniform in the shader |
quat | The quaternion to store the result |
std::vector< std::string > cugl::Shader::getUniforms | ( | ) | const |
Returns a vector of all uniform variables in this shader
std::vector< std::string > cugl::Shader::getUniformsForBlock | ( | GLint | pos | ) | const |
Returns a vector of all uniforms for the given block.
A uniform block is a variable attached to a uniform buffer. It is not the same as a normal uniform and cannot be treated as such. In this case the uniform values are set in the UniformBuffer
object and not the shader.
This method allows us to verify that at UniformBuffer
object properly matches this shader.
pos | The location of the uniform block in the shader |
std::vector< std::string > cugl::Shader::getUniformsForBlock | ( | std::string | name | ) | const |
Returns a vector of all uniforms for the given block.
A uniform block is a variable attached to a uniform buffer. It is not the same as a normal uniform and cannot be treated as such. In this case the uniform values are set in the UniformBuffer
object and not the shader.
This method allows us to verify that at UniformBuffer
object properly matches this shader.
name | The name of the uniform block in the shader |
GLint cugl::Shader::getUniformSize | ( | const std::string | name | ) | const |
Returns the size (in bytes) of the given uniform
If name is not a valid uniform, this method returns -1.
name | The uniform variable name |
GLenum cugl::Shader::getUniformType | ( | const std::string | name | ) | const |
Returns the type of the given uniform
If name is not a valid uniform, this method returns GL_FALSE.
name | The uniform variable name |
bool cugl::Shader::getUniformuiv | ( | const std::string | name, |
GLsizei | size, | ||
GLuint * | value | ||
) | const |
Gets the given uniform as an array of unsigned integer values
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
size | The available size of the value array |
value | The array to receive the values |
bool cugl::Shader::getUniformuiv | ( | GLint | pos, |
GLsizei | size, | ||
GLuint * | value | ||
) | const |
Gets the given uniform as an array of unsigned integer values
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
size | The available size of the value array |
value | The array to receive the values |
bool cugl::Shader::getUniformVec2 | ( | const std::string | name, |
Vec2 & | vec | ||
) | const |
Returns true if it can access the given uniform as a vector.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a vec2 (or larger).
name | The name of the uniform |
vec | The vector to store the result |
bool cugl::Shader::getUniformVec2 | ( | GLint | pos, |
Vec2 & | vec | ||
) | const |
Returns true if it can access the given uniform as a vector.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a vec2 (or larger).
pos | The location of the uniform in the shader |
vec | The vector to store the result |
bool cugl::Shader::getUniformVec3 | ( | const std::string | name, |
Vec3 & | vec | ||
) | const |
Returns true if it can access the given uniform as a vector.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a vec3 (or larger).
name | The name of the uniform |
vec | The vector to store the result |
bool cugl::Shader::getUniformVec3 | ( | GLint | pos, |
Vec3 & | vec | ||
) | const |
Returns true if it can access the given uniform as a vector.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a vec3 (or larger).
pos | The location of the uniform in the shader |
vec | The vector to store the result |
bool cugl::Shader::getUniformVec4 | ( | const std::string | name, |
Vec4 & | vec | ||
) | const |
Returns true if it can access the given uniform as a vector.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a vec4 (or larger).
name | The name of the uniform |
vec | The vector to store the result |
bool cugl::Shader::getUniformVec4 | ( | GLint | pos, |
Vec4 & | vec | ||
) | const |
Returns true if it can access the given uniform as a vector.
This method will only succeed if the shader is actively bound. It assumes that the shader variable is a vec4 (or larger).
pos | The location of the uniform in the shader |
vec | The vector to store the result |
|
inline |
Returns the source string for the vertex shader.
The string is empty if not defined.
bool cugl::Shader::init | ( | const std::string | vsource, |
std::string | fsource | ||
) |
Initializes this shader with the given vertex and fragment source.
The shader will compile the vertex and fragment sources and link them together. When compilation is complete, the shader will be bound and active.
vsource | The source string for the vertex shader. |
fsource | The source string for the fragment shader. |
bool cugl::Shader::isBound | ( | ) | const |
Returns true if this shader is currently bound.
Any OpenGL calls will be sent to this shader only if it is bound.
|
inline |
Returns true if this shader has been compiled and is ready for use.
void cugl::Shader::setSampler | ( | const std::string | name, |
const std::shared_ptr< Texture > & | texture | ||
) |
Sets the given sampler variable to the bindpoint of the given texture.
A sampler is a variable attached to a texture. All samplers are also uniforms. Therefore this method has the same effect as the method setUniform1ui
.
This method will bind the sampler to the current bindpoint of the texture. The shader will not be aware if the texture changes its bindpoint in the future.
This method will only succeed if the shader is actively bound.
name | The name of the sampler variable |
texture | The texture to initialize the bindpoint |
void cugl::Shader::setSampler | ( | const std::string | name, |
GLuint | bpoint | ||
) |
Sets the given sampler variable to a texture bindpoint.
A sampler is a variable attached to a texture. All samplers are also uniforms. Therefore this method has the same effect as the method setUniform1ui
.
This method will only succeed if the shader is actively bound.
Note that changing this value is causes a significant performance hit to a shader. Whenever possible, it is better to keep the bindpoint the same while binding a different texture to the same point.
name | The name of the sampler variable |
bpoint | The bindpoint for the sampler |
void cugl::Shader::setSampler | ( | GLint | pos, |
const std::shared_ptr< Texture > & | texture | ||
) |
Sets the given sampler variable to the bindpoint of the given texture.
A sampler is a variable attached to a texture. All samplers are also uniforms. Therefore this method has the same effect as the method setUniform1ui
.
This method will only succeed if the shader is actively bound.
pos | The location of the sampler in the shader |
texture | The texture to initialize the bindpoint |
void cugl::Shader::setSampler | ( | GLint | pos, |
GLuint | bpoint | ||
) |
Sets the given sampler variable to a texture bindpoint.
A sampler is a variable attached to a texture. All samplers are also uniforms. Therefore this method has the same effect as the method setUniform1ui
.
This method will only succeed if the shader is actively bound.
Note that changing this value is causes a significant performance hit to a shader. Whenever possible, it is better to keep the bindpoint the same while binding a different texture to the same point.
pos | The location of the sampler in the shader |
bpoint | The bindpoint for the sampler |
void cugl::Shader::setUniform1f | ( | const std::string | name, |
GLfloat | v0 | ||
) |
Sets the given uniform to a single float value.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
v0 | The value for the uniform |
void cugl::Shader::setUniform1f | ( | GLint | pos, |
GLfloat | v0 | ||
) |
Sets the given uniform to a single float value.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
v0 | The value for the uniform |
void cugl::Shader::setUniform1fv | ( | const std::string | name, |
GLsizei | count, | ||
const GLfloat * | value | ||
) |
Sets the given uniform to an array of 1-element floats.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of floats |
void cugl::Shader::setUniform1fv | ( | GLint | pos, |
GLsizei | count, | ||
const GLfloat * | value | ||
) |
Sets the given uniform to an array of 1-element floats.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of floats |
void cugl::Shader::setUniform1i | ( | const std::string | name, |
GLint | v0 | ||
) |
Sets the given uniform to a single int value.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
v0 | The value for the uniform |
void cugl::Shader::setUniform1i | ( | GLint | pos, |
GLint | v0 | ||
) |
Sets the given uniform to a single int value.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
v0 | The value for the uniform |
void cugl::Shader::setUniform1iv | ( | const std::string | name, |
GLsizei | count, | ||
const GLint * | value | ||
) |
Sets the given uniform to an array of 1-element ints.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of ints |
void cugl::Shader::setUniform1iv | ( | GLint | pos, |
GLsizei | count, | ||
const GLint * | value | ||
) |
Sets the given uniform to an array of 1-element ints.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of ints |
void cugl::Shader::setUniform1ui | ( | const std::string | name, |
GLuint | v0 | ||
) |
Sets the given uniform to a single unsigned value.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
v0 | The value for the uniform |
void cugl::Shader::setUniform1ui | ( | GLint | pos, |
GLuint | v0 | ||
) |
Sets the given uniform to a single unsigned value.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
v0 | The value for the uniform |
void cugl::Shader::setUniform1uiv | ( | const std::string | name, |
GLsizei | count, | ||
const GLuint * | value | ||
) |
Sets the given uniform to an array of 1-element unsigned ints.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of unsigned ints |
void cugl::Shader::setUniform1uiv | ( | GLint | pos, |
GLsizei | count, | ||
const GLuint * | value | ||
) |
Sets the given uniform to an array of 1-element unsigned ints.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of unsigned ints |
void cugl::Shader::setUniform2f | ( | const std::string | name, |
GLfloat | v0, | ||
GLfloat | v1 | ||
) |
Sets the given uniform to a pair of float values.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
void cugl::Shader::setUniform2f | ( | GLint | pos, |
GLfloat | v0, | ||
GLfloat | v1 | ||
) |
Sets the given uniform to a pair of float values.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
void cugl::Shader::setUniform2fv | ( | const std::string | name, |
GLsizei | count, | ||
const GLfloat * | value | ||
) |
Sets the given uniform to an array of 2-element floats.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of floats |
void cugl::Shader::setUniform2fv | ( | GLint | pos, |
GLsizei | count, | ||
const GLfloat * | value | ||
) |
Sets the given uniform to an array of 2-element floats.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of floats |
void cugl::Shader::setUniform2i | ( | const std::string | name, |
GLint | v0, | ||
GLint | v1 | ||
) |
Sets the given uniform to a pair of int values.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
void cugl::Shader::setUniform2i | ( | GLint | pos, |
GLint | v0, | ||
GLint | v1 | ||
) |
Sets the given uniform to a pair of int values.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
void cugl::Shader::setUniform2iv | ( | const std::string | name, |
GLsizei | count, | ||
const GLint * | value | ||
) |
Sets the given uniform to an array of 2-element ints.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of ints |
void cugl::Shader::setUniform2iv | ( | GLint | pos, |
GLsizei | count, | ||
const GLint * | value | ||
) |
Sets the given uniform to an array of 2-element ints.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of ints |
void cugl::Shader::setUniform2ui | ( | const std::string | name, |
GLuint | v0, | ||
GLuint | v1 | ||
) |
Sets the given uniform to a pair of unsigned values.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
void cugl::Shader::setUniform2ui | ( | GLint | pos, |
GLuint | v0, | ||
GLuint | v1 | ||
) |
Sets the given uniform to a pair of unsigned values.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
void cugl::Shader::setUniform2uiv | ( | const std::string | name, |
GLsizei | count, | ||
const GLuint * | value | ||
) |
Sets the given uniform to an array of 2-element unsigned ints.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of unsigned ints |
void cugl::Shader::setUniform2uiv | ( | GLint | pos, |
GLsizei | count, | ||
const GLuint * | value | ||
) |
Sets the given uniform to an array of 2-element unsigned ints.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of unsigned ints |
void cugl::Shader::setUniform3f | ( | const std::string | name, |
GLfloat | v0, | ||
GLfloat | v1, | ||
GLfloat | v2 | ||
) |
Sets the given uniform to a trio of float values.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
v2 | The third value for the uniform |
void cugl::Shader::setUniform3f | ( | GLint | pos, |
GLfloat | v0, | ||
GLfloat | v1, | ||
GLfloat | v2 | ||
) |
Sets the given uniform to a trio of float values.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
v2 | The third value for the uniform |
void cugl::Shader::setUniform3fv | ( | const std::string | name, |
GLsizei | count, | ||
const GLfloat * | value | ||
) |
Sets the given uniform to an array of 3-element floats.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of floats |
void cugl::Shader::setUniform3fv | ( | GLint | pos, |
GLsizei | count, | ||
const GLfloat * | value | ||
) |
Sets the given uniform to an array of 3-element floats.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of floats |
void cugl::Shader::setUniform3i | ( | const std::string | name, |
GLint | v0, | ||
GLint | v1, | ||
GLint | v2 | ||
) |
Sets the given uniform to a trio of int values.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
v2 | The third value for the uniform |
void cugl::Shader::setUniform3i | ( | GLint | pos, |
GLint | v0, | ||
GLint | v1, | ||
GLint | v2 | ||
) |
Sets the given uniform to a trio of int values.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
v2 | The third value for the uniform |
void cugl::Shader::setUniform3iv | ( | const std::string | name, |
GLsizei | count, | ||
const GLint * | value | ||
) |
Sets the given uniform to an array of 3-element ints.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of ints |
void cugl::Shader::setUniform3iv | ( | GLint | pos, |
GLsizei | count, | ||
const GLint * | value | ||
) |
Sets the given uniform to an array of 3-element ints.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of ints |
void cugl::Shader::setUniform3ui | ( | const std::string | name, |
GLuint | v0, | ||
GLuint | v1, | ||
GLuint | v2 | ||
) |
Sets the given uniform to a trio of unsigned values.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
v2 | The third value for the uniform |
void cugl::Shader::setUniform3ui | ( | GLint | pos, |
GLuint | v0, | ||
GLuint | v1, | ||
GLuint | v2 | ||
) |
Sets the given uniform to a trio of unsigned values.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
v2 | The third value for the uniform |
void cugl::Shader::setUniform3uiv | ( | const std::string | name, |
GLsizei | count, | ||
const GLuint * | value | ||
) |
Sets the given uniform to an array of 3-element unsigned ints.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of unsigned ints |
void cugl::Shader::setUniform3uiv | ( | GLint | pos, |
GLsizei | count, | ||
const GLuint * | value | ||
) |
Sets the given uniform to an array of 3-element unsigned ints.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of unsigned ints |
void cugl::Shader::setUniform4f | ( | const std::string | name, |
GLfloat | v0, | ||
GLfloat | v1, | ||
GLfloat | v2, | ||
GLfloat | v3 | ||
) |
Sets the given uniform to a quartet of float values.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
v2 | The third value for the uniform |
v3 | The fourth value for the uniform |
void cugl::Shader::setUniform4f | ( | GLint | pos, |
GLfloat | v0, | ||
GLfloat | v1, | ||
GLfloat | v2, | ||
GLfloat | v3 | ||
) |
Sets the given uniform to a quartet of float values.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
v2 | The third value for the uniform |
v3 | The fourth value for the uniform |
void cugl::Shader::setUniform4fv | ( | const std::string | name, |
GLsizei | count, | ||
const GLfloat * | value | ||
) |
Sets the given uniform to an array of 4-element floats.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of floats |
void cugl::Shader::setUniform4fv | ( | GLint | pos, |
GLsizei | count, | ||
const GLfloat * | value | ||
) |
Sets the given uniform to an array of 4-element floats.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of floats |
void cugl::Shader::setUniform4i | ( | const std::string | name, |
GLint | v0, | ||
GLint | v1, | ||
GLint | v2, | ||
GLint | v3 | ||
) |
Sets the given uniform to a quartet of int values.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
v2 | The third value for the uniform |
v3 | The fourth value for the uniform |
void cugl::Shader::setUniform4i | ( | GLint | pos, |
GLint | v0, | ||
GLint | v1, | ||
GLint | v2, | ||
GLint | v3 | ||
) |
Sets the given uniform to a quartet of int values.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
v2 | The third value for the uniform |
v3 | The fourth value for the uniform |
void cugl::Shader::setUniform4iv | ( | const std::string | name, |
GLsizei | count, | ||
const GLint * | value | ||
) |
Sets the given uniform to an array of 4-element ints.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of ints |
void cugl::Shader::setUniform4iv | ( | GLint | pos, |
GLsizei | count, | ||
const GLint * | value | ||
) |
Sets the given uniform to an array of 4-element ints.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of ints |
void cugl::Shader::setUniform4ui | ( | const std::string | name, |
GLuint | v0, | ||
GLuint | v1, | ||
GLuint | v2, | ||
GLuint | v3 | ||
) |
Sets the given uniform to a quartet of unsigned values.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
v2 | The third value for the uniform |
v3 | The fourth value for the uniform |
void cugl::Shader::setUniform4ui | ( | GLint | pos, |
GLuint | v0, | ||
GLuint | v1, | ||
GLuint | v2, | ||
GLuint | v3 | ||
) |
Sets the given uniform to a quartet of unsigned values.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
v0 | The first value for the uniform |
v1 | The second value for the uniform |
v2 | The third value for the uniform |
v3 | The fourth value for the uniform |
void cugl::Shader::setUniform4uiv | ( | const std::string | name, |
GLsizei | count, | ||
const GLuint * | value | ||
) |
Sets the given uniform to an array of 4-element unsigned ints.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of unsigned ints |
void cugl::Shader::setUniform4uiv | ( | GLint | pos, |
GLsizei | count, | ||
const GLuint * | value | ||
) |
Sets the given uniform to an array of 4-element unsigned ints.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of unsigned ints |
void cugl::Shader::setUniformAffine2 | ( | const std::string | name, |
const Affine2 & | mat | ||
) |
Sets the given uniform to an affine transform.
Affine transforms are passed to a shader as a 3x3 matrix on homogenous coordinates.
This method will only succeed if the shader is actively bound.
name | The name of the uniform |
mat | The value for the uniform |
void cugl::Shader::setUniformAffine2 | ( | GLint | pos, |
const Affine2 & | mat | ||
) |
Sets the given uniform to an affine transform.
Affine transforms are passed to a shader as a 3x3 matrix on homogenous coordinates.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
mat | The value for the uniform |
void cugl::Shader::setUniformBlock | ( | const std::string | name, |
const std::shared_ptr< UniformBuffer > & | buffer | ||
) |
Sets the given uniform block variable to the bindpoint of the given uniform buffer.
A uniform block is a variable attached to a uniform buffer. It is not the same as a normal uniform and cannot be treated as such. In this case the uniform values are set in the UniformBuffer
object and not the shader.
This method will bind the uniform buffer to the current bindpoint of the block object. The shader will not be aware if the buffer object changes its bindpoint in the future. However, it will verify whether the buffer object has uniform variables matching this shader.
This method will only succeed if the shader is actively bound.
name | The name of the uniform block in the shader |
buffer | The buffer to bind to this uniform block |
void cugl::Shader::setUniformBlock | ( | const std::string | name, |
GLuint | bpoint | ||
) |
Sets the given uniform block variable to a uniform buffer bindpoint.
A uniform block is a variable attached to a uniform buffer. It is not the same as a normal uniform and cannot be treated as such. In this case the uniform values are set in the UniformBuffer
object and not the shader.
This method will only succeed if the shader is actively bound.
name | The name of the uniform block in the shader |
bpoint | The bindpoint for the uniform block |
void cugl::Shader::setUniformBlock | ( | GLint | pos, |
const std::shared_ptr< UniformBuffer > & | buffer | ||
) |
Sets the given uniform block variable to the bindpoint of the given uniform buffer.
A uniform block is a variable attached to a uniform buffer. It is not the same as a normal uniform and cannot be treated as such. In this case the uniform values are set in the UniformBuffer
object and not the shader.
This method will bind the uniform buffer to the current bindpoint of the block object. The shader will not be aware if the buffer object changes its bindpoint in the future. However, it will verify whether the buffer object has uniform variables matching this shader.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform block in the shader |
buffer | The buffer to bind to this uniform block |
void cugl::Shader::setUniformBlock | ( | GLint | pos, |
GLuint | bpoint | ||
) |
Sets the given uniform block variable to a uniform buffer bindpoint.
A uniform block is a variable attached to a uniform buffer. It is not the same as a normal uniform and cannot be treated as such. In this case the uniform values are set in the UniformBuffer
object and not the shader.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform block in the shader |
bpoint | The bindpoint for the uniform block |
void cugl::Shader::setUniformColor4 | ( | const std::string | name, |
const Color4 | color | ||
) |
Sets the given uniform to a color value.
This method will only succeed if the shader is actively bound.
name | The name of the uniform |
color | The value for the uniform |
void cugl::Shader::setUniformColor4 | ( | GLint | pos, |
const Color4 | color | ||
) |
Sets the given uniform to a color value.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
color | The value for the uniform |
void cugl::Shader::setUniformColor4f | ( | const std::string | name, |
const Color4f | color | ||
) |
Sets the given uniform to a color value.
This method will only succeed if the shader is actively bound.
name | The name of the uniform |
color | The value for the uniform |
void cugl::Shader::setUniformColor4f | ( | GLint | pos, |
const Color4f | color | ||
) |
Sets the given uniform to a color value.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
color | The value for the uniform |
void cugl::Shader::setUniformMat4 | ( | const std::string | name, |
const Mat4 & | mat | ||
) |
Sets the given uniform to a matrix value
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
mat | The value for the uniform |
void cugl::Shader::setUniformMat4 | ( | GLint | pos, |
const Mat4 & | mat | ||
) |
Sets the given uniform to a matrix value.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
mat | The value for the uniform |
void cugl::Shader::setUniformMatrix2fv | ( | const std::string | name, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 2x2 matrices.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix2fv | ( | GLint | pos, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 2x2 matrices.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix2x3fv | ( | const std::string | name, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 2x3 matrices.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix2x3fv | ( | GLint | pos, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 2x3 matrices.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix2x4fv | ( | const std::string | name, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 2x4 matrices.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix2x4fv | ( | GLint | pos, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 2x4 matrices.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix3fv | ( | const std::string | name, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 3x3 matrices.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix3fv | ( | GLint | pos, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 3x3 matrices.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix3x2fv | ( | const std::string | name, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 3x2 matrices.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix3x2fv | ( | GLint | pos, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 3x2 matrices.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix3x4fv | ( | const std::string | name, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 3x4 matrices.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix3x4fv | ( | GLint | pos, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 3x4 matrices.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix4fv | ( | const std::string | name, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 4x4 matrices.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix4fv | ( | GLint | pos, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 4x4 matrices.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix4x2fv | ( | const std::string | name, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 4x2 matrices.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix4x2fv | ( | GLint | pos, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 4x2 matrices.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix4x3fv | ( | const std::string | name, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 4x3 matrices.
This method will only succeed if the shader is actively bound. It will silently fail (with no error) if name is does not refer to a valid uniform.
name | The name of the uniform |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformMatrix4x3fv | ( | GLint | pos, |
GLsizei | count, | ||
const GLfloat * | value, | ||
GLboolean | tpose = false |
||
) |
Sets the given uniform to an array 4x3 matrices.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
count | The number of elements in the array |
value | The array of matrices |
tpose | Whether to transpose the matrices |
void cugl::Shader::setUniformQuaternion | ( | const std::string | name, |
const Quaternion & | quat | ||
) |
Sets the given uniform to a quaternion.
This method will only succeed if the shader is actively bound.
name | The name of the uniform |
quat | The value for the uniform |
void cugl::Shader::setUniformQuaternion | ( | GLint | pos, |
const Quaternion & | quat | ||
) |
Sets the given uniform to a quaternion.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
quat | The value for the uniform |
void cugl::Shader::setUniformVec2 | ( | const std::string | name, |
const Vec2 | vec | ||
) |
Sets the given uniform to a vector value.
This method will only succeed if the shader is actively bound.
name | The name of the uniform |
vec | The value for the uniform |
void cugl::Shader::setUniformVec2 | ( | GLint | pos, |
const Vec2 | vec | ||
) |
Sets the given uniform to a vector value.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
vec | The value for the uniform |
void cugl::Shader::setUniformVec3 | ( | const std::string | name, |
const Vec3 | vec | ||
) |
Sets the given uniform to a vector value.
This method will only succeed if the shader is actively bound.
name | The name of the uniform |
vec | The value for the uniform |
void cugl::Shader::setUniformVec3 | ( | GLint | pos, |
const Vec3 | vec | ||
) |
Sets the given uniform to a vector value.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
vec | The value for the uniform |
void cugl::Shader::setUniformVec4 | ( | const std::string | name, |
const Vec4 | vec | ||
) |
Sets the given uniform to a vector value.
This method will only succeed if the shader is actively bound.
name | The name of the uniform |
vec | The value for the uniform |
void cugl::Shader::setUniformVec4 | ( | GLint | pos, |
const Vec4 | vec | ||
) |
Sets the given uniform to a vector value.
This method will only succeed if the shader is actively bound.
pos | The location of the uniform in the shader |
vec | The value for the uniform |
void cugl::Shader::unbind | ( | ) |
Unbinds this shader, making it no longer active.
Once unbound, OpenGL calls will no longer be sent to this shader.
|
protected |
The attribute variable names of this shader
|
protected |
The attribute locations of this shader
|
protected |
The attribute locations of this shader
|
protected |
The OpenGL fragment shader for this shader
|
protected |
The source string for the fragment shader
|
protected |
The OpenGL program for this shader
|
protected |
Mappings of uniforms to a uniform block
|
protected |
The uniform block variable names for this shader
|
protected |
The uniform block locations of this shader
|
protected |
The uniform variable names for this shader (includes samplers)
|
protected |
The uniform locations of this shader (includes samplers)
|
protected |
The uniform locations of this shader
|
protected |
The OpenGL vertex shader for this shader
|
protected |
The source string for the vertex shader