blob: 2696f19c34294a62a59f7f62009d8fc5892cad1a (
plain)
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
|
#ifndef SHADER_H
#define SHADER_H
#include <string>
#include <unordered_map>
#include <wx/string.h>
#include <glm\glm.hpp>
struct ShaderSource
{
std::string vertexShader = "";
std::string fragmentShader = "";
};
class Shader
{
public:
Shader(const std::string& filepath);
~Shader();
void Bind() const;
void Unbind() const;
//Set uniforms
void SetUniform4f(const std::string& name, float v0, float v1, float v2, float v3);
void SetUniform2f(const std::string& name, float v0, float v1);
void SetUniformMatrix4fv(const std::string& name, const glm::mat4& matrix);
void SetUniform1f(const std::string& name, const float& value);
protected:
unsigned int GetUniformLocation(const std::string& name);
unsigned int CompileShader(unsigned int type, const wxString& source) const;
unsigned int CreateShader(std::string& vertexShader, std::string& fragmentShader) const;
ShaderSource ParseShader(const wxString& filepath) const;
unsigned int m_rendererID;
wxString m_filepath;
std::unordered_map<std::string, int> m_uniformLocationCache;
};
#endif // SHADER_H
|