/*
 * ShaderProgram.h
 *
 *  Created on: 31 janv. 2020
 *      Author: simon
 */

#ifndef RENDER_SHADERS_SHADERPROGRAM_H_
#define RENDER_SHADERS_SHADERPROGRAM_H_

#include <string>
#include <glm/glm.hpp>
#include "render/GL.h"

class ShaderProgram {
public:
	ShaderProgram();
	virtual ~ShaderProgram();
	void start() const;
	void stop() const;
	void loadProgramFile(const std::string& vertexFile, const std::string& fragmentFile);
	void loadProgram(const std::string& vertexSource, const std::string& fragmentSource);

protected:
	virtual void getAllUniformLocation() = 0;
	int getUniformLocation(const std::string& uniformName)const;
	void loadFloat(const int location, const float value)const;
	void loadInt(const int& location, const int& value)const;
	void loadVector(const int& location, const glm::vec2& vector)const;
	void loadVector(const int& location, const glm::vec3& vector)const;
	void loadVector(const int& location, const glm::vec4& vector)const;
	void loadBoolean(const int& location, const bool& value)const;
	void loadMatrix(const int& location, const glm::mat4& matrix);
	void cleanUp() const;

private:
	unsigned int programID;
	unsigned int vertexShaderID;
	unsigned int fragmentShaderID;
	int loadShaderFromFile(const std::string& file, GLenum type);
	int loadShader(const std::string& source, GLenum type);
};

#endif /* RENDER_SHADERS_SHADERPROGRAM_H_ */
