forked from hyperlogic/riftty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shader.h
43 lines (36 loc) · 939 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
36
37
38
39
40
41
42
43
#ifndef __SHADER_H__
#define __SHADER_H__
#include <string>
#include <map>
#include "opengl.h"
class Shader
{
public:
Shader();
virtual ~Shader();
bool compileAndLinkFromFiles(const std::string& vertShaderFilename,
const std::string& fragShaderFilename);
int getUniformLoc(const std::string& uniformName) const;
int getAttribLoc(const std::string& attribName) const;
GLint getProgram() const;
void apply(const Shader* prev) const;
void dump() const;
protected:
void buildVarMaps();
std::string m_vertShaderFilename;
std::string m_fragShaderFilename;
GLint m_vertShader;
GLint m_fragShader;
GLint m_program;
struct Var
{
GLint size;
GLenum type;
GLint loc;
};
typedef std::map<const std::string, Var> VarMap;
VarMap m_uniformVarMap;
VarMap m_attribVarMap;
uint32_t m_attribLocMask;
};
#endif