OpenGL Shader Program.
More...
#include <Shader.hpp>
|
| | Shader () noexcept |
| | Constructor.
|
| | Shader (Shader &&) noexcept |
| | Move constructor.
|
| Shader & | operator= (Shader &&) noexcept |
| | Move assignment operator.
|
| | ~Shader () noexcept |
| | Destructor.
|
| bool | load (const std::string &file) noexcept |
| | Loads a combined shader.
|
| bool | load (const std::string &vertex, const std::string &frag) noexcept |
| | Loads an OpenGL shader.
|
| bool | parse (const std::string &src) noexcept |
| | Loads a combined raw shader.
|
| bool | parse (const std::string &vertex, const std::string &frag) noexcept |
| | Loads a raw shader.
|
| template<typename... Uniforms> |
| void | set_uniform (const std::string &name, const Uniforms &... args) |
| | Specialized variadic template for setting shader uniforms.
|
| template<> |
| void | set_uniform (const std::string &name) |
| template<> |
| void | set_uniform (const std::string &name, const bool &a) |
| template<> |
| void | set_uniform (const std::string &name, const int &a) |
| template<> |
| void | set_uniform (const std::string &name, const unsigned int &a) |
| template<> |
| void | set_uniform (const std::string &name, const float &a) |
|
| ray::Shader | m_shader |
| | Handle.
|
| ankerl::unordered_dense::map< std::string, int > | m_cache |
| | Cache of uniforms for better performance.
|
OpenGL Shader Program.
Currently only supports vertex and fragment shaders.
Definition at line 23 of file Shader.hpp.
◆ Shader() [1/3]
| galaxy::Shader::Shader |
( |
| ) |
|
|
noexcept |
◆ Shader() [2/3]
| galaxy::Shader::Shader |
( |
Shader && | s | ) |
|
|
noexcept |
◆ ~Shader()
| galaxy::Shader::~Shader |
( |
| ) |
|
|
noexcept |
◆ Shader() [3/3]
| galaxy::Shader::Shader |
( |
const Shader & | | ) |
|
|
privatedelete |
◆ operator=() [1/2]
Move assignment operator.
Definition at line 35 of file Shader.cpp.
◆ load() [1/2]
| bool galaxy::Shader::load |
( |
const std::string & | file | ) |
|
|
nodiscardnoexcept |
Loads a combined shader.
- Parameters
-
| file | Path to a combined shader source. |
- Returns
- True if successful.
Definition at line 63 of file Shader.cpp.
◆ load() [2/2]
| bool galaxy::Shader::load |
( |
const std::string & | vertex, |
|
|
const std::string & | frag ) |
|
nodiscardnoexcept |
Loads an OpenGL shader.
- Parameters
-
| vertex | Vertex shader. |
| frag | Fragment shader. |
- Returns
- True if successful.
Definition at line 71 of file Shader.cpp.
◆ parse() [1/2]
| bool galaxy::Shader::parse |
( |
const std::string & | src | ) |
|
|
nodiscardnoexcept |
Loads a combined raw shader.
- Parameters
-
- Returns
- True if successful.
Definition at line 81 of file Shader.cpp.
◆ parse() [2/2]
| bool galaxy::Shader::parse |
( |
const std::string & | vertex, |
|
|
const std::string & | frag ) |
|
nodiscardnoexcept |
Loads a raw shader.
- Parameters
-
| vertex | Raw vertex shader code. |
| frag | Raw fragment shader code. |
- Returns
- True if successful.
Definition at line 135 of file Shader.cpp.
◆ set_uniform() [1/6]
template<typename... Uniforms>
| void galaxy::Shader::set_uniform |
( |
const std::string & | name, |
|
|
const Uniforms &... | args ) |
Specialized variadic template for setting shader uniforms.
Useful for i.e. 2f would be ("name", 1.0f, 2.0f) and 3i would be ("name", 1, 2, 3)
- Parameters
-
| name | The name of the uniform to set. |
| args | Variable amount of arguments for the uniform. |
◆ operator=() [2/2]
Copy assignment operator.
◆ get_uniform_location()
| int galaxy::Shader::get_uniform_location |
( |
const std::string & | name | ) |
|
|
nodiscardprivate |
Retrieves the location of a shader uniform.
- Parameters
-
- Returns
- Uniform location. -1 on error.
Definition at line 160 of file Shader.cpp.
◆ set_uniform() [2/6]
template<>
| void galaxy::Shader::set_uniform |
( |
const std::string & | name | ) |
|
|
inline |
◆ set_uniform() [3/6]
template<>
| void galaxy::Shader::set_uniform |
( |
const std::string & | name, |
|
|
const bool & | a ) |
|
inline |
◆ set_uniform() [4/6]
template<>
| void galaxy::Shader::set_uniform |
( |
const std::string & | name, |
|
|
const int & | a ) |
|
inline |
◆ set_uniform() [5/6]
template<>
| void galaxy::Shader::set_uniform |
( |
const std::string & | name, |
|
|
const unsigned int & | a ) |
|
inline |
◆ set_uniform() [6/6]
template<>
| void galaxy::Shader::set_uniform |
( |
const std::string & | name, |
|
|
const float & | a ) |
|
inline |
◆ m_shader
| ray::Shader galaxy::Shader::m_shader |
|
private |
◆ m_cache
| ankerl::unordered_dense::map<std::string, int> galaxy::Shader::m_cache |
|
private |
The documentation for this class was generated from the following files: