-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathShader.h
More file actions
executable file
·46 lines (37 loc) · 1.17 KB
/
Shader.h
File metadata and controls
executable file
·46 lines (37 loc) · 1.17 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
39
40
41
42
43
44
45
46
#pragma once
#include "GL/glew.h"
#include "glm/glm.hpp"
#include <fstream>
#include <map>
#include <sstream>
#include <string>
namespace g3d {
enum {
SHADER_PHONG_LIGHT,
SHADER_MAX,
};
class Shader {
std::map<std::string, GLint> uniformMap;
GLuint program;
std::string vertexShaderData, fragmentShaderData;
std::string readFile(const std::string &fileName);
void checkProgramErrors();
void checkShaderErrors(GLuint shader);
public:
Shader();
Shader(const std::string &vertexFileName,
const std::string &fragmentFileName);
~Shader();
GLint getUniformLocation(const GLchar *name);
bool loadFromFile(const std::string &vertexFileName,
const std::string &fragmentFileName);
void fromMemory(const std::string &vertexData,
const std::string &fragmentData);
template <class T> void setUniform(const GLchar *name, const T &value);
void setTextureSlots(const GLchar *name, const GLint &slot);
GLuint compile();
static Shader *defaultPhongLightingShader();
void use();
};
extern g3d::Shader *shaders[g3d::SHADER_MAX];
};