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

#ifndef COLORRACE_STATICSHADER_H
#define COLORRACE_STATICSHADER_H
#include <functional>

#include "loader/models/Material.h"
#include "utils/openglWrapper/shader/ShaderProgram.h"
#include "utils/openglWrapper/shader/UniformValue.h"


namespace engine {
    class StaticShader : public ShaderProgram {
    public:
        StaticShader() : ShaderProgram("assets/shaders/basic.vert", "assets/shaders/basic.frag") {
            storeAllUniformLocations({
                std::ref(transformationMatrix),
                std::ref(projectionMatrix),
                std::ref(viewMatrix),
                std::ref(opacity),
                std::ref(lightPosition),
                std::ref(lightColor),
                std::ref(cameraPosition),
                std::ref(shininess),
                std::ref(highlightColor),
                std::ref(highlightIntensity)
            });
        };

        void loadTransformationMatrix(const glm::mat4& matrix) {
            transformationMatrix.load(matrix);
        }

        void loadProjectionMatrix(const glm::mat4& matrix) {
            projectionMatrix.load(matrix);
        }

        void loadViewMatrix(const glm::mat4& matrix) {
            viewMatrix.load(matrix);
        }

        void loadMaterial(const Material& material) {
            //shininess.load(material.getShininess());
            //opacity.load(material.getOpacity());
        }

        void loadHighlightEffect(glm::vec3 color, float intensity) {
            highlightIntensity.load(intensity);
            highlightColor.load(color);
        }

        void loadLight(const glm::vec3& position, const glm::vec3& color) {
            lightPosition.load(position);
            lightColor.load(color);
        }

        void loadCameraPosition(const glm::vec3& position) {
            cameraPosition.load(position);
        }
    private:
        engine::UniformValue<glm::mat4> transformationMatrix{"transformationMatrix"};
        engine::UniformValue<glm::mat4> projectionMatrix{"projectionMatrix"};
        engine::UniformValue<glm::mat4> viewMatrix{"viewMatrix"};
        engine::UniformValue<float> shininess{"shininess"};
        engine::UniformValue<float> opacity{"opacity"};
        engine::UniformValue<glm::vec3> lightPosition{"lightPosition"};
        engine::UniformValue<glm::vec3> lightColor{"lightColor"};
        engine::UniformValue<glm::vec3> cameraPosition{"cameraPosition"};
        engine::UniformValue<glm::vec3> highlightColor{"highlightColor"};
        engine::UniformValue<float> highlightIntensity{"highlightIntensity"};
    };
}


#endif //COLORRACE_STATICSHADER_H
