47 lines
1.4 KiB
C++
Executable File
47 lines
1.4 KiB
C++
Executable File
/*
|
|
* 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(unsigned int location, float value) const;
|
|
void loadInt(unsigned int location, int value) const;
|
|
void loadVector(unsigned int location, const glm::vec2& vector) const;
|
|
void loadVector(unsigned int location, const glm::vec3& vector) const;
|
|
void loadVector(unsigned int location, const glm::vec4& vector) const;
|
|
void loadBoolean(unsigned int location, bool value) const;
|
|
void loadMatrix(unsigned int location, const glm::mat4& matrix) const;
|
|
void cleanUp() const;
|
|
|
|
private:
|
|
unsigned int m_ProgramID;
|
|
unsigned int m_VertexShaderID;
|
|
unsigned int m_FragmentShaderID;
|
|
|
|
unsigned int loadShaderFromFile(const std::string& file, GLenum type);
|
|
unsigned int loadShader(const std::string& source, GLenum type);
|
|
};
|
|
|
|
#endif /* RENDER_SHADERS_SHADERPROGRAM_H_ */
|