#ifndef OPENGL_FRAMEBUFFER_HPP
#define OPENGL_FRAMEBUFFER_HPP

#include "core.hpp"
#include <renderer/framebuffer.hpp>

#include <cstdint>
#include <vector>

namespace OpenEngine {
    class OpenGLFramebuffer : public FrameBuffer
	{
	public:
		OpenGLFramebuffer(const FramebufferSpecification& spec);
		virtual ~OpenGLFramebuffer();

		void Invalidate();

		virtual void Bind() override;
		virtual void Unbind() override;

        virtual void Resize(uint32_t width, uint32_t height) override;
        virtual int ReadPixel(uint32_t index, int x, int y) override;
        virtual void ClearBufferI(int index, int value) override;

		virtual uint32_t GetColorAttachmentRendererID(uint32_t index = 0) const override {
            OE_CORE_ASSERT(index < color_attachment_ids.size(), "Index is greater than color attachment count.");
            return color_attachment_ids[index];
        }

		virtual const FramebufferSpecification& GetSpecification() const override { return specs; }

	private:
		uint32_t id = 0;
		FramebufferSpecification specs;

        std::vector<FramebufferTextureSpecification> color_attachment_specs;
        FramebufferTextureSpecification depth_attachment_specs = FramebufferTextureFormat::None;

        std::vector<uint32_t> color_attachment_ids;
        uint32_t depth_attachment_id;
	};

}

#endif // OPENGL_FRAMEBUFFER_HPP
