1
0
Fork 0
2019-ecs/Source/Graphics/Shader.hpp

34 lines
591 B
C++
Raw Normal View History

2019-08-03 19:29:42 +00:00
#pragma once
#include "GlLoader.hpp"
#include <string>
class Mat44;
class Vec3;
class Shader
{
public:
Shader(std::string const& vertexPath, std::string const& fragmentPath);
void Activate();
template<typename T>
void SetUniform(const std::string& name, const T& value)
{
if constexpr (std::is_same_v<T, Mat44>)
{
glUniformMatrix4fv(glGetUniformLocation(mId, name.c_str()), 1, GL_TRUE, (GLfloat*)value.m);
}
else if constexpr (std::is_same_v<T, Vec3>)
{
glUniform3fv(glGetUniformLocation(mId, name.c_str()), 1, (GLfloat*)&value);
}
}
private:
GLuint mId;
};