forked from michal1000w/GPUSmoke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShader.h
33 lines (29 loc) · 926 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
33
#pragma once
#include "Common.h"
#include <string>
#include <unordered_map>
struct ShaderProgramSource {
std::string VertexSource;
std::string FragmentSource;
};
class Shader {
private:
unsigned int m_RendererID;
std::string m_FilePath;
//cache for uniforms
std::unordered_map<std::string, int> m_UniformLocationCache;
public:
Shader(const std::string& filepath);
~Shader();
void Bind() const;
void UnBind() const;
void SetUniform1i(const std::string& name, int value);
void SetUniform1f(const std::string& name, float value);
void SetUniform4f(const std::string& name, float v0, float v1, float v2, float v3);
private:
int GetUniformLocation(const std::string& name);
unsigned int CompileShader(unsigned int type, const std::string& source);
unsigned int CreateShader(const std::string& vertexShader,
const std::string& fragmentShader);
ShaderProgramSource ParseShader(const std::string& filepath);
};