//
// Created by sebastian on 29.07.26.
//

#ifndef COLORRACE_GLSTATECACHE_H
#define COLORRACE_GLSTATECACHE_H
#include "glm/vec4.hpp"

namespace engine {
    class GLStateCache {
    public:
        static void init(); // einmal nach GLAD-Init aufrufen, um Startzustand zu setzen

        static void setFaceCulling(bool enabled, bool frontFace);
        static void setAntialiasing(bool enabled);
        static void setAlphaBlending(bool enabled);
        static void setAdditiveBlending(bool enabled);
        static void setDepthTest(bool enabled);
        static void setDepthWriting(bool enabled);
        static void setScissorTest(bool enabled, int x = 0, int y = 0, int width = 0, int height = 0);
        static void setWireframe(bool enabled);

        static void bindTexture2D(unsigned int textureId, int slot);

        static void clearColorBuffer();
        static void clearDepthBuffer();
        static void clearFrameBuffer();
        static void clearFrameBuffer(glm::vec4 color);
    private:
        inline static bool s_cullingFaces = false;
        inline static bool s_frontFaceCulling = false;
        inline static bool s_antialiasing = false;
        inline static bool s_alphaBlending = false;
        inline static bool s_additiveBlending = false;
        inline static bool s_depthTest = false;
        inline static bool s_depthWriting = true;
        inline static bool s_scissorTest = false;
        inline static bool s_wireframe = false;
        inline static int s_scissorBounds[4] = {0, 0, 0, 0};
        inline static glm::vec4 s_clearColor = {0.0f, 0.0f, 0.0f, 1.0f};
    };
}

#endif //COLORRACE_GLSTATECACHE_H
