1#ifndef OE_RENDER_FRAMEBUFFER_H
2#define OE_RENDER_FRAMEBUFFER_H
10#include "../util/non_copyable.h"
14 enum TargetBuffer :
int
16 COLOR_BUFFER = 0x4000,
17 DEPTH_BUFFER = 0x0100,
18 STENCIL_BUFFER = 0x0400,
28 std::span<glm::ivec2> dimensions;
55 Framebuffer(
const glm::ivec2& dimensions);
64 _width(dimensions.x), _height(dimensions.y),
75 _width = other._width;
76 _height = other._height;
83 Framebuffer(
const uint32_t width,
const uint32_t height);
90 std::shared_ptr<Texture>
addColorAttachment(
const uint32_t attachment_level = 0,
const uint32_t internal_format = 0,
const uint32_t format = 0,
const uint32_t type = 0,
91 const uint32_t filter = 0,
const uint8_t max_mips = 1
98 void addDepthAttachment(
const uint32_t format = 0,
const uint32_t type = 0,
const uint32_t filter = 0);
111 void setTextureAttachment(
const uint32_t attachment_level, std::shared_ptr<Texture> texture,
const int32_t mip_level = 0);
126 void clearContents(
const glm::vec4& color = glm::vec4(0.f),
const int& target = 0);
149 return _color_attachments.at(attachment_level);
158 return _depth_attachment;
174 const Framebuffer* src,
175 const glm::ivec4& src_bounds = glm::ivec4(0),
176 const glm::ivec4& target_bounds = glm::ivec4(0),
177 const TargetBuffer& type = TargetBuffer::ALL,
178 const uint8_t color_attachment_src = 0,
179 const uint8_t color_attachment_dest = 0,
180 const bool usefilter =
false
197 const glm::ivec4& src_bounds = glm::ivec4(0),
198 const glm::ivec4& target_bounds = glm::ivec4(0),
199 const TargetBuffer& type = TargetBuffer::ALL,
200 const uint8_t color_attachment_src = 0,
201 const uint8_t color_attachment_dest = 0,
202 const bool usefilter =
false
210 void copyFrom(Framebuffer* source,
const TargetBuffer& type = TargetBuffer::ALL)
220 void blitToDefault(
const uint8_t color_attachment_src = 0,
const bool& usefilter =
false)
const;
233 return {_width, _height};
236 #ifdef OXYGEN_ENGINE_DEBUG_VALIDATE_ORDERED_OPERATIONS
237 bool is_between_begin_end =
false;
241 void _update_color_attachments();
242 void _clear_all_color_attachments(
const glm::vec4& color);
247 const glm::ivec4& src_bounds,
248 const glm::ivec4& target_bounds,
249 const TargetBuffer& type,
250 const uint8_t color_attachment_src,
251 const uint8_t color_attachment_dest,
255 std::map<uint32_t, std::shared_ptr<Texture>> _color_attachments;
256 std::shared_ptr<Texture> _depth_attachment = {};
259 uint32_t _height = 0;
Definition framebuffer.h:53
void blitTo(Framebuffer *target, const glm::ivec4 &src_bounds=glm::ivec4(0), const glm::ivec4 &target_bounds=glm::ivec4(0), const TargetBuffer &type=TargetBuffer::ALL, const uint8_t color_attachment_src=0, const uint8_t color_attachment_dest=0, const bool usefilter=false) const
Framebuffer(const glm::ivec2 &dimensions, uint32_t id)
Definition framebuffer.h:63
void addDepthAttachment(const uint32_t format=0, const uint32_t type=0, const uint32_t filter=0)
void blitToDefault(const uint8_t color_attachment_src=0, const bool &usefilter=false) const
void blitFrom(const Framebuffer *src, const glm::ivec4 &src_bounds=glm::ivec4(0), const glm::ivec4 &target_bounds=glm::ivec4(0), const TargetBuffer &type=TargetBuffer::ALL, const uint8_t color_attachment_src=0, const uint8_t color_attachment_dest=0, const bool usefilter=false)
const std::shared_ptr< Texture > & getDepthAttachment() const
Definition framebuffer.h:156
const std::shared_ptr< Texture > & getColorAttachment(const uint32_t attachment_level) const
Definition framebuffer.h:147
void clearContents(const glm::vec4 &color=glm::vec4(0.f), const int &target=0)
void setDepthAttachment(std::shared_ptr< Texture > texture)
void setTextureAttachment(const uint32_t attachment_level, std::shared_ptr< Texture > texture, const int32_t mip_level=0)
friend void generateMultipleFramebuffers(MultipleFramebufferInfo, std::vector< Framebuffer > &)
Generate multiple framebuffers at once.
void beginRender(const bool resize_viewport=true)
std::shared_ptr< Texture > addColorAttachment(const uint32_t attachment_level=0, const uint32_t internal_format=0, const uint32_t format=0, const uint32_t type=0, const uint32_t filter=0, const uint8_t max_mips=1)
glm::ivec2 getDimensions() const noexcept
Definition framebuffer.h:231
void setTextureAttachment(const uint32_t attachment_level, Texture *texture, const int32_t mip_level=0)
void copyFrom(Framebuffer *source, const TargetBuffer &type=TargetBuffer::ALL)
Definition framebuffer.h:210
Prevent class to be copied.
Definition non_copyable.h:12
Render related abstractions (Shader, Framebuffer, Cubemaps, Textures).
Definition opengl.h:12
void generateMultipleFramebuffers(MultipleFramebufferInfo input, std::vector< Framebuffer > &result)
Generate multiple framebuffers at once.
structure used to create multiple Framebuffer at once
Definition framebuffer.h:27