![]() |
galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
|
OpenGL Shader Program. More...
#include <Shader.hpp>
Collaboration diagram for galaxy::Shader:Public Member Functions | |
| 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. | |
| void | compile () |
| Compiles shader into GPU mem. | |
| void | destroy () |
| Destroys shader program. | |
| void | bind () const |
| Make active shader. | |
| void | unbind () const |
| Unbind. | |
| template<typename... Uniforms> | |
| void | set_uniform (const std::string &name, const Uniforms &... args) |
| Specialized variadic template for setting shader uniforms. | |
| unsigned int | id () const noexcept |
| Get program id. | |
| 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 int &a, const int &b) |
| template<> | |
| void | set_uniform (const std::string &name, const int &a, const int &b, const int &c) |
| template<> | |
| void | set_uniform (const std::string &name, const int &a, const int &b, const int &c, const int &d) |
| template<> | |
| void | set_uniform (const std::string &name, const unsigned int &a) |
| template<> | |
| void | set_uniform (const std::string &name, const unsigned int &a, const unsigned int &b) |
| template<> | |
| void | set_uniform (const std::string &name, const unsigned int &a, const unsigned int &b, const unsigned int &c) |
| template<> | |
| void | set_uniform (const std::string &name, const unsigned int &a, const unsigned int &b, const unsigned int &c, const unsigned int &d) |
| template<> | |
| void | set_uniform (const std::string &name, const float &a) |
| template<> | |
| void | set_uniform (const std::string &name, const float &a, const float &b) |
| template<> | |
| void | set_uniform (const std::string &name, const float &a, const float &b, const float &c) |
| template<> | |
| void | set_uniform (const std::string &name, const float &a, const float &b, const float &c, const float &d) |
| template<> | |
| void | set_uniform (const std::string &name, const double &a) |
| template<> | |
| void | set_uniform (const std::string &name, const double &a, const double &b) |
| template<> | |
| void | set_uniform (const std::string &name, const double &a, const double &b, const double &c) |
| template<> | |
| void | set_uniform (const std::string &name, const double &a, const double &b, const double &c, const double &d) |
| template<> | |
| void | set_uniform (const std::string &name, const Colour &a) |
Private Member Functions | |
| Shader (const Shader &)=delete | |
| Copy constructor. | |
| Shader & | operator= (const Shader &)=delete |
| Copy assignment operator. | |
| bool | preprocess (const std::string &src) noexcept |
| Extract source code from a combined shader. | |
| int | get_uniform_location (const std::string &name) |
| Retrieves the location of a shader uniform. | |
Private Attributes | |
| unsigned int | m_id |
| OpenGL handle. | |
| ankerl::unordered_dense::map< std::string, int > | m_cache |
| Cache of uniforms for better performance. | |
| entt::compressed_pair< std::string, std::string > | m_src |
| Shader source code. | |
OpenGL Shader Program.
Currently only supports vertex and fragment shaders.
Definition at line 27 of file Shader.hpp.
|
noexcept |
Constructor.
Definition at line 22 of file Shader.cpp.
|
noexcept |
Move constructor.
Definition at line 27 of file Shader.cpp.
|
noexcept |
|
privatedelete |
Copy constructor.
Move assignment operator.
Definition at line 41 of file Shader.cpp.
|
nodiscardnoexcept |
Loads a combined shader.
| file | Path to a combined shader source. |
Definition at line 65 of file Shader.cpp.
Here is the caller graph for this function:
|
nodiscardnoexcept |
Loads an OpenGL shader.
| vertex | Vertex shader. |
| frag | Fragment shader. |
Definition at line 73 of file Shader.cpp.
|
nodiscardnoexcept |
Loads a combined raw shader.
| src | Raw shader code. |
Definition at line 83 of file Shader.cpp.
Here is the caller graph for this function:
|
nodiscardnoexcept |
Loads a raw shader.
| vertex | Raw vertex shader code. |
| frag | Raw fragment shader code. |
Definition at line 88 of file Shader.cpp.
| void galaxy::Shader::compile | ( | ) |
Compiles shader into GPU mem.
Definition at line 113 of file Shader.cpp.
Here is the caller graph for this function:| void galaxy::Shader::destroy | ( | ) |
Destroys shader program.
Definition at line 202 of file Shader.cpp.
Here is the caller graph for this function:| void galaxy::Shader::bind | ( | ) | const |
Make active shader.
Definition at line 211 of file Shader.cpp.
Here is the caller graph for this function:| void galaxy::Shader::unbind | ( | ) | const |
| 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)
| name | The name of the uniform to set. |
| args | Variable amount of arguments for the uniform. |
Here is the caller graph for this function:
|
nodiscardnoexcept |
Get program id.
Definition at line 221 of file Shader.cpp.
Here is the caller graph for this function:
|
nodiscardprivatenoexcept |
Extract source code from a combined shader.
| src | Raw source code. |
Definition at line 226 of file Shader.cpp.
|
nodiscardprivate |
Retrieves the location of a shader uniform.
| name | Shader uniform name. |
Definition at line 273 of file Shader.cpp.
Here is the caller graph for this function:
|
inline |
Definition at line 181 of file Shader.hpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
OpenGL handle.
Definition at line 167 of file Shader.hpp.
|
private |
Cache of uniforms for better performance.
Definition at line 172 of file Shader.hpp.
|
private |
Shader source code.
Definition at line 177 of file Shader.hpp.