-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathShader.h
35 lines (29 loc) · 876 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
34
35
#pragma once
#include <string>
// hashtable
#include <unordered_map>
struct ShaderProgramSource
{
std::string vertex_shader_source;
std::string fragment_shader_source;
};
class Shader
{
private:
std::string m_filepath;
unsigned int m_renderer_id;
std::unordered_map<std::string, int> m_uniform_location_cache;
public:
Shader (const std::string& filepath);
~Shader();
// actually use but every other class uses bind
void bind();
void unbind();
// set uniforms
void set_uniform_4f(const std::string& name, float v0, float v1, float v2, float v3);
private:
ShaderProgramSource parse_shader(const std::string& file_path);
unsigned int compile_shader(unsigned int type, const std::string& source);
unsigned int create_shader(const std::string& vertex_shader, const std::string& fragment_shader);
unsigned int get_uniform_location(const std::string& name);
};