#pragma once
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <unordered_map>
#include "Debugger.h"
#include "GLM/glm.hpp"


struct ShaderProgramSource
{
	std::string vertex_source;
	std::string fragment_source;
};


class Shader
{
private:
	unsigned int m_rendererID;
	std::string m_filepath;
	std::unordered_map<std::string, int> m_uniform_location_chache; // Chacing for uniforms

public:
	Shader(const std::string& filepath);
	~Shader();

	void Bind() const;
	void UnBind() const;

	// Set uniforms
	void SetUniform1i(const std::string& name, int value);
	void SetUniform1f(const std::string& name, float value);
	void SetUniform3f(const std::string& name, float v0, float v1, float v2);
	void SetUniform4f(const std::string& name, float v0, float v1, float v2, float v3);
	void SetUniformMatrix4f(const std::string& name, const glm::mat4& matrix);
	
private:
	ShaderProgramSource ParseShader(const std::string& file_path);
	unsigned int CompileShader(const unsigned int shader_type, const std::string& source);
	unsigned int CreateShader(const std::string& vertex_shader_string, const std::string& fragment_shader_string);
	
	int GetUniformLocation(const std::string& name);
};

