Antkeeper  0.0.1
framebuffer.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_FRAMEBUFFER_HPP
21 #define ANTKEEPER_GL_FRAMEBUFFER_HPP
22 
25 #include <array>
26 #include <cstdint>
27 #include <span>
28 #include <vector>
29 
30 namespace gl {
31 
36 {
37 public:
45  framebuffer(std::span<const framebuffer_attachment> attachments, std::uint32_t width, std::uint32_t height);
46 
48  ~framebuffer();
49 
58  void resize(std::uint32_t width, std::uint32_t height);
59 
61  [[nodiscard]] inline constexpr const std::vector<framebuffer_attachment>& attachments() const noexcept
62  {
63  return m_attachments;
64  }
65 
67  [[nodiscard]] inline constexpr const std::array<std::uint32_t, 2>& dimensions() const noexcept
68  {
69  return m_dimensions;
70  }
71 
73  [[nodiscard]] inline constexpr std::uint32_t width() const noexcept
74  {
75  return m_dimensions[0];
76  }
77 
79  [[nodiscard]] inline constexpr std::uint32_t height() const noexcept
80  {
81  return m_dimensions[1];
82  }
83 
84 private:
85  friend class pipeline;
86 
87  std::vector<framebuffer_attachment> m_attachments;
88  std::array<std::uint32_t, 2> m_dimensions{0, 0};
89  unsigned int m_gl_named_framebuffer{0};
90 };
91 
92 } // namespace gl
93 
94 #endif // ANTKEEPER_GL_FRAMEBUFFER_HPP
framebuffer(std::span< const framebuffer_attachment > attachments, std::uint32_t width, std::uint32_t height)
Constructs a framebuffer.
Definition: framebuffer.cpp:26
~framebuffer()
Destroys a framebuffer.
constexpr const std::array< std::uint32_t, 2 > & dimensions() const noexcept
Returns the dimensions of the framebuffer.
Definition: framebuffer.hpp:67
constexpr const std::vector< framebuffer_attachment > & attachments() const noexcept
Returns the framebuffer attachments.
Definition: framebuffer.hpp:61
constexpr std::uint32_t width() const noexcept
Returns the width of the framebuffer.
Definition: framebuffer.hpp:73
constexpr std::uint32_t height() const noexcept
Returns the height of the framebuffer.
Definition: framebuffer.hpp:79
void resize(std::uint32_t width, std::uint32_t height)
Resizes the framebuffer.
Graphics pipeline interface.
Definition: pipeline.hpp:48
Graphics library interface.
Definition: window.hpp:28