Antkeeper  0.0.1
shader-variable.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_INPUT_HPP
21 #define ANTKEEPER_GL_SHADER_INPUT_HPP
22 
23 #include <engine/math/vector.hpp>
24 #include <engine/math/matrix.hpp>
26 #include <cstdint>
27 #include <span>
28 #include <memory>
29 
30 namespace gl {
31 
32 class texture_1d;
33 class texture_2d;
34 class texture_3d;
35 class texture_cube;
36 
41 {
42 public:
46  [[nodiscard]] virtual constexpr shader_variable_type type() const noexcept = 0;
47 
51  [[nodiscard]] inline std::size_t size() const noexcept
52  {
53  return m_size;
54  }
55 
64  virtual void update(bool value) const;
65  virtual void update(const math::bvec2& value) const;
66  virtual void update(const math::bvec3& value) const;
67  virtual void update(const math::bvec4& value) const;
68 
69  virtual void update(int value) const;
70  virtual void update(const math::ivec2& value) const;
71  virtual void update(const math::ivec3& value) const;
72  virtual void update(const math::ivec4& value) const;
73 
74  virtual void update(unsigned int value) const;
75  virtual void update(const math::uvec2& value) const;
76  virtual void update(const math::uvec3& value) const;
77  virtual void update(const math::uvec4& value) const;
78 
79  virtual void update(float value) const;
80  virtual void update(const math::fvec2& value) const;
81  virtual void update(const math::fvec3& value) const;
82  virtual void update(const math::fvec4& value) const;
83 
84  virtual void update(const math::fmat2& value) const;
85  virtual void update(const math::fmat3& value) const;
86  virtual void update(const math::fmat4& value) const;
87 
88  virtual void update(const texture_1d& value) const;
89  virtual void update(const texture_2d& value) const;
90  virtual void update(const texture_3d& value) const;
91  virtual void update(const texture_cube& value) const;
93 
103  virtual void update(bool value, std::size_t index) const;
104  virtual void update(const math::bvec2& value, std::size_t index) const;
105  virtual void update(const math::bvec3& value, std::size_t index) const;
106  virtual void update(const math::bvec4& value, std::size_t index) const;
107 
108  virtual void update(int value, std::size_t index) const;
109  virtual void update(const math::ivec2& value, std::size_t index) const;
110  virtual void update(const math::ivec3& value, std::size_t index) const;
111  virtual void update(const math::ivec4& value, std::size_t index) const;
112 
113  virtual void update(unsigned int value, std::size_t index) const;
114  virtual void update(const math::uvec2& value, std::size_t index) const;
115  virtual void update(const math::uvec3& value, std::size_t index) const;
116  virtual void update(const math::uvec4& value, std::size_t index) const;
117 
118  virtual void update(float value, std::size_t index) const;
119  virtual void update(const math::fvec2& value, std::size_t index) const;
120  virtual void update(const math::fvec3& value, std::size_t index) const;
121  virtual void update(const math::fvec4& value, std::size_t index) const;
122 
123  virtual void update(const math::fmat2& value, std::size_t index) const;
124  virtual void update(const math::fmat3& value, std::size_t index) const;
125  virtual void update(const math::fmat4& value, std::size_t index) const;
126 
127  virtual void update(const texture_1d& value, std::size_t index) const;
128  virtual void update(const texture_2d& value, std::size_t index) const;
129  virtual void update(const texture_3d& value, std::size_t index) const;
130  virtual void update(const texture_cube& value, std::size_t index) const;
132 
142  virtual void update(std::span<const bool> values, std::size_t index = 0) const;
143  virtual void update(std::span<const math::bvec2> values, std::size_t index = 0) const;
144  virtual void update(std::span<const math::bvec3> values, std::size_t index = 0) const;
145  virtual void update(std::span<const math::bvec4> values, std::size_t index = 0) const;
146 
147  virtual void update(std::span<const int> values, std::size_t index = 0) const;
148  virtual void update(std::span<const math::ivec2> values, std::size_t index = 0) const;
149  virtual void update(std::span<const math::ivec3> values, std::size_t index = 0) const;
150  virtual void update(std::span<const math::ivec4> values, std::size_t index = 0) const;
151 
152  virtual void update(std::span<const unsigned int> values, std::size_t index = 0) const;
153  virtual void update(std::span<const math::uvec2> values, std::size_t index = 0) const;
154  virtual void update(std::span<const math::uvec3> values, std::size_t index = 0) const;
155  virtual void update(std::span<const math::uvec4> values, std::size_t index = 0) const;
156 
157  virtual void update(std::span<const float> values, std::size_t index = 0) const;
158  virtual void update(std::span<const math::fvec2> values, std::size_t index = 0) const;
159  virtual void update(std::span<const math::fvec3> values, std::size_t index = 0) const;
160  virtual void update(std::span<const math::fvec4> values, std::size_t index = 0) const;
161 
162  virtual void update(std::span<const math::fmat2> values, std::size_t index = 0) const;
163  virtual void update(std::span<const math::fmat3> values, std::size_t index = 0) const;
164  virtual void update(std::span<const math::fmat4> values, std::size_t index = 0) const;
165 
166  virtual void update(std::span<const texture_1d* const> values, std::size_t index = 0) const;
167  virtual void update(std::span<const texture_2d* const> values, std::size_t index = 0) const;
168  virtual void update(std::span<const texture_3d* const> values, std::size_t index = 0) const;
169  virtual void update(std::span<const texture_cube* const> values, std::size_t index = 0) const;
170 
171  virtual void update(std::span<const std::shared_ptr<texture_1d>> values, std::size_t index = 0) const;
172  virtual void update(std::span<const std::shared_ptr<texture_2d>> values, std::size_t index = 0) const;
173  virtual void update(std::span<const std::shared_ptr<texture_3d>> values, std::size_t index = 0) const;
174  virtual void update(std::span<const std::shared_ptr<texture_cube>> values, std::size_t index = 0) const;
176 
177 protected:
183  explicit shader_variable(std::size_t size) noexcept;
184 
185 private:
186  const std::size_t m_size{0};
187 };
188 
189 } // namespace gl
190 
191 #endif // ANTKEEPER_GL_SHADER_VARIABLE_HPP
Shader program variable.
virtual void update(const math::uvec2 &value) const
Updates the value of the variable.
virtual void update(const math::fvec2 &value) const
Updates the value of the variable.
virtual void update(std::span< const math::uvec4 > values, std::size_t index=0) const
Updates the values of one or more elements in an array variable.
virtual void update(const math::ivec4 &value, std::size_t index) const
Updates the value of a single element in an array variable.
virtual void update(std::span< const math::fvec3 > values, std::size_t index=0) const
Updates the values of one or more elements in an array variable.
virtual void update(std::span< const math::uvec2 > values, std::size_t index=0) const
Updates the values of one or more elements in an array variable.
virtual void update(const math::uvec4 &value) const
Updates the value of the variable.
virtual void update(const math::fvec3 &value) const
Updates the value of the variable.
virtual constexpr shader_variable_type type() const noexcept=0
Returns the shader variable data type.
virtual void update(const math::ivec2 &value) const
Updates the value of the variable.
virtual void update(const math::uvec3 &value, std::size_t index) const
Updates the value of a single element in an array variable.
virtual void update(const math::fvec3 &value, std::size_t index) const
Updates the value of a single element in an array variable.
std::size_t size() const noexcept
Returns the number of elements in an array variable, or 1 if the variable is not an array.
virtual void update(const math::uvec3 &value) const
Updates the value of the variable.
virtual void update(const math::fvec4 &value) const
Updates the value of the variable.
virtual void update(const math::ivec4 &value) const
Updates the value of the variable.
virtual void update(const math::uvec4 &value, std::size_t index) const
Updates the value of a single element in an array variable.
virtual void update(const math::fvec2 &value, std::size_t index) const
Updates the value of a single element in an array variable.
virtual void update(bool value) const
Updates the value of the variable.
virtual void update(const math::ivec3 &value, std::size_t index) const
Updates the value of a single element in an array variable.
shader_variable(std::size_t size) noexcept
Constructs a shader variable.
virtual void update(std::span< const math::ivec2 > values, std::size_t index=0) const
Updates the values of one or more elements in an array variable.
virtual void update(std::span< const math::uvec3 > values, std::size_t index=0) const
Updates the values of one or more elements in an array variable.
virtual void update(std::span< const math::ivec3 > values, std::size_t index=0) const
Updates the values of one or more elements in an array variable.
virtual void update(const math::uvec2 &value, std::size_t index) const
Updates the value of a single element in an array variable.
virtual void update(std::span< const math::ivec4 > values, std::size_t index=0) const
Updates the values of one or more elements in an array variable.
virtual void update(std::span< const math::fvec2 > values, std::size_t index=0) const
Updates the values of one or more elements in an array variable.
virtual void update(std::span< const math::fvec4 > values, std::size_t index=0) const
Updates the values of one or more elements in an array variable.
virtual void update(const math::ivec2 &value, std::size_t index) const
Updates the value of a single element in an array variable.
virtual void update(const math::fvec4 &value, std::size_t index) const
Updates the value of a single element in an array variable.
virtual void update(const math::ivec3 &value) const
Updates the value of the variable.
1D texture.
Definition: texture.hpp:73
2D texture.
Definition: texture.hpp:141
3D texture.
Definition: texture.hpp:209
Cube texture.
Definition: texture.hpp:243
Graphics library interface.
Definition: window.hpp:28
shader_variable_type
Shader variable data types.
n by m column-major matrix.
Definition: math/matrix.hpp:44
n-dimensional vector.
Definition: vector.hpp:44