libdonut
2.3.2
Application framework for cross-platform game development in C++20
|
Compiled and linked GPU shader program. More...
#include <donut/graphics/ShaderProgram.hpp>
Public Types | |
using | UniformValue = Variant< float, vec2, vec3, vec4, i32, i32vec2, i32vec3, i32vec4, u32, u32vec2, u32vec3, u32vec4, mat2, mat3, mat4 > |
Value of a uniform shader variable. More... | |
Public Member Functions | |
ShaderProgram (const ShaderProgramOptions &options) | |
Compile and link a shader program. More... | |
void | setUniformFloat (const ShaderParameter ¶meter, float value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type float. More... | |
void | setUniformVec2 (const ShaderParameter ¶meter, vec2 value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type vec2. More... | |
void | setUniformVec3 (const ShaderParameter ¶meter, vec3 value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type vec3. More... | |
void | setUniformVec4 (const ShaderParameter ¶meter, vec4 value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type vec4. More... | |
void | setUniformInt (const ShaderParameter ¶meter, i32 value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type int. More... | |
void | setUniformIVec2 (const ShaderParameter ¶meter, i32vec2 value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type ivec2. More... | |
void | setUniformIVec3 (const ShaderParameter ¶meter, i32vec3 value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type ivec3. More... | |
void | setUniformIVec4 (const ShaderParameter ¶meter, i32vec4 value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type ivec4. More... | |
void | setUniformUint (const ShaderParameter ¶meter, u32 value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type uint. More... | |
void | setUniformUVec2 (const ShaderParameter ¶meter, u32vec2 value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type uvec2. More... | |
void | setUniformUVec3 (const ShaderParameter ¶meter, u32vec3 value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type uvec3. More... | |
void | setUniformUVec4 (const ShaderParameter ¶meter, u32vec4 value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type uvec4. More... | |
void | setUniformMat2 (const ShaderParameter ¶meter, const mat2 &value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type mat2. More... | |
void | setUniformMat3 (const ShaderParameter ¶meter, const mat3 &value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type mat3. More... | |
void | setUniformMat4 (const ShaderParameter ¶meter, const mat4 &value) |
Enqueue a new value to be set for a uniform shader variable of GLSL type mat4. More... | |
void | setUniformSampler (const ShaderParameter ¶meter, const Texture *texture) |
Insert a new texture to be bound for a uniform shader variable of a GLSL sampler type. More... | |
void | clearUniformUploadQueue () noexcept |
Erase all entries from the queue of new uniform shader variable values. More... | |
void | clearTextureBindings () noexcept |
Erase all entries from the list of active texture bindings. More... | |
std::span< const std::pair< std::int32_t, UniformValue > > | getUniformUploadQueue () const noexcept |
Get the list of new uniform shader variable values to be uploaded to the shader. More... | |
std::span< const std::pair< std::int32_t, const Texture * > > | getTextureBindings () const noexcept |
Get the list of active texture bindings to be synchronized with the shader. More... | |
Handle | get () const noexcept |
Get an opaque handle to the GPU representation of the shader program. More... | |
Compiled and linked GPU shader program.
using donut::graphics::ShaderProgram::UniformValue = Variant< float, vec2, vec3, vec4, i32, i32vec2, i32vec3, i32vec4, u32, u32vec2, u32vec3, u32vec4, mat2, mat3, mat4> |
Value of a uniform shader variable.
|
explicit |
Compile and link a shader program.
options | shader program options, see ShaderProgramOptions. |
graphics::Error | on failure to create a shader object, create the shader program object, compile the shader code or link the shader program. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformFloat | ( | const ShaderParameter & | parameter, |
float | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type float.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformVec2 | ( | const ShaderParameter & | parameter, |
vec2 | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type vec2.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformVec3 | ( | const ShaderParameter & | parameter, |
vec3 | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type vec3.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformVec4 | ( | const ShaderParameter & | parameter, |
vec4 | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type vec4.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformInt | ( | const ShaderParameter & | parameter, |
i32 | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type int.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformIVec2 | ( | const ShaderParameter & | parameter, |
i32vec2 | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type ivec2.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformIVec3 | ( | const ShaderParameter & | parameter, |
i32vec3 | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type ivec3.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformIVec4 | ( | const ShaderParameter & | parameter, |
i32vec4 | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type ivec4.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformUint | ( | const ShaderParameter & | parameter, |
u32 | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type uint.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformUVec2 | ( | const ShaderParameter & | parameter, |
u32vec2 | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type uvec2.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformUVec3 | ( | const ShaderParameter & | parameter, |
u32vec3 | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type uvec3.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformUVec4 | ( | const ShaderParameter & | parameter, |
u32vec4 | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type uvec4.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformMat2 | ( | const ShaderParameter & | parameter, |
const mat2 & | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type mat2.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformMat3 | ( | const ShaderParameter & | parameter, |
const mat3 & | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type mat3.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformMat4 | ( | const ShaderParameter & | parameter, |
const mat4 & | value | ||
) |
Enqueue a new value to be set for a uniform shader variable of GLSL type mat4.
parameter | shader variable to set. |
value | new value to set the variable to. |
std::bad_alloc | on allocation failure. |
void donut::graphics::ShaderProgram::setUniformSampler | ( | const ShaderParameter & | parameter, |
const Texture * | texture | ||
) |
Insert a new texture to be bound for a uniform shader variable of a GLSL sampler type.
parameter | shader variable to set. |
texture | non-owning read-only pointer to the new texture to bind the variable to, or nullptr to remove the binding for the given variable. |
std::bad_alloc | on allocation failure. |
|
inlinenoexcept |
Erase all entries from the queue of new uniform shader variable values.
|
inlinenoexcept |
Erase all entries from the list of active texture bindings.
|
inlinenoexcept |
Get the list of new uniform shader variable values to be uploaded to the shader.
|
inlinenoexcept |
Get the list of active texture bindings to be synchronized with the shader.
|
inlinenoexcept |
Get an opaque handle to the GPU representation of the shader program.