#include <Shader.hpp>
A shader program is a set of shader (for instance vertex shader + pixel shader) defining the rendering pipeline. More...
A shader program is a set of shader (for instance vertex shader + pixel shader) defining the rendering pipeline.
This is a move-only ressource.
This class provide an interface to define the OpenGL uniforms and attributes using GLM objects.
Definition at line 114 of file Shader.hpp.
Public Member Functions | |
ShaderProgram () | |
The constructor. The ShaderProgram is initially invalid. You need to call AddShader and Link before being able to use it. More... | |
void | AddShader (const Shader &shader) |
Add a Shader to the program list. This must called multiple time for each shader components before calling Link. More... | |
void | Link () const |
Add a Shader to the program list. More... | |
bool | IsReady () const |
bool | LinkStatus () const |
void | Use () const |
Bind the ShaderProgram. Future draw will use it. This unbind any previously bound ShaderProgram. More... | |
void | Unuse () const |
Unbind the ShaderProgram. More... | |
GLuint | id () const |
The GPU id to the ShaderProgram. More... | |
GLint | Attribute (const std::string &name) const |
Return the GPU attribute id. More... | |
void | SetAttribute (const std::string &name, GLint size, GLsizei stride, GLuint offset, GLboolean normalize, GLenum type) const |
Set an OpenGL attribute properties. More... | |
void | SetAttribute (const std::string &name, GLint size, GLsizei stride, GLuint offset, GLboolean normalize) const |
Set an OpenGL attribute properties, assuming data are float. More... | |
void | SetAttribute (const std::string &name, GLint size, GLsizei stride, GLuint offset, GLenum type) const |
Set an OpenGL attribute properties, assuming data are float. More... | |
void | SetAttribute (const std::string &name, GLint size, GLsizei stride, GLuint offset) const |
Set an OpenGL attribute properties, assuming data are float. More... | |
GLint | Uniform (const std::string &name) |
Return the uniform ID. More... | |
GLint | operator[] (const std::string &name) |
void | SetUniform (const std::string &name, float x, float y, float z) |
Assign shader vec3 uniform. More... | |
void | SetUniform (const std::string &name, const glm::vec3 &v) |
void | SetUniform (const std::string &name, const glm::vec4 &v) |
void | SetUniform (const std::string &name, const glm::mat4 &m) |
void | SetUniform (const std::string &name, const glm::mat3 &m) |
void | SetUniform (const std::string &name, float val) |
Assign shader float uniform. More... | |
void | SetUniform (const std::string &name, int val) |
Assign shader int uniform. More... | |
ShaderProgram (ShaderProgram &&) noexcept | |
ShaderProgram (const ShaderProgram &) | |
ShaderProgram & | operator= (ShaderProgram &&) noexcept |
ShaderProgram & | operator= (const ShaderProgram &) |
bool | operator== (const ShaderProgram &rhs) const |
bool | operator!= (const ShaderProgram &rhs) const |
smk::ShaderProgram::ShaderProgram | ( | ) |
The constructor. The ShaderProgram is initially invalid. You need to call AddShader and Link before being able to use it.
Definition at line 219 of file Shader.cpp.
void smk::ShaderProgram::AddShader | ( | const Shader & | shader | ) |
Add a Shader to the program list. This must called multiple time for each shader components before calling Link.
shader | The Shader to be added to the program list. |
Definition at line 224 of file Shader.cpp.
GLint smk::ShaderProgram::Attribute | ( | const std::string & | name | ) | const |
Return the GPU attribute id.
name | The attribute name in the Shader. |
Definition at line 304 of file Shader.cpp.
GLuint smk::ShaderProgram::id | ( | ) | const |
The GPU id to the ShaderProgram.
Definition at line 441 of file Shader.cpp.
bool smk::ShaderProgram::IsReady | ( | ) | const |
Definition at line 244 of file Shader.cpp.
void smk::ShaderProgram::Link | ( | ) | const |
Add a Shader to the program list.
Definition at line 236 of file Shader.cpp.
bool smk::ShaderProgram::LinkStatus | ( | ) | const |
Definition at line 256 of file Shader.cpp.
bool smk::ShaderProgram::operator!= | ( | const ShaderProgram & | rhs | ) | const |
Definition at line 449 of file Shader.cpp.
bool smk::ShaderProgram::operator== | ( | const ShaderProgram & | rhs | ) | const |
Definition at line 445 of file Shader.cpp.
GLint smk::ShaderProgram::operator[] | ( | const std::string & | name | ) |
Definition at line 297 of file Shader.cpp.
void smk::ShaderProgram::SetAttribute | ( | const std::string & | name, |
GLint | size, | ||
GLsizei | stride, | ||
GLuint | offset | ||
) | const |
Set an OpenGL attribute properties, assuming data are float.
Definition at line 365 of file Shader.cpp.
void smk::ShaderProgram::SetAttribute | ( | const std::string & | name, |
GLint | size, | ||
GLsizei | stride, | ||
GLuint | offset, | ||
GLboolean | normalize | ||
) | const |
Set an OpenGL attribute properties, assuming data are float.
Definition at line 345 of file Shader.cpp.
void smk::ShaderProgram::SetAttribute | ( | const std::string & | name, |
GLint | size, | ||
GLsizei | stride, | ||
GLuint | offset, | ||
GLboolean | normalize, | ||
GLenum | type | ||
) | const |
Set an OpenGL attribute properties.
name | Attribute name in the Shader. |
size | Specify the number of component per object. One of {1,2,3,4}. |
stride | Specify the byte offset in between consecutive attribute of the same kind. |
offset | Offset of the attribute in the struct. |
type | The type of data. For instance GL_FLOAT. |
Definition at line 331 of file Shader.cpp.
void smk::ShaderProgram::SetAttribute | ( | const std::string & | name, |
GLint | size, | ||
GLsizei | stride, | ||
GLuint | offset, | ||
GLenum | type | ||
) | const |
Set an OpenGL attribute properties, assuming data are float.
Definition at line 355 of file Shader.cpp.
void smk::ShaderProgram::SetUniform | ( | const std::string & | name, |
float | val | ||
) |
Assign shader float uniform.
val | float value This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. |
Definition at line 415 of file Shader.cpp.
void smk::ShaderProgram::SetUniform | ( | const std::string & | name, |
float | x, | ||
float | y, | ||
float | z | ||
) |
Assign shader vec3 uniform.
x | First vec3 component. |
y | Second vec3 component. |
z | Third vec3 component This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. |
Definition at line 377 of file Shader.cpp.
void smk::ShaderProgram::SetUniform | ( | const std::string & | name, |
int | val | ||
) |
Assign shader int uniform.
val | int value This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. |
Definition at line 422 of file Shader.cpp.
GLint smk::ShaderProgram::Uniform | ( | const std::string & | name | ) |
Return the uniform ID.
name | The uniform name in the Shader. |
Definition at line 278 of file Shader.cpp.
void smk::ShaderProgram::Unuse | ( | ) | const |
Unbind the ShaderProgram.
Definition at line 435 of file Shader.cpp.
void smk::ShaderProgram::Use | ( | ) | const |
Bind the ShaderProgram. Future draw will use it. This unbind any previously bound ShaderProgram.
Definition at line 429 of file Shader.cpp.