forked from benschreyer/ParticleSimulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShader.h
32 lines (29 loc) · 946 Bytes
/
Shader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include <string>
#include <unordered_map>
#include "glm/glm.hpp"
struct ShaderProgramSource
{
std::string VertexSource;
std::string FragmentSource;
};
class Shader
{
public:
std::string m_FilePath;
std::unordered_map<std::string, int> m_UniformLocationCache;
unsigned int m_RendererID;
public:
Shader(const std::string& filename);
~Shader();
void Bind() const;
void Unbind() const;
void SetUniform4f(const std::string& name, float v0, float v1, float v2, float v3);
void SetUniform1i(const std::string& name, int v0);
void SetUniformMat4f(const std::string& name, const glm::mat4& matrix);
private:
unsigned int CreateShader(const std::string& vertexShader, const std::string& fragmentShader);
ShaderProgramSource ParseShader(const std::string& filepath);
unsigned int CompileShader(unsigned int type, const std::string& source);
int GetUniformLocation(const std::string& name);
};