summaryrefslogtreecommitdiffstats
path: root/src/Shader.hpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2019-01-26 08:58:51 +0100
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2019-01-26 08:58:51 +0100
commit9c575f056ef47ef7e8da581164041985749c1676 (patch)
tree6bfec2ad24801c59f516dde644d4afeacf1503d4 /src/Shader.hpp
parentAdded Framebuffer class (diff)
downloadAltCraft-9c575f056ef47ef7e8da581164041985749c1676.tar
AltCraft-9c575f056ef47ef7e8da581164041985749c1676.tar.gz
AltCraft-9c575f056ef47ef7e8da581164041985749c1676.tar.bz2
AltCraft-9c575f056ef47ef7e8da581164041985749c1676.tar.lz
AltCraft-9c575f056ef47ef7e8da581164041985749c1676.tar.xz
AltCraft-9c575f056ef47ef7e8da581164041985749c1676.tar.zst
AltCraft-9c575f056ef47ef7e8da581164041985749c1676.zip
Diffstat (limited to '')
-rw-r--r--src/Shader.hpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Shader.hpp b/src/Shader.hpp
index d6d59eb..b551602 100644
--- a/src/Shader.hpp
+++ b/src/Shader.hpp
@@ -1,6 +1,11 @@
#pragma once
+#include <map>
+#include <vector>
+
#include <GL/glew.h>
+#include <glm/glm.hpp>
+#include <glm/gtc/type_ptr.hpp>
class Shader
{
@@ -13,4 +18,39 @@ public:
void Use();
void Reload();
+};
+
+class NewShader {
+ 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;
+
+ NewShader(const std::string &vertSource, const std::string &fragSource, const std::vector<std::string> &uniformsNames);
+
+ ~NewShader();
+
+ void Activate();
+
+ inline void SetUniform(const std::string &name, int val) {
+ glUniform1i(GetUniformLocation(name), val);
+ }
+
+ inline void SetUniform(const std::string &name, float val) {
+ glUniform1f(GetUniformLocation(name), val);
+ }
+
+ inline void SetUniform(const std::string &name, glm::vec4 val) {
+ glUniform4f(GetUniformLocation(name), val.x, val.y, val.z, val.w);
+ }
+
+ inline void SetUniform(const std::string &name, glm::mat4 val) {
+ glUniformMatrix4fv(GetUniformLocation(name), 1, GL_FALSE, glm::value_ptr(val));
+ }
}; \ No newline at end of file