Manages OpenGL shader program compilation and uniform setting.
More...
#include <shader.hpp>
|
| void | use () |
| | Activate this shader for rendering.
|
| void | bindBlocks () |
| | Bind uniform buffer blocks to predefined binding points.
|
| void | setUniform (const std::string &name, const glm::mat4 &value) |
| | Set a mat4 uniform value.
|
| void | setUniform (const std::string &name, const glm::vec3 &value) |
| | Set a vec3 uniform value.
|
| void | setUniform (const std::string &name, float value) |
| | Set a float uniform value.
|
| void | setUniform (const std::string &name, int value) |
| | Set an integer uniform value.
|
| void | setUniform (const std::string &name, bool value) |
| | Set a boolean uniform value.
|
| void | compile (const std::string &vertexSrc, const std::string &fragmentSrc) |
| | Compile and link shader program from source code.
|
| void | checkCompileErrors (uint32_t shader, const std::string &type) |
| | Check for shader compilation or linking errors.
|
Manages OpenGL shader program compilation and uniform setting.
- Note
- Automatically binds common uniform blocks (Camera, Lights, Rigidbody)
- Warning
- Shader sources must be valid GLSL code
◆ bindBlocks()
| void solarsim::Shader::bindBlocks |
( |
| ) |
|
|
inline |
Bind uniform buffer blocks to predefined binding points.
- Note
- Binds CameraBuffer(0), LightsBuffer(1), RigidbodyBuffer(2)
- Warning
- Call this after compilation, it's called automatically by compile()
◆ checkCompileErrors()
| void solarsim::Shader::checkCompileErrors |
( |
uint32_t | shader, |
|
|
const std::string & | type ) |
|
inline |
Check for shader compilation or linking errors.
- Parameters
-
| shader | Shader or program object to check |
| type | Type of shader ("VERTEX", "FRAGMENT", or "PROGRAM") |
- Note
- Prints errors to std::cerr
◆ compile()
| void solarsim::Shader::compile |
( |
const std::string & | vertexSrc, |
|
|
const std::string & | fragmentSrc ) |
|
inline |
Compile and link shader program from source code.
- Parameters
-
| vertexSrc | Vertex shader source code |
| fragmentSrc | Fragment shader source code |
- Note
- Automatically calls bindBlocks() after successful compilation
◆ setUniform() [1/5]
| void solarsim::Shader::setUniform |
( |
const std::string & | name, |
|
|
bool | value ) |
|
inline |
Set a boolean uniform value.
- Parameters
-
| name | Uniform variable name in shader |
| value | Boolean value (converted to 0 or 1) |
◆ setUniform() [2/5]
| void solarsim::Shader::setUniform |
( |
const std::string & | name, |
|
|
const glm::mat4 & | value ) |
|
inline |
Set a mat4 uniform value.
- Parameters
-
| name | Uniform variable name in shader |
| value | 4x4 matrix value |
◆ setUniform() [3/5]
| void solarsim::Shader::setUniform |
( |
const std::string & | name, |
|
|
const glm::vec3 & | value ) |
|
inline |
Set a vec3 uniform value.
- Parameters
-
| name | Uniform variable name in shader |
| value | 3-component vector value |
◆ setUniform() [4/5]
| void solarsim::Shader::setUniform |
( |
const std::string & | name, |
|
|
float | value ) |
|
inline |
Set a float uniform value.
- Parameters
-
| name | Uniform variable name in shader |
| value | Single float value |
◆ setUniform() [5/5]
| void solarsim::Shader::setUniform |
( |
const std::string & | name, |
|
|
int | value ) |
|
inline |
Set an integer uniform value.
- Parameters
-
| name | Uniform variable name in shader |
| value | Integer value |
◆ use()
| void solarsim::Shader::use |
( |
| ) |
|
|
inline |
Activate this shader for rendering.
◆ programID
| uint32_t solarsim::Shader::programID = 0 |
The OpenGL shader program handle
The documentation for this struct was generated from the following file: