From 9c575f056ef47ef7e8da581164041985749c1676 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Sat, 26 Jan 2019 12:58:51 +0500 Subject: Implemented new Shader class --- src/Shader.hpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/Shader.hpp') 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 +#include + #include +#include +#include class Shader { @@ -13,4 +18,39 @@ public: void Use(); void Reload(); +}; + +class NewShader { + std::map 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 &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 -- cgit v1.2.3