Antkeeper  0.0.1
shader-object.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_GL_SHADER_OBJECT_HPP
21 #define ANTKEEPER_GL_SHADER_OBJECT_HPP
22 
24 #include <cstddef>
25 #include <string>
26 #include <string_view>
27 
28 namespace gl {
29 
30 class shader_program;
31 
39 {
40 public:
49 
54 
63  void source(std::string_view source_code);
64 
75  bool compile();
76 
78  [[nodiscard]] inline shader_stage stage() const noexcept
79  {
80  return m_stage;
81  }
82 
84  [[nodiscard]] inline const std::string& info() const noexcept
85  {
86  return info_log;
87  }
88 
90  [[nodiscard]] inline bool compiled() const noexcept
91  {
92  return m_compiled;
93  }
94 
95  shader_object(const shader_object&) = delete;
97 
98 private:
99  friend class shader_program;
100 
101  unsigned int gl_shader_id{0};
102  shader_stage m_stage{0};
103  bool m_compiled{false};
104  std::string info_log;
105 };
106 
107 } // namespace gl
108 
109 #endif // ANTKEEPER_GL_SHADER_OBJECT_HPP
Shader object which can be compiled and linked to a shader program.
bool compile()
Compiles the shader object.
~shader_object()
Destroys a shader object.
void source(std::string_view source_code)
Replaces the source code of the shader object.
shader_stage stage() const noexcept
Returns the shader stage of this shader object.
shader_object & operator=(const shader_object &)=delete
const std::string & info() const noexcept
Returns the shader object info log, which is updated when the shader object is compiled.
bool compiled() const noexcept
Returns true if the shader object has been successfully compiled, false otherwise.
shader_object(shader_stage stage)
Creates an empty shader object for the specified shader stage.
shader_object(const shader_object &)=delete
Shader program which can be linked to shader objects and executed.
Graphics library interface.
Definition: window.hpp:28
shader_stage
Enumerates all supported shader stages.