Antkeeper  0.0.1
image-view.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_IMAGE_VIEW_HPP
21 #define ANTKEEPER_GL_IMAGE_VIEW_HPP
22 
23 #include <engine/gl/image.hpp>
25 #include <cstdint>
26 #include <memory>
27 
28 namespace gl {
29 
34 {
35 public:
37  virtual ~image_view() = 0;
38 
39  image_view(const image_view&) = delete;
40  image_view(image_view&&) = delete;
41  image_view& operator=(const image_view&) = delete;
43 
45  [[nodiscard]] inline constexpr const std::shared_ptr<image>& get_image() const noexcept
46  {
47  return m_image;
48  }
49 
51  [[nodiscard]] inline constexpr format get_format() const noexcept
52  {
53  return m_format;
54  }
55 
57  [[nodiscard]] inline constexpr std::uint32_t get_first_mip_level() const noexcept
58  {
59  return m_first_mip_level;
60  }
61 
63  [[nodiscard]] inline constexpr std::uint32_t get_mip_level_count() const noexcept
64  {
65  return m_mip_level_count;
66  }
67 
69  [[nodiscard]] inline constexpr std::uint32_t get_first_array_layer() const noexcept
70  {
71  return m_first_array_layer;
72  }
73 
75  [[nodiscard]] inline constexpr std::uint32_t get_array_layer_count() const noexcept
76  {
77  return m_array_layer_count;
78  }
79 
81  [[nodiscard]] inline constexpr std::uint8_t get_dimensionality() const noexcept
82  {
83  return m_dimensionality;
84  }
85 
87  [[nodiscard]] inline constexpr bool is_1d() const noexcept
88  {
89  return m_dimensionality == 1;
90  }
91 
93  [[nodiscard]] inline constexpr bool is_2d() const noexcept
94  {
95  return m_dimensionality == 2;
96  }
97 
99  [[nodiscard]] inline constexpr bool is_3d() const noexcept
100  {
101  return m_dimensionality == 3;
102  }
103 
105  [[nodiscard]] inline constexpr bool is_array() const noexcept
106  {
107  return m_flags & std::to_underlying(image_view_flag::array);
108  }
109 
111  [[nodiscard]] inline constexpr bool is_cube() const noexcept
112  {
113  return m_flags & std::to_underlying(image_view_flag::cube);
114  }
115 
116 protected:
139  image_view
140  (
141  std::shared_ptr<gl::image> image,
142  std::uint8_t dimensionality,
144  std::uint32_t first_mip_level,
145  std::uint32_t mip_level_count,
146  std::uint32_t first_array_layer,
147  std::uint32_t array_layer_count,
148  std::uint8_t flags
149  );
150 
151 private:
152  friend class framebuffer;
153  friend class gl_shader_texture_1d;
154  friend class gl_shader_texture_2d;
155  friend class gl_shader_texture_3d;
157 
158  unsigned int m_gl_texture_name{0};
159  std::shared_ptr<image> m_image;
160  std::uint8_t m_dimensionality{0};
161  format m_format{format::undefined};
162  std::uint32_t m_first_mip_level{0};
163  std::uint32_t m_mip_level_count{0};
164  std::uint32_t m_first_array_layer{0};
165  std::uint32_t m_array_layer_count{0};
166  std::uint8_t m_flags{0};
167 };
168 
173 {
174 public:
177  (
178  std::shared_ptr<gl::image> image,
180  std::uint32_t first_mip_level = 0,
181  std::uint32_t mip_level_count = 1,
182  std::uint32_t first_array_layer = 0
183  );
184 };
185 
190 {
191 public:
194  (
195  std::shared_ptr<gl::image> image,
197  std::uint32_t first_mip_level = 0,
198  std::uint32_t mip_level_count = 1,
199  std::uint32_t first_array_layer = 0,
200  std::uint32_t array_layer_count = 1
201  );
202 };
203 
208 {
209 public:
212  (
213  std::shared_ptr<gl::image> image,
215  std::uint32_t first_mip_level = 0,
216  std::uint32_t mip_level_count = 1,
217  std::uint32_t first_array_layer = 0
218  );
219 };
220 
225 {
226 public:
229  (
230  std::shared_ptr<gl::image> image,
232  std::uint32_t first_mip_level = 0,
233  std::uint32_t mip_level_count = 1,
234  std::uint32_t first_array_layer = 0,
235  std::uint32_t array_layer_count = 1
236  );
237 };
238 
243 {
244 public:
247  (
248  std::shared_ptr<gl::image> image,
250  std::uint32_t first_mip_level = 0,
251  std::uint32_t mip_level_count = 1
252  );
253 };
254 
259 {
260 public:
263  (
264  std::shared_ptr<gl::image> image,
266  std::uint32_t first_mip_level = 0,
267  std::uint32_t mip_level_count = 1,
268  std::uint32_t first_array_layer = 0
269  );
270 };
271 
276 {
277 public:
280  (
281  std::shared_ptr<gl::image> image,
283  std::uint32_t first_mip_level = 0,
284  std::uint32_t mip_level_count = 1,
285  std::uint32_t first_array_layer = 0,
286  std::uint32_t array_layer_count = 6
287  );
288 };
289 
290 } // namespace gl
291 
292 #endif // ANTKEEPER_GL_IMAGE_VIEW_HPP
1-dimensional texture shader variable implementation using OpenGL.
2-dimensional texture shader variable implementation using OpenGL.
3-dimensional texture shader variable implementation using OpenGL.
Cube texture shader variable implementation using OpenGL.
1D image array view.
Definition: image-view.hpp:190
image_view_1d_array(std::shared_ptr< gl::image > image, gl::format format=gl::format::undefined, std::uint32_t first_mip_level=0, std::uint32_t mip_level_count=1, std::uint32_t first_array_layer=0, std::uint32_t array_layer_count=1)
Definition: image-view.cpp:171
1D image view.
Definition: image-view.hpp:173
image_view_1d(std::shared_ptr< gl::image > image, gl::format format=gl::format::undefined, std::uint32_t first_mip_level=0, std::uint32_t mip_level_count=1, std::uint32_t first_array_layer=0)
Definition: image-view.cpp:150
2D image array view.
Definition: image-view.hpp:225
image_view_2d_array(std::shared_ptr< gl::image > image, gl::format format=gl::format::undefined, std::uint32_t first_mip_level=0, std::uint32_t mip_level_count=1, std::uint32_t first_array_layer=0, std::uint32_t array_layer_count=1)
Definition: image-view.cpp:214
2D image view.
Definition: image-view.hpp:208
image_view_2d(std::shared_ptr< gl::image > image, gl::format format=gl::format::undefined, std::uint32_t first_mip_level=0, std::uint32_t mip_level_count=1, std::uint32_t first_array_layer=0)
Definition: image-view.cpp:193
3D image view.
Definition: image-view.hpp:243
image_view_3d(std::shared_ptr< gl::image > image, gl::format format=gl::format::undefined, std::uint32_t first_mip_level=0, std::uint32_t mip_level_count=1)
Definition: image-view.cpp:236
Cube image array view.
Definition: image-view.hpp:276
image_view_cube_array(std::shared_ptr< gl::image > image, gl::format format=gl::format::undefined, std::uint32_t first_mip_level=0, std::uint32_t mip_level_count=1, std::uint32_t first_array_layer=0, std::uint32_t array_layer_count=6)
Definition: image-view.cpp:277
Cube image view.
Definition: image-view.hpp:259
image_view_cube(std::shared_ptr< gl::image > image, gl::format format=gl::format::undefined, std::uint32_t first_mip_level=0, std::uint32_t mip_level_count=1, std::uint32_t first_array_layer=0)
Definition: image-view.cpp:256
Image view.
Definition: image-view.hpp:34
constexpr bool is_1d() const noexcept
Returns true if the image view is 1D, false otherwise.
Definition: image-view.hpp:87
constexpr bool is_cube() const noexcept
Returns true if the image view is a cube map view, false otherwise.
Definition: image-view.hpp:111
constexpr std::uint32_t get_first_array_layer() const noexcept
Returns the first array layer accessible to the view.
Definition: image-view.hpp:69
image_view(image_view &&)=delete
virtual ~image_view()=0
Destructs an image view.
Definition: image-view.cpp:144
constexpr std::uint8_t get_dimensionality() const noexcept
Returns the dimensionality of the image view.
Definition: image-view.hpp:81
constexpr std::uint32_t get_mip_level_count() const noexcept
Returns the number of mipmap levels accessible to the view.
Definition: image-view.hpp:63
image_view(const image_view &)=delete
constexpr bool is_array() const noexcept
Returns true if the image view is an array view, false otherwise.
Definition: image-view.hpp:105
constexpr format get_format() const noexcept
Returns the format and type used to interpret texel blocks of the image.
Definition: image-view.hpp:51
constexpr bool is_2d() const noexcept
Returns true if the image view is 2D, false otherwise.
Definition: image-view.hpp:93
constexpr const std::shared_ptr< image > & get_image() const noexcept
Returns the image on which the view was created.
Definition: image-view.hpp:45
constexpr std::uint32_t get_array_layer_count() const noexcept
Returns the number of array layers accessible to the view.
Definition: image-view.hpp:75
image_view & operator=(const image_view &)=delete
constexpr std::uint32_t get_first_mip_level() const noexcept
Returns the first mipmap level accessible to the view.
Definition: image-view.hpp:57
image_view & operator=(image_view &&)=delete
constexpr bool is_3d() const noexcept
Returns true if the image view is 3D, false otherwise.
Definition: image-view.hpp:99
Graphics library interface.
Definition: window.hpp:28
format
Image and vertex formats.
Definition: format.hpp:29
@ cube
Cube map view.
@ array
Image array view.