#pragma once

#include "shader/Shader.hpp"
#include "buffer/VertexBuffer.hpp"
#include "buffer/IndexBuffer.hpp"
#include "interfaces/IRenderer.hpp"
#include <vector>

namespace TSE::OpenGL
{
    class DefaultRendererOpenGL : public IRenderer
    {
    private:
        uint vao = 0;
        VertexBuffer vbo;
        Shader* lastShader;
        IndexBuffer* ibo = nullptr; //idk why this needs to be a pointer but not the vbo, just don't question it. it works MAK 28.05.25
        ushort* iboData;
        int indexCount = 0;
        ushort iboOffset = 0;
        float* bufferPointer;
        ushort* indexBufferPointer;
    public:
        DefaultRendererOpenGL(Shader& shader);
        ~DefaultRendererOpenGL();

        void InitShader(Shader& s, bool init = false);
        void End() override;
        void Flush() override;
        void Begin() override;
        void Submit(const Transformable& trans, TransformationStack& stack) override;
        void Submit(const Transformable& trans, IShader* shader, TransformationStack& stack) override;

    private:
        static void Redraw(IRenderer& rnd);
        bool CreateIbo();
    };
} // namespace TSE::OpenGL
