-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shader.h
37 lines (32 loc) · 839 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
#pragma once
#include <GL/glew.h>
#include <GL/glut.h>
#include <string>
#include <memory>
#include "Exception.h"
class Shader {
class ShaderProgram;
public:
enum ShaderType {
VertexShader = GL_VERTEX_SHADER,
FragmentShader = GL_FRAGMENT_SHADER,
};
class ShaderException : public Exception {
public:
ShaderException(std::string & message) : Exception(message) {};
};
private:
struct ShaderIdHolder {
GLuint shaderId;
ShaderIdHolder(GLuint shaderId);
~ShaderIdHolder();
};
ShaderType shaderType;
std::shared_ptr<ShaderIdHolder> shaderIdHolder;
Shader(ShaderType shaderType, GLuint shaderId);
public:
static Shader compile(ShaderType shaderType, const std::string & code);
ShaderType getShaderType() const;
GLuint getShaderId() const;
virtual void initAttribute(const ShaderProgram & shaderProgram) const;
};