29 std::shared_ptr<gl::image>
image,
30 std::uint8_t dimensionality,
32 std::uint32_t first_mip_level,
33 std::uint32_t mip_level_count,
34 std::uint32_t first_array_layer,
35 std::uint32_t array_layer_count,
41 throw std::invalid_argument(
"Image view has null image.");
49 const auto format_index = std::to_underlying(
format);
50 const auto gl_internal_format =
gl_format_lut[format_index][0];
52 if (!gl_internal_format)
54 throw std::invalid_argument(
"Image view has unsupported format.");
59 throw std::invalid_argument(
"Image view has zero mip levels.");
64 throw std::out_of_range(
"Image view mip range out of image mip range.");
67 if (!array_layer_count)
69 throw std::invalid_argument(
"Image view has zero array layers.");
74 throw std::out_of_range(
"Image view array layer range out of image array layer range.");
79 throw std::invalid_argument(
"Image view dimensionality must match image dimensionality.");
86 throw std::invalid_argument(
"Cube image views must be constructed from cube-compatible images.");
89 if (array_layer_count % 6 != 0)
91 throw std::invalid_argument(
"Cube image views array layer count must be a multiple of 6.");
96 m_dimensionality = dimensionality;
98 m_first_mip_level = first_mip_level;
99 m_mip_level_count = mip_level_count;
100 m_first_array_layer = first_array_layer;
101 m_array_layer_count = array_layer_count;
104 unsigned int gl_target = 0;
105 switch (dimensionality)
108 gl_target =
is_array() ? GL_TEXTURE_1D_ARRAY : GL_TEXTURE_1D;
114 gl_target =
is_array() ? GL_TEXTURE_CUBE_MAP_ARRAY : GL_TEXTURE_CUBE_MAP;
118 gl_target =
is_array() ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D;
123 gl_target = GL_TEXTURE_3D;
130 glGenTextures(1, &m_gl_texture_name);
135 m_image->m_gl_texture_name,
146 glDeleteTextures(1, &m_gl_texture_name);
151 std::shared_ptr<gl::image>
image,
153 std::uint32_t first_mip_level,
154 std::uint32_t mip_level_count,
155 std::uint32_t first_array_layer
172 std::shared_ptr<gl::image>
image,
174 std::uint32_t first_mip_level,
175 std::uint32_t mip_level_count,
176 std::uint32_t first_array_layer,
177 std::uint32_t array_layer_count
194 std::shared_ptr<gl::image>
image,
196 std::uint32_t first_mip_level,
197 std::uint32_t mip_level_count,
198 std::uint32_t first_array_layer
215 std::shared_ptr<gl::image>
image,
217 std::uint32_t first_mip_level,
218 std::uint32_t mip_level_count,
219 std::uint32_t first_array_layer,
220 std::uint32_t array_layer_count
237 std::shared_ptr<gl::image>
image,
239 std::uint32_t first_mip_level,
240 std::uint32_t mip_level_count
257 std::shared_ptr<gl::image>
image,
259 std::uint32_t first_mip_level,
260 std::uint32_t mip_level_count,
261 std::uint32_t first_array_layer
278 std::shared_ptr<gl::image>
image,
280 std::uint32_t first_mip_level,
281 std::uint32_t mip_level_count,
282 std::uint32_t first_array_layer,
283 std::uint32_t array_layer_count
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)
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)
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)
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)
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)
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)
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)
constexpr bool is_cube() const noexcept
Returns true if the image view is a cube map view, false otherwise.
virtual ~image_view()=0
Destructs an image view.
image_view(const image_view &)=delete
constexpr bool is_array() const noexcept
Returns true if the image view is an array view, false otherwise.
constexpr bool is_cube_compatible() const noexcept
Returns true if the image is cube map compatible, false otherwise.
constexpr std::uint8_t get_dimensionality() const noexcept
Returns the dimensionality of the image.
constexpr std::uint32_t get_mip_levels() const noexcept
Returns the number of levels of detail available for minified sampling of the image.
constexpr format get_format() const noexcept
Returns the format and type of the texel blocks contained in the image.
constexpr std::uint32_t get_array_layers() const noexcept
Returns the number of layers in the image.
Graphics library interface.
format
Image and vertex formats.
image_view_flag
Image flags.
constexpr GLenum gl_format_lut[][3]
Maps gl::format to OpenGL internal format, base format, and pixel type.