-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathShaderFactory.h
55 lines (48 loc) · 1.7 KB
/
ShaderFactory.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#include <string>
#include <glad/glad.h>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "file_manager.h"
#include <vector>
enum class ShaderName {
DEFAULT,
TEXT,
DOODLE,
UI
};
struct Shader {
GLuint program;
std::vector<GLuint> uniformLocations;
};
class ShaderFactory {
public:
void createAllShaderPrograms();
/// <summary>
/// Use the default shader. This includes calling the glUseProgram and loading all the uniforms.
/// </summary>
/// <param name="modelMat"></param>
/// <param name="viewMat"></param>
/// <param name="projectMat"></param>
/// <param name="color"></param>
void useDefaultShader(glm::mat4 modelMat, glm::mat4 viewMat, glm::mat4 projectMat, glm::vec3 color, bool colorOnly);
/// <summary>
/// Use the text shader. This includes calling the glUseProgram and loading all the uniforms.
/// </summary>
/// <param name="modelMat"></param>
/// <param name="viewMat"></param>
/// <param name="projectMat"></param>
/// <param name="color"></param>
void useTextShader(glm::mat4 modelMat, glm::mat4 projectMat, glm::vec3 color);
/// <summary>
/// Use the text shader. This includes calling the glUseProgram and loading all the uniforms.
/// </summary>
/// <param name="modelMat"></param>
/// <param name="viewMat"></param>
/// <param name="projectMat"></param>
/// <param name="color"></param>
void useDoodleShader(glm::mat4 modelMat, glm::mat4 viewMat, glm::mat4 projectMat, float time);
private:
std::map<ShaderName, Shader> shaders;
void createShaderProgram(ShaderName name, std::string vertPath, std::string fragPath, std::string uniforms[], int amount);
};