Antkeeper  0.0.1
texture.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_TEXTURE_HPP
21 #define ANTKEEPER_GL_TEXTURE_HPP
22 
23 #include <engine/gl/image-view.hpp>
24 #include <engine/gl/sampler.hpp>
25 #include <memory>
26 
27 namespace gl {
28 
32 class texture
33 {
34 public:
42  inline texture(std::shared_ptr<gl::sampler> sampler) noexcept:
43  m_sampler(sampler)
44  {}
45 
46  constexpr texture() noexcept = default;
48 
54  inline void set_sampler(std::shared_ptr<gl::sampler> sampler)
55  {
56  m_sampler = sampler;
57  }
58 
60  [[nodiscard]] inline constexpr const std::shared_ptr<sampler>& get_sampler() const noexcept
61  {
62  return m_sampler;
63  }
64 
65 private:
66  std::shared_ptr<sampler> m_sampler;
67 };
68 
72 class texture_1d: public texture
73 {
74 public:
77  inline texture_1d(std::shared_ptr<image_view_1d> image_view, std::shared_ptr<gl::sampler> sampler) noexcept:
79  m_image_view(image_view)
80  {}
81 
82  constexpr texture_1d() noexcept = default;
84 
88  inline void set_image_view(std::shared_ptr<gl::image_view_1d> image_view)
89  {
90  m_image_view = image_view;
91  }
92 
94  [[nodiscard]] inline constexpr const std::shared_ptr<image_view_1d>& get_image_view() const noexcept
95  {
96  return m_image_view;
97  }
98 
99 private:
100  std::shared_ptr<image_view_1d> m_image_view;
101 };
102 
107 {
108 public:
111  inline texture_1d_array(std::shared_ptr<image_view_1d_array> image_view, std::shared_ptr<gl::sampler> sampler) noexcept:
112  texture(sampler),
113  m_image_view(image_view)
114  {}
115 
116  constexpr texture_1d_array() noexcept = default;
118 
122  inline void set_image_view(std::shared_ptr<gl::image_view_1d_array> image_view)
123  {
124  m_image_view = image_view;
125  }
126 
128  [[nodiscard]] inline constexpr const std::shared_ptr<image_view_1d_array>& get_image_view() const noexcept
129  {
130  return m_image_view;
131  }
132 
133 private:
134  std::shared_ptr<image_view_1d_array> m_image_view;
135 };
136 
140 class texture_2d: public texture
141 {
142 public:
145  inline texture_2d(std::shared_ptr<image_view_2d> image_view, std::shared_ptr<gl::sampler> sampler) noexcept:
146  texture(sampler),
147  m_image_view(image_view)
148  {}
149 
150  constexpr texture_2d() noexcept = default;
152 
156  inline void set_image_view(std::shared_ptr<gl::image_view_2d> image_view)
157  {
158  m_image_view = image_view;
159  }
160 
162  [[nodiscard]] inline constexpr const std::shared_ptr<image_view_2d>& get_image_view() const noexcept
163  {
164  return m_image_view;
165  }
166 
167 private:
168  std::shared_ptr<image_view_2d> m_image_view;
169 };
170 
175 {
176 public:
179  inline texture_2d_array(std::shared_ptr<image_view_2d_array> image_view, std::shared_ptr<gl::sampler> sampler) noexcept:
180  texture(sampler),
181  m_image_view(image_view)
182  {}
183 
184  constexpr texture_2d_array() noexcept = default;
186 
190  inline void set_image_view(std::shared_ptr<gl::image_view_2d_array> image_view)
191  {
192  m_image_view = image_view;
193  }
194 
196  [[nodiscard]] inline constexpr const std::shared_ptr<image_view_2d_array>& get_image_view() const noexcept
197  {
198  return m_image_view;
199  }
200 
201 private:
202  std::shared_ptr<image_view_2d_array> m_image_view;
203 };
204 
208 class texture_3d: public texture
209 {
210 public:
213  inline texture_3d(std::shared_ptr<image_view_3d> image_view, std::shared_ptr<gl::sampler> sampler) noexcept:
214  texture(sampler),
215  m_image_view(image_view)
216  {}
217 
218  constexpr texture_3d() noexcept = default;
220 
224  inline void set_image_view(std::shared_ptr<gl::image_view_3d> image_view)
225  {
226  m_image_view = image_view;
227  }
228 
230  [[nodiscard]] inline constexpr const std::shared_ptr<image_view_3d>& get_image_view() const noexcept
231  {
232  return m_image_view;
233  }
234 
235 private:
236  std::shared_ptr<image_view_3d> m_image_view;
237 };
238 
242 class texture_cube: public texture
243 {
244 public:
247  inline texture_cube(std::shared_ptr<image_view_cube> image_view, std::shared_ptr<gl::sampler> sampler) noexcept:
248  texture(sampler),
249  m_image_view(image_view)
250  {}
251 
252  constexpr texture_cube() noexcept = default;
254 
258  inline void set_image_view(std::shared_ptr<gl::image_view_cube> image_view)
259  {
260  m_image_view = image_view;
261  }
262 
264  [[nodiscard]] inline constexpr const std::shared_ptr<image_view_cube>& get_image_view() const noexcept
265  {
266  return m_image_view;
267  }
268 
269 private:
270  std::shared_ptr<image_view_cube> m_image_view;
271 };
272 
277 {
278 public:
281  inline texture_cube_array(std::shared_ptr<image_view_cube_array> image_view, std::shared_ptr<gl::sampler> sampler) noexcept:
282  texture(sampler),
283  m_image_view(image_view)
284  {}
285 
286  constexpr texture_cube_array() noexcept = default;
288 
292  inline void set_image_view(std::shared_ptr<gl::image_view_cube_array> image_view)
293  {
294  m_image_view = image_view;
295  }
296 
298  [[nodiscard]] inline constexpr const std::shared_ptr<image_view_cube_array>& get_image_view() const noexcept
299  {
300  return m_image_view;
301  }
302 
303 private:
304  std::shared_ptr<image_view_cube_array> m_image_view;
305 };
306 
307 } // namespace gl
308 
309 #endif // ANTKEEPER_GL_TEXTURE_HPP
1D image array view.
Definition: image-view.hpp:190
1D image view.
Definition: image-view.hpp:173
2D image array view.
Definition: image-view.hpp:225
2D image view.
Definition: image-view.hpp:208
3D image view.
Definition: image-view.hpp:243
Cube image array view.
Definition: image-view.hpp:276
Cube image view.
Definition: image-view.hpp:259
Image view.
Definition: image-view.hpp:34
Sampler object.
Definition: sampler.hpp:35
1D texture array.
Definition: texture.hpp:107
constexpr texture_1d_array() noexcept=default
Constructs a texture.
constexpr const std::shared_ptr< image_view_1d_array > & get_image_view() const noexcept
Returns the image view.
Definition: texture.hpp:128
texture_1d_array(std::shared_ptr< image_view_1d_array > image_view, std::shared_ptr< gl::sampler > sampler) noexcept
Constructs a texture.
Definition: texture.hpp:111
void set_image_view(std::shared_ptr< gl::image_view_1d_array > image_view)
Sets the image view.
Definition: texture.hpp:122
1D texture.
Definition: texture.hpp:73
texture_1d(std::shared_ptr< image_view_1d > image_view, std::shared_ptr< gl::sampler > sampler) noexcept
Constructs a texture.
Definition: texture.hpp:77
void set_image_view(std::shared_ptr< gl::image_view_1d > image_view)
Sets the image view.
Definition: texture.hpp:88
constexpr texture_1d() noexcept=default
Constructs a texture.
constexpr const std::shared_ptr< image_view_1d > & get_image_view() const noexcept
Returns the image view.
Definition: texture.hpp:94
2D texture array.
Definition: texture.hpp:175
constexpr const std::shared_ptr< image_view_2d_array > & get_image_view() const noexcept
Returns the image view.
Definition: texture.hpp:196
texture_2d_array(std::shared_ptr< image_view_2d_array > image_view, std::shared_ptr< gl::sampler > sampler) noexcept
Constructs a texture.
Definition: texture.hpp:179
constexpr texture_2d_array() noexcept=default
Constructs a texture.
void set_image_view(std::shared_ptr< gl::image_view_2d_array > image_view)
Sets the image view.
Definition: texture.hpp:190
2D texture.
Definition: texture.hpp:141
texture_2d(std::shared_ptr< image_view_2d > image_view, std::shared_ptr< gl::sampler > sampler) noexcept
Constructs a texture.
Definition: texture.hpp:145
constexpr texture_2d() noexcept=default
Constructs a texture.
constexpr const std::shared_ptr< image_view_2d > & get_image_view() const noexcept
Returns the image view.
Definition: texture.hpp:162
void set_image_view(std::shared_ptr< gl::image_view_2d > image_view)
Sets the image view.
Definition: texture.hpp:156
3D texture.
Definition: texture.hpp:209
texture_3d(std::shared_ptr< image_view_3d > image_view, std::shared_ptr< gl::sampler > sampler) noexcept
Constructs a texture.
Definition: texture.hpp:213
void set_image_view(std::shared_ptr< gl::image_view_3d > image_view)
Sets the image view.
Definition: texture.hpp:224
constexpr const std::shared_ptr< image_view_3d > & get_image_view() const noexcept
Returns the image view.
Definition: texture.hpp:230
constexpr texture_3d() noexcept=default
Constructs a texture.
Cube texture array.
Definition: texture.hpp:277
constexpr texture_cube_array() noexcept=default
Constructs a texture.
texture_cube_array(std::shared_ptr< image_view_cube_array > image_view, std::shared_ptr< gl::sampler > sampler) noexcept
Constructs a texture.
Definition: texture.hpp:281
void set_image_view(std::shared_ptr< gl::image_view_cube_array > image_view)
Sets the image view.
Definition: texture.hpp:292
constexpr const std::shared_ptr< image_view_cube_array > & get_image_view() const noexcept
Returns the image view.
Definition: texture.hpp:298
Cube texture.
Definition: texture.hpp:243
texture_cube(std::shared_ptr< image_view_cube > image_view, std::shared_ptr< gl::sampler > sampler) noexcept
Constructs a texture.
Definition: texture.hpp:247
constexpr const std::shared_ptr< image_view_cube > & get_image_view() const noexcept
Returns the image view.
Definition: texture.hpp:264
constexpr texture_cube() noexcept=default
Constructs a texture.
void set_image_view(std::shared_ptr< gl::image_view_cube > image_view)
Sets the image view.
Definition: texture.hpp:258
Image view and sampler object pair.
Definition: texture.hpp:33
texture(std::shared_ptr< gl::sampler > sampler) noexcept
Constructs a texture.
Definition: texture.hpp:42
constexpr texture() noexcept=default
Constructs a texture.
void set_sampler(std::shared_ptr< gl::sampler > sampler)
Sets the sampler object.
Definition: texture.hpp:54
constexpr const std::shared_ptr< sampler > & get_sampler() const noexcept
Returns the sampler object.
Definition: texture.hpp:60
Graphics library interface.
Definition: window.hpp:28