20 #ifndef ANTKEEPER_GL_SHADER_PROGRAM_HPP
21 #define ANTKEEPER_GL_SHADER_PROGRAM_HPP
24 #include <unordered_map>
25 #include <unordered_set>
33 class shader_variable;
110 [[nodiscard]]
inline bool linked() const noexcept
120 [[nodiscard]]
inline const std::unordered_map<hash::fnv1a32_t, const std::unique_ptr<const shader_variable>>&
variables() const noexcept
134 if (
auto i = variable_map.find(key); i != variable_map.end())
136 return i->second.get();
145 [[nodiscard]]
inline const std::string&
info() const noexcept
153 void load_variables();
155 unsigned int gl_program_id{0};
156 bool m_linked{
false};
157 std::unordered_set<const shader_object*> attached_objects;
158 std::unordered_map<hash::fnv1a32_t, const std::unique_ptr<const shader_variable>> variable_map;
159 std::string info_log;
Graphics pipeline interface.
Shader object which can be compiled and linked to a shader program.
Shader program which can be linked to shader objects and executed.
shader_program()
Creates an empty shader program.
const shader_variable * variable(hash::fnv1a32_t key) const
Returns a pointer to an active shader variable with the given name, or nullptr if not found.
const std::unordered_map< hash::fnv1a32_t, const std::unique_ptr< const shader_variable > > & variables() const noexcept
Returns all active shader variables in the shader program.
shader_program(shader_program &&)=delete
void attach(const shader_object &object)
Attaches a shader object to the shader program.
bool link()
Links all attached shader objects to create an executable shader program.
~shader_program()
Destroys a shader program.
void detach_all()
Detaches all shader objects from the shader program.
const std::string & info() const noexcept
Returns the info log that contains debug information when linking fails.
shader_program(const shader_program &)=delete
bool linked() const noexcept
Returns true if the shader program has been successfully linked, false otherwise.
void detach(const shader_object &object)
Detaches a shader object from the shader program.
shader_program & operator=(const shader_program &)=delete
shader_program & operator=(shader_program &&)=delete
Graphics library interface.
32-bit FNV-1a hash value.