-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathShader.h
More file actions
38 lines (28 loc) · 1.22 KB
/
Copy pathShader.h
File metadata and controls
38 lines (28 loc) · 1.22 KB
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
36
37
38
#pragma once
#include <glad.h>
#include <vector>
#include "Vector.h"
class Shader {
public:
GLuint ID = 0;
Shader() = default;
Shader(const char* vertexCode, const char* fragmentCode);
Shader(const char* computeCode);
void use() const;
// utility uniform functions
void setBool(const char* name, int len, bool value) const;
// ------------------------------------------------------------------------
void setInt(const char* name, int len, int value) const;
// ------------------------------------------------------------------------
void setFloat(const char* name, int len, float value) const;
// ------------------------------------------------------------------------
void setVec2(const char* name, int len, const vec2& value) const;
void setVec2(const char* name, int len, float x, float y) const;
// ------------------------------------------------------------------------
void setVec3(const char* name, int len, const vec3& value) const;
void setVec3(const char* name, int len, float x, float y, float z) const;
private:
mutable std::vector<int> uniformCache;
void cacheUniforms();
GLint getUniformLocation(const char* uniformName, int len) const;
};