Antkeeper  0.0.1
texture-cube.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_CUBE_HPP
21 #define ANTKEEPER_GL_TEXTURE_CUBE_HPP
22 
23 #include <engine/gl/texture.hpp>
25 
26 namespace gl {
27 
31 class texture_cube: public texture
32 {
33 public:
42  [[nodiscard]] static cube_map_layout infer_cube_map_layout(std::uint16_t w, std::uint16_t h) noexcept;
43 
53  [[nodiscard]] static std::uint16_t infer_cube_map_face_size(cube_map_layout layout, std::uint16_t w, std::uint16_t h) noexcept;
54 
56  texture_cube(std::uint16_t width, std::uint16_t height, gl::pixel_type type = gl::pixel_type::uint_8, gl::pixel_format format = gl::pixel_format::rgba, gl::transfer_function transfer_function = gl::transfer_function::linear, const std::byte* data = nullptr);
57 
58  [[nodiscard]] inline constexpr texture_type get_texture_type() const noexcept override
59  {
60  return texture_type::cube;
61  }
62 
64  void resize(std::uint16_t width, std::uint16_t height, gl::pixel_type type, gl::pixel_format format, gl::transfer_function transfer_function, const std::byte* data) override;
65 
73  void resize(std::uint16_t width, std::uint16_t height, const std::byte* data);
74 
76  virtual void set_wrapping(gl::texture_wrapping wrap_s, texture_wrapping wrap_t, texture_wrapping wrap_r);
77 
79  [[nodiscard]] inline std::uint16_t get_face_size() const noexcept
80  {
81  return m_face_size;
82  }
83 
84 private:
85  void resized();
86 
87  std::uint16_t m_face_size{};
88 };
89 
90 } // namespace gl
91 
92 #endif // ANTKEEPER_GL_TEXTURE_CUBE_HPP
A cube texture which can be uploaded to shaders via shader inputs.
texture_cube(std::uint16_t width, std::uint16_t height, gl::pixel_type type=gl::pixel_type::uint_8, gl::pixel_format format=gl::pixel_format::rgba, gl::transfer_function transfer_function=gl::transfer_function::linear, const std::byte *data=nullptr)
Constructs a cube texture.
virtual void set_wrapping(gl::texture_wrapping wrap_s, texture_wrapping wrap_t, texture_wrapping wrap_r)
Sets the texture wrapping modes.
static cube_map_layout infer_cube_map_layout(std::uint16_t w, std::uint16_t h) noexcept
Infers the layout of a cube map from its aspect ratio.
std::uint16_t get_face_size() const noexcept
Returns the edge length of the cube texture faces, in pixels.
void resize(std::uint16_t width, std::uint16_t height, gl::pixel_type type, gl::pixel_format format, gl::transfer_function transfer_function, const std::byte *data) override
Resizes the texture.
static std::uint16_t infer_cube_map_face_size(cube_map_layout layout, std::uint16_t w, std::uint16_t h) noexcept
Infers the edge length of a cube map face from its layout and resolution.
constexpr texture_type get_texture_type() const noexcept override
Returns the texture type.
Abstract base class for 1D, 2D, 3D, and cube textures which can be uploaded to shaders via shader inp...
Definition: texture.hpp:47
Graphics library interface.
transfer_function
Texture sampling transfer function.
@ linear
Linear transfer function.
pixel_format
@ rgba
Red, green, blue, alpha.
pixel_type
Definition: pixel-type.hpp:28
texture_type
Texture types.
@ cube
Cube texture.
cube_map_layout
Cube map layout types.
Text and typography.
Definition: bitmap-font.cpp:24