|
Monad Engine da02fba2
> Undercity Codex_
|
Linked GLSL program with cached uniform locations. More...
#include <ShaderProgram.h>
Public Member Functions | |
| ShaderProgram ()=delete | |
| ShaderProgram (const ShaderProgram &)=delete | |
| ShaderProgram & | operator= (const ShaderProgram &)=delete |
| ShaderProgram (GLuint shaderProgramID) | |
| Wraps an existing linked GL program. | |
| ~ShaderProgram () | |
| Calls glDeleteProgram() to release the GPU resource. | |
| void | Bind () |
| Activate this program for subsequent draw calls (glUseProgram). | |
| GLint | GetUniformLocation (const std::string &name) |
| Look up a uniform location, caching the result for future calls. | |
Uniform Setters | |
Upload typed values to named GLSL uniforms. | |
| void | SetUniform (const std::string &name, float value) |
| Upload a float uniform. | |
| void | SetUniform (const std::string &name, float v0, float v1) |
| Upload a vec2 uniform. | |
| void | SetUniform (const std::string &name, float v0, float v1, float v2) |
| Upload a vec3 uniform. | |
| void | SetUniform (const std::string &name, float v0, float v1, float v2, float v3) |
| Upload a vec4 uniform. | |
| void | SetUniform (const std::string &name, const mat4 &mat) |
| Upload a 4×4 matrix (column-major). | |
| void | SetUniform (const std::string &name, const vec3 &value) |
| Upload a vec3 from a glm::vec3. | |
| void | SetUniform (const std::string &name, const mat4 *matrices, std::size_t count) |
| Upload an array of 4×4 matrices. | |
| void | SetTexture (const std::string &name, Texture *texture) |
| Bind a texture to the next available texture unit and set the sampler uniform. | |
Linked GLSL program with cached uniform locations.
Non-copyable — each GL program handle is unique. Created exclusively by GraphicsAPI and typically stored in a std::shared_ptr<ShaderProgram>.
Definition at line 40 of file ShaderProgram.h.
|
delete |
|
delete |
|
explicit |
Wraps an existing linked GL program.
| shaderProgramID | A GL program handle returned by glCreateProgram(). |
Definition at line 8 of file ShaderProgram.cpp.
References LOG_INFO.
| mnd::ShaderProgram::~ShaderProgram | ( | ) |
Calls glDeleteProgram() to release the GPU resource.
Definition at line 14 of file ShaderProgram.cpp.
References LOG_INFO.
| void mnd::ShaderProgram::Bind | ( | ) |
Activate this program for subsequent draw calls (glUseProgram).
Definition at line 20 of file ShaderProgram.cpp.
| GLint mnd::ShaderProgram::GetUniformLocation | ( | const std::string & | name | ) |
Look up a uniform location, caching the result for future calls.
| name | The GLSL uniform variable name. |
Definition at line 26 of file ShaderProgram.cpp.
References LOG_WARN.
Referenced by SetTexture(), SetUniform(), SetUniform(), SetUniform(), SetUniform(), SetUniform(), SetUniform(), and SetUniform().
|
delete |
| void mnd::ShaderProgram::SetTexture | ( | const std::string & | name, |
| Texture * | texture | ||
| ) |
Bind a texture to the next available texture unit and set the sampler uniform.
| name | GLSL sampler uniform name (e.g. "uDiffuse"). |
| texture | Texture to bind; must not be nullptr. |
Definition at line 86 of file ShaderProgram.cpp.
References mnd::Texture::GetID(), and GetUniformLocation().
| void mnd::ShaderProgram::SetUniform | ( | const std::string & | name, |
| const mat4 & | mat | ||
| ) |
Upload a 4×4 matrix (column-major).
Definition at line 64 of file ShaderProgram.cpp.
References GetUniformLocation().
| void mnd::ShaderProgram::SetUniform | ( | const std::string & | name, |
| const mat4 * | matrices, | ||
| std::size_t | count | ||
| ) |
Upload an array of 4×4 matrices.
Definition at line 76 of file ShaderProgram.cpp.
References GetUniformLocation().
| void mnd::ShaderProgram::SetUniform | ( | const std::string & | name, |
| const vec3 & | value | ||
| ) |
Upload a vec3 from a glm::vec3.
Definition at line 70 of file ShaderProgram.cpp.
References GetUniformLocation().
| void mnd::ShaderProgram::SetUniform | ( | const std::string & | name, |
| float | v0, | ||
| float | v1 | ||
| ) |
Upload a vec2 uniform.
Definition at line 46 of file ShaderProgram.cpp.
References GetUniformLocation().
| void mnd::ShaderProgram::SetUniform | ( | const std::string & | name, |
| float | v0, | ||
| float | v1, | ||
| float | v2 | ||
| ) |
Upload a vec3 uniform.
Definition at line 52 of file ShaderProgram.cpp.
References GetUniformLocation().
| void mnd::ShaderProgram::SetUniform | ( | const std::string & | name, |
| float | v0, | ||
| float | v1, | ||
| float | v2, | ||
| float | v3 | ||
| ) |
Upload a vec4 uniform.
Definition at line 58 of file ShaderProgram.cpp.
References GetUniformLocation().
| void mnd::ShaderProgram::SetUniform | ( | const std::string & | name, |
| float | value | ||
| ) |
Upload a float uniform.
Definition at line 40 of file ShaderProgram.cpp.
References GetUniformLocation().