ShaderState class
#include <nCine/Graphics/ShaderState.h>
Binds a custom shader to a drawable node and feeds its uniforms and textures.
Lets the user attach a Shader to a DrawableNode and set its uniform values, uniform block contents and texture units. Returns the node to its default shader when assigned a nullptr shader.
Constructors, destructors, conversion operators
- ShaderState()
- ShaderState(DrawableNode* node, Shader* shader)
- ~ShaderState()
- ShaderState(const ShaderState&) deleted
Public functions
- auto operator=(const ShaderState&) -> ShaderState& deleted
- auto GetNode() const -> const DrawableNode*
- Returns the associated drawable node.
- auto SetNode(DrawableNode* node) -> bool
- Sets the associated drawable node.
- auto GetShader() const -> const Shader*
- Returns the assigned shader.
- auto SetShader(Shader* shader) -> bool
- Assigns a shader to the node, or restores the default shader when
nullptr. - auto ResetShader() -> bool
- Triggers a shader update without setting a new shader.
-
auto SetTexture(std::
uint32_t unit, const Texture* texture) -> bool - Sets the texture bound to the specified texture unit.
- auto SetTexture(const Texture* texture) -> bool
- Sets the texture bound to the first texture unit.
-
auto SetUniformInt(const char* blockName,
const char* name,
const std::
int32_t* vector) -> bool - Sets an integer uniform value from a vector pointer.
-
auto SetUniformInt(const char* blockName,
const char* name,
std::
int32_t value0) -> bool - Sets an integer uniform from one to four scalar components.
-
auto SetUniformInt(const char* blockName,
const char* name,
std::
int32_t value0, std:: int32_t value1) -> bool - Sets an integer uniform from one to four scalar components.
-
auto SetUniformInt(const char* blockName,
const char* name,
std::
int32_t value0, std:: int32_t value1, std:: int32_t value2) -> bool - Sets an integer uniform from one to four scalar components.
-
auto SetUniformInt(const char* blockName,
const char* name,
std::
int32_t value0, std:: int32_t value1, std:: int32_t value2, std:: int32_t value3) -> bool - Sets an integer uniform from one to four scalar components.
- auto SetUniformInt(const char* blockName, const char* name, const Vector2i& vector) -> bool
- Sets an integer uniform from an integer vector.
- auto SetUniformInt(const char* blockName, const char* name, const Vector3i& vector) -> bool
- Sets an integer uniform from an integer vector.
- auto SetUniformInt(const char* blockName, const char* name, const Vector4i& vector) -> bool
- Sets an integer uniform from an integer vector.
- auto SetUniformFloat(const char* blockName, const char* name, const float* vector) -> bool
- Sets a float uniform value from a vector pointer.
- auto SetUniformFloat(const char* blockName, const char* name, float value0) -> bool
- Sets a float uniform from one to four scalar components.
- auto SetUniformFloat(const char* blockName, const char* name, float value0, float value1) -> bool
- Sets a float uniform from one to four scalar components.
- auto SetUniformFloat(const char* blockName, const char* name, float value0, float value1, float value2) -> bool
- Sets a float uniform from one to four scalar components.
- auto SetUniformFloat(const char* blockName, const char* name, float value0, float value1, float value2, float value3) -> bool
- Sets a float uniform from one to four scalar components.
- auto SetUniformFloat(const char* blockName, const char* name, const Vector2f& vector) -> bool
- Sets a float uniform from a float vector.
- auto SetUniformFloat(const char* blockName, const char* name, const Vector3f& vector) -> bool
- Sets a float uniform from a float vector.
- auto SetUniformFloat(const char* blockName, const char* name, const Vector4f& vector) -> bool
- Sets a float uniform from a float vector.
- auto SetUniformFloat(const char* blockName, const char* name, const Colorf& color) -> bool
- Sets a float uniform from a color.
-
auto GetUniformBlockSize(const char* blockName) -> std::
uint32_t - Returns the size in bytes of the specified uniform block.
-
auto CopyToUniformBlock(const char* blockName,
std::
uint32_t destIndex, std:: uint8_t* src, std:: uint32_t numBytes) -> bool - Copies raw data into the specified uniform block at the given element index.
-
auto CopyToUniformBlock(const char* blockName,
std::
uint8_t* src, std:: uint32_t numBytes) -> bool - Copies the specified number of bytes into the uniform block.
-
auto CopyToUniformBlock(const char* blockName,
std::
uint8_t* src) -> bool - Copies data filling the whole uniform block.
Function documentation
bool nCine:: ShaderState:: ResetShader()
Triggers a shader update without setting a new shader.