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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
#ifndef __LIBJIN_SHADER_H
#define __LIBJIN_SHADER_H
#include "../../jin_configuration.h"
#if LIBJIN_MODULES_RENDER
#include <string>
#include <map>
#include "../../3rdparty/GLee/GLee.h"
#include "../color.h"
#include "../texture.h"
#include "../canvas.h"
#include "base.shader.h"
namespace jin
{
namespace graphics
{
///
/// @details Built in shader program.
///
class Shader
{
public:
///
/// @brief Create shader program from source code.
///
/// @param source The shader source code.
///
static Shader* createShader(const std::string& source);
///
/// @brief Get current shader.
///
static inline Shader* getCurrentShader() { return CurrentShader; }
///
/// @brief Unuse current shader
///
static void unuse();
///
///
///
virtual ~Shader();
///
///
///
void use();
///
///
///
void sendFloat(const char* name, float number);
///
///
///
void sendTexture(const char* name, const Texture* image);
///
///
///
void sendInt(const char* name, int value);
///
///
///
void sendVec2(const char* name, float x, float y);
///
///
///
void sendVec3(const char* name, float x, float y, float z);
///
///
///
void sendVec4(const char* name, float x, float y, float z, float w);
///
///
///
void sendCanvas(const char* name, const Canvas* canvas);
///
///
///
void sendColor(const char* name, const Color* col);
///
///
///
void sendMatrix4(const char* name, const math::Matrix* mat4);
///
///
///
void bindVertexPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers);
///
///
///
void bindUVPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers);
protected:
static Shader* CurrentShader;
GLint claimTextureUnit(const std::string& name);
Shader(const std::string& program);
bool compile(const std::string& program);
GLuint mPID;
GLint mCurrentTextureUnit;
std::map<std::string, GLint> mTextureUnits;
};
} // namespace graphics
} // namespace jin
#endif // LIBJIN_MODULES_RENDER
#endif // __LIBJIN_SHADER_H
|