RAII representation of a open gl shader program.
More...
|
| | ShaderProgram (DEBUG_LABEL_ARG_MANY const std::string &vertex_source, const std::string &fragment_source, const core::CompiledShaderVertexAttributes &layout) |
| | Compile and link a shader.
|
| |
| | ~ShaderProgram () |
| | Destroy the shader if it's loaded.
|
| |
| | ShaderProgram (const ShaderProgram &)=delete |
| | Copying is not allowed.
|
| |
| void | operator= (const ShaderProgram &)=delete |
| | Copying is not allowed.
|
| |
| | ShaderProgram (ShaderProgram &&other) noexcept |
| | Take ownership of another shader.
|
| |
| ShaderProgram & | operator= (ShaderProgram &&rhs) noexcept |
| | Take ownership of another shader.
|
| |
| void | clear () |
| | Turn this object into a zombie by destroying it.
|
| |
| bool | is_loaded () const |
| | Checks if the ShaderProgram is loaded and valid.
|
| |
| void | use () const |
| | Activates the ShaderProgram for rendering.
|
| |
| Uniform | get_uniform (const std::string &name) const |
| | Get a uniform by name.
|
| |
| void | set_float (const Uniform &uniform, float value) |
| | Sets a uniform float value.
|
| |
| void | set_bool (const Uniform &uniform, bool value) |
| | Sets a uniform boolean value.
|
| |
| void | set_vec2 (const Uniform &uniform, float x, float y) |
| | Sets a uniform 2d vector.
|
| |
| void | set_vec2 (const Uniform &uniform, const v2 &v) |
| | Sets a uniform 2d vector.
|
| |
| void | set_vec3 (const Uniform &uniform, float x, float y, float z) |
| | Sets a uniform 3d vector.
|
| |
| void | set_vec3 (const Uniform &uniform, const v3 &v) |
| | Sets a uniform 3d vector.
|
| |
| void | set_vec4 (const Uniform &uniform, float x, float y, float z, float w) |
| | Sets a uniform 4d vector.
|
| |
| void | set_vec4 (const Uniform &uniform, const v4 &v) |
| | Sets a uniform 4d vector.
|
| |
| void | set_texture (const Uniform &uniform) |
| | Sets a texture for a uniform.
|
| |
| void | set_mat (const Uniform &uniform, const m4 &mat) |
| | Sets a uniform 4x4 matrix.
|
| |
| void | setup_uniform_block (const core::UniformBufferSetup &setup) |
| | Configures a uniform block binding for the shader.
|
| |
RAII representation of a open gl shader program.
Definition at line 27 of file shader.h.
◆ ShaderProgram() [1/3]
Compile and link a shader.
If there are any errors, they are logged and a zombie object is created instead.
- Parameters
-
| vertex_source | glsl code for the vertex shader |
| fragment_source | glsl code for the fragment shader |
| layout | the vertex layout to use |
◆ ~ShaderProgram()
| eu::render::ShaderProgram::~ShaderProgram |
( |
| ) |
|
Destroy the shader if it's loaded.
- See also
- clear
◆ ShaderProgram() [2/3]
◆ ShaderProgram() [3/3]
| eu::render::ShaderProgram::ShaderProgram |
( |
ShaderProgram && |
other | ) |
|
|
noexcept |
Take ownership of another shader.
- Parameters
-
| other | the shader to take ownership from |
◆ clear()
| void eu::render::ShaderProgram::clear |
( |
| ) |
|
Turn this object into a zombie by destroying it.
- Note
- Does nothing if it already is a zombie
◆ get_uniform()
| Uniform eu::render::ShaderProgram::get_uniform |
( |
const std::string & |
name | ) |
const |
Get a uniform by name.
- Parameters
-
| name | the name of the uniform in the shader program |
- Returns
- Uniform object representing the location or a zombie if not found
◆ is_loaded()
| bool eu::render::ShaderProgram::is_loaded |
( |
| ) |
const |
Checks if the ShaderProgram is loaded and valid.
- Returns
true if the program is valid; otherwise, false
◆ operator=() [1/2]
◆ operator=() [2/2]
Take ownership of another shader.
- Parameters
-
| rhs | the shader to take ownership from |
◆ set_bool()
Sets a uniform boolean value.
- Parameters
-
| uniform | the target uniform |
| value | the value |
- Note
- The shader must be bound before calling this method
◆ set_float()
Sets a uniform float value.
Does nothing if the uniform is a zombie.
- Parameters
-
| uniform | the target uniform |
| value | the value |
- Note
- The shader must be bound before calling this method
◆ set_mat()
Sets a uniform 4x4 matrix.
- Parameters
-
| uniform | the target uniform |
| mat | the matrix data |
- Note
- The shader must be bound before calling this method.
◆ set_texture()
Sets a texture for a uniform.
Does nothing if the uniform is a zombie.
- Parameters
-
| uniform | the target uniform (must be a texture uniform) |
- Note
- The shader must be bound before calling this method.
◆ set_vec2() [1/2]
Sets a uniform 2d vector.
Does nothing if the uniform is a zombie.
- Parameters
-
| uniform | the target uniform |
| v | the value |
- Note
- The shader must be bound before calling this method.
◆ set_vec2() [2/2]
Sets a uniform 2d vector.
Does nothing if the uniform is a zombie.
- Parameters
-
| uniform | the target uniform |
| x | the x value of the vector |
| y | the y value of the vector |
- Note
- The shader must be bound before calling this method.
◆ set_vec3() [1/2]
Sets a uniform 3d vector.
Does nothing if the uniform is a zombie.
- Parameters
-
| uniform | the target uniform |
| v | the vector |
- Note
- The shader must be bound before calling this method.
◆ set_vec3() [2/2]
Sets a uniform 3d vector.
Does nothing if the uniform is a zombie.
- Parameters
-
| uniform | the target uniform |
| x | the x value of the vector |
| y | the y value of the vector |
| z | the z value of the vector |
- Note
- The shader must be bound before calling this method.
◆ set_vec4() [1/2]
Sets a uniform 4d vector.
Does nothing if the uniform is a zombie.
- Parameters
-
| uniform | the target uniform |
| v | the vector |
- Note
- The shader must be bound before calling this method.
◆ set_vec4() [2/2]
Sets a uniform 4d vector.
Does nothing if the uniform is a zombie.
- Parameters
-
| uniform | the target uniform |
| x | the x value of the vector |
| y | the y value of the vector |
| z | the z value of the vector |
| w | the w value of the vector |
- Note
- The shader must be bound before calling this method.
◆ setup_uniform_block()
Configures a uniform block binding for the shader.
- Parameters
-
| setup | the information about the uniform block setup |
◆ use()
| void eu::render::ShaderProgram::use |
( |
| ) |
const |
Activates the ShaderProgram for rendering.
◆ debug_vertex_types
The debug information describing the vertex layout that this shader expects.
Definition at line 173 of file shader.h.
◆ shader_program
The id of the shader program.
Definition at line 172 of file shader.h.
The documentation for this struct was generated from the following file: