From 45baf48db974c66cfdc51f26cee191abbbd89a0b Mon Sep 17 00:00:00 2001 From: hachem Date: Thu, 20 Aug 2026 22:20:49 +0200 Subject: [feat]: reduce renderer abstraction --- src/rendering/framebuffer.h | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'src/rendering/framebuffer.h') diff --git a/src/rendering/framebuffer.h b/src/rendering/framebuffer.h index a01a81b..cf1fbef 100644 --- a/src/rendering/framebuffer.h +++ b/src/rendering/framebuffer.h @@ -3,17 +3,19 @@ #include "core/memory.h" #include "texture.h" +#include + namespace Donut { enum class FramebufferTextureFormat { None = 0, - + RGBA8, RED_INTEGER, - + DEPTH24STENCIL8, - + Depth = DEPTH24STENCIL8 }; @@ -47,19 +49,32 @@ namespace Donut class Framebuffer { public: - virtual ~Framebuffer() = default; + Framebuffer(const FramebufferSpecification& spec); + ~Framebuffer(); - virtual auto bind() -> void = 0; - virtual auto unbind() -> void = 0; + auto bind() -> void; + auto unbind() -> void; - virtual auto resize(uint32_t width, uint32_t height) -> void = 0; - virtual auto read_pixel(uint32_t attachment_index, int x, int y) -> int = 0; + auto resize(uint32_t width, uint32_t height) -> void; + auto read_pixel(uint32_t attachment_index, int x, int y) -> int; - virtual auto clear_attachment(uint32_t attachment_index, int value) -> void = 0; - virtual auto get_color_attachment_renderer_id(uint32_t index = 0) const -> uint32_t = 0; + auto clear_attachment(uint32_t attachment_index, int value) -> void; + auto get_color_attachment_renderer_id(uint32_t index = 0) const -> uint32_t { return m_color_attachments[index]; } - virtual auto get_specification() const -> const FramebufferSpecification& = 0; + auto get_specification() const -> const FramebufferSpecification& { return m_specification; } static auto create(const FramebufferSpecification& spec) -> Ref; + + private: + auto invalidate() -> void; + + uint32_t m_renderer_id = 0; + FramebufferSpecification m_specification; + + std::vector m_color_attachment_specifications; + FramebufferTextureSpecification m_depth_attachment_specification = FramebufferTextureFormat::None; + + std::vector m_color_attachments; + uint32_t m_depth_attachment = 0; }; }; -- cgit v1.3