summaryrefslogtreecommitdiffstats
path: root/src/Shader.hpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2019-01-26 10:54:29 +0100
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2019-01-26 10:58:17 +0100
commitf8af4c44d17b94ab814f1784060388afd7a24e03 (patch)
treee0c8e06c209fe964b03caae362169facecd3c949 /src/Shader.hpp
parentImplemented new Shader class (diff)
downloadAltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.tar
AltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.tar.gz
AltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.tar.bz2
AltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.tar.lz
AltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.tar.xz
AltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.tar.zst
AltCraft-f8af4c44d17b94ab814f1784060388afd7a24e03.zip
Diffstat (limited to 'src/Shader.hpp')
-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);
}