From 5b361d81dbd2af0d0e99b9eb1adebea76ff05db0 Mon Sep 17 00:00:00 2001 From: hachem Date: Thu, 20 Aug 2026 02:27:02 +0200 Subject: [chore]: MASSIVE refactor + more vulkan bs --- src/rendering/framebuffer.h | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/rendering/framebuffer.h (limited to 'src/rendering/framebuffer.h') diff --git a/src/rendering/framebuffer.h b/src/rendering/framebuffer.h new file mode 100644 index 0000000..a01a81b --- /dev/null +++ b/src/rendering/framebuffer.h @@ -0,0 +1,65 @@ +#pragma once + +#include "core/memory.h" +#include "texture.h" + +namespace Donut +{ + enum class FramebufferTextureFormat + { + None = 0, + + RGBA8, + RED_INTEGER, + + DEPTH24STENCIL8, + + Depth = DEPTH24STENCIL8 + }; + + struct FramebufferTextureSpecification + { + FramebufferTextureSpecification() = default; + FramebufferTextureSpecification(FramebufferTextureFormat format) + : texture_format(format) {} + + FramebufferTextureFormat texture_format = FramebufferTextureFormat::None; + }; + + struct FramebufferAttachmentSpecification + { + FramebufferAttachmentSpecification() = default; + FramebufferAttachmentSpecification(std::initializer_list attachments) + : attachments(attachments) {} + + std::vector attachments; + }; + + struct FramebufferSpecification + { + uint32_t Width = 0, Height = 0; + FramebufferAttachmentSpecification attachments; + uint32_t Samples = 1; + + bool SwapChainTarget = false; + }; + + class Framebuffer + { + public: + virtual ~Framebuffer() = default; + + virtual auto bind() -> void = 0; + virtual auto unbind() -> void = 0; + + 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; + + 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; + + virtual auto get_specification() const -> const FramebufferSpecification& = 0; + + static auto create(const FramebufferSpecification& spec) -> Ref; + }; +}; -- cgit v1.3