ecsgame/Rendering/Shader.h

41 lines
1.0 KiB
C
Raw Normal View History

2020-01-03 21:51:30 +01:00
//
// Created by karl on 03.01.20.
//
#ifndef ECSGAME_SHADER_H
#define ECSGAME_SHADER_H
#include <string>
#include <glm/glm.hpp>
2020-01-03 21:51:30 +01:00
class Shader {
public:
/// Program ID
2020-01-03 21:51:30 +01:00
unsigned int ID;
/// Read and build the shader from the files at vertexPath and fragmentPath.
/// Note that an OpenGL context has to be initialized before calling this! Otherwise a SIGSEGV will be thrown.
2020-01-03 21:51:30 +01:00
Shader(const char *vertexPath, const char *fragmentPath);
/// Activate the shader - usually called before rendering.
2020-01-03 21:51:30 +01:00
void use();
/// Set a uniform boolean in the shader
2020-01-03 21:51:30 +01:00
void setBool(const std::string &name, bool value) const;
/// Set a uniform int in the shader
2020-01-03 21:51:30 +01:00
void setInt(const std::string &name, int value) const;
/// Set a uniform float in the shader
2020-01-03 21:51:30 +01:00
void setFloat(const std::string &name, float value) const;
/// Set a uniform mat4 in the shader
void setMat4(const std::string &name, glm::mat4 mat) const;
2020-01-03 21:51:30 +01:00
private:
static void checkCompileErrors(unsigned int shader, const std::string &type);
};
#endif //ECSGAME_SHADER_H