//
// Created by lbmas on 4/29/2026.
//

#include "ShaderProgram.h"

#include <fstream>

#include <glad/gl.h>

void ShaderProgram::bind()
{
    glUseProgram(id);
}

void ShaderProgram::unbind()
{
    glUseProgram(0);
}

void ShaderProgram::setFloat(std::string_view name, float value) const
{
    glUniform1f(glGetUniformLocation(id, name.data()), value);
}

void ShaderProgram::setInt(std::string_view name, int value) const
{
    glUniform1i(glGetUniformLocation(id, name.data()), value);
}

void ShaderProgram::setVec3(std::string_view name, const glm::vec3& value) const
{
    glUniform3fv(glGetUniformLocation(id, name.data()), 1, &value[0]);
}

void ShaderProgram::setVec4(std::string_view name, const glm::vec4& value) const
{
    glUniform4fv(glGetUniformLocation(id, name.data()), 1, &value[0]);
}

void ShaderProgram::setMat4(std::string_view name, const glm::mat4& value) const
{
    glUniformMatrix4fv(glGetUniformLocation(id, name.data()), 1, GL_FALSE, &value[0][0]);
}

