#pragma once #include #include #include namespace extra2d { // 前向声明 class GLTexture; /** * @brief OpenGL 帧缓冲实现 */ class GLFramebuffer : public RHIFramebuffer { public: GLFramebuffer(); explicit GLFramebuffer(const RenderPassDesc& desc); ~GLFramebuffer() override; bool create(); void destroy(); void bind() override; void unbind() override; uint32_t getColorAttachmentCount() const override; TextureHandle getColorAttachment(uint32_t index) const override; TextureHandle getDepthStencilAttachment() const override; uint32_t getWidth() const override { return width_; } uint32_t getHeight() const override { return height_; } bool hasDepthStencil() const override; bool isValid() const override; bool isDefault() const override; void setSize(uint32_t width, uint32_t height); GLuint getGLFramebuffer() const { return framebuffer_; } const RenderPassDesc& getDesc() const { return desc_; } void clear(ClearFlags flags, const Color& color, float depth, uint8_t stencil); private: RenderPassDesc desc_; GLuint framebuffer_; uint32_t width_; uint32_t height_; std::vector> colorAttachments_; std::unique_ptr depthStencilAttachment_; }; } // namespace extra2d