summaryrefslogtreecommitdiffstats
path: root/src/Shader.hpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Shader.hpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/Shader.hpp b/src/Shader.hpp
index b551602..d70d394 100644
--- a/src/Shader.hpp
+++ b/src/Shader.hpp
@@ -7,34 +7,21 @@
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
-class Shader
-{
-private:
- const GLchar *vertex;
- const GLchar *fragment;
-public:
- GLuint Program;
- Shader(const GLchar* vertexPath, const GLchar* fragmentPath, const GLchar* geometryPath = nullptr);
- void Use();
-
- void Reload();
-};
-
-class NewShader {
+class Shader {
std::map<std::string, GLuint> uniforms;
GLuint program = 0;
GLuint GetUniformLocation(const std::string &name);
public:
- NewShader(const NewShader &) = delete;
- NewShader(NewShader &&other) = delete;
- NewShader &operator=(const NewShader &) = delete;
- NewShader &operator=(NewShader &&other) = delete;
+ Shader(const Shader &) = delete;
+ Shader(Shader &&other) = delete;
+ Shader &operator=(const Shader &) = delete;
+ Shader &operator=(Shader &&other) = delete;
- NewShader(const std::string &vertSource, const std::string &fragSource, const std::vector<std::string> &uniformsNames);
+ Shader(const std::string &vertSource, const std::string &fragSource, const std::vector<std::string> &uniformsNames);
- ~NewShader();
+ ~Shader();
void Activate();
@@ -46,6 +33,14 @@ public:
glUniform1f(GetUniformLocation(name), val);
}
+ inline void SetUniform(const std::string &name, glm::vec2 val) {
+ glUniform2f(GetUniformLocation(name), val.x, val.y);
+ }
+
+ inline void SetUniform(const std::string &name, glm::vec3 val) {
+ glUniform3f(GetUniformLocation(name), val.x, val.y, val.z);
+ }
+
inline void SetUniform(const std::string &name, glm::vec4 val) {
glUniform4f(GetUniformLocation(name), val.x, val.y, val.z, val.w);
}