|
Euphoria
|
RAII representation of a open gl shader program. More...
Public Member Functions | |
| 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. | |
Public Attributes | |
| unsigned int | shader_program |
| The id of the shader program. | |
| core::VertexTypes | debug_vertex_types |
| The debug information describing the vertex layout that this shader expects. | |
| eu::render::ShaderProgram::ShaderProgram | ( | DEBUG_LABEL_ARG_MANY const std::string & | vertex_source, |
| const std::string & | fragment_source, | ||
| const core::CompiledShaderVertexAttributes & | layout ) |
Compile and link a shader.
If there are any errors, they are logged and a zombie object is created instead.
| vertex_source | glsl code for the vertex shader |
| fragment_source | glsl code for the fragment shader |
| layout | the vertex layout to use |
| eu::render::ShaderProgram::~ShaderProgram | ( | ) |
Destroy the shader if it's loaded.
|
delete |
Copying is not allowed.
|
noexcept |
Take ownership of another shader.
| other | the shader to take ownership from |
| void eu::render::ShaderProgram::clear | ( | ) |
Turn this object into a zombie by destroying it.
|
nodiscard |
Get a uniform by name.
| name | the name of the uniform in the shader program |
|
nodiscard |
Checks if the ShaderProgram is loaded and valid.
|
delete |
Copying is not allowed.
|
noexcept |
Take ownership of another shader.
| rhs | the shader to take ownership from |
| void eu::render::ShaderProgram::set_bool | ( | const Uniform & | uniform, |
| bool | value ) |
Sets a uniform boolean value.
| uniform | the target uniform |
| value | the value |
| void eu::render::ShaderProgram::set_float | ( | const Uniform & | uniform, |
| float | value ) |
Sets a uniform float value.
Does nothing if the uniform is a zombie.
| uniform | the target uniform |
| value | the value |
Sets a uniform 4x4 matrix.
| uniform | the target uniform |
| mat | the matrix data |
| void eu::render::ShaderProgram::set_texture | ( | const Uniform & | uniform | ) |
Sets a texture for a uniform.
Does nothing if the uniform is a zombie.
| uniform | the target uniform (must be a texture uniform) |
Sets a uniform 2d vector.
Does nothing if the uniform is a zombie.
| uniform | the target uniform |
| v | the value |
| void eu::render::ShaderProgram::set_vec2 | ( | const Uniform & | uniform, |
| float | x, | ||
| float | y ) |
Sets a uniform 2d vector.
Does nothing if the uniform is a zombie.
| uniform | the target uniform |
| x | the x value of the vector |
| y | the y value of the vector |
Sets a uniform 3d vector.
Does nothing if the uniform is a zombie.
| uniform | the target uniform |
| v | the vector |
| void eu::render::ShaderProgram::set_vec3 | ( | const Uniform & | uniform, |
| float | x, | ||
| float | y, | ||
| float | z ) |
Sets a uniform 3d vector.
Does nothing if the uniform is a zombie.
| 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 |
Sets a uniform 4d vector.
Does nothing if the uniform is a zombie.
| uniform | the target uniform |
| v | the vector |
| void eu::render::ShaderProgram::set_vec4 | ( | const Uniform & | uniform, |
| float | x, | ||
| float | y, | ||
| float | z, | ||
| float | w ) |
Sets a uniform 4d vector.
Does nothing if the uniform is a zombie.
| 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 |
| void eu::render::ShaderProgram::setup_uniform_block | ( | const core::UniformBufferSetup & | setup | ) |
Configures a uniform block binding for the shader.
| setup | the information about the uniform block setup |
| void eu::render::ShaderProgram::use | ( | ) | const |
Activates the ShaderProgram for rendering.
| core::VertexTypes eu::render::ShaderProgram::debug_vertex_types |
| unsigned int eu::render::ShaderProgram::shader_program |