-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshader_program_set.cpp
81 lines (65 loc) · 1.53 KB
/
shader_program_set.cpp
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
#include "shader_program_set.h"
#include "UsableClass/Macros/macros.h"
typedef ShaderProgramSet cls;
#define RETURN_IS_NOT_INITIALIZE(ret_val) do{\
if (! isInitialize()){\
DEBUG2("ShaderProgramSet - not initialized! ", __PRETTY_FUNCTION__);\
return ret_val;\
}\
}while(0)
cls::ShaderProgramSet(QString vrtxShaderCode,
QString frgmntShaderCode,
const QGLContext *curContext,
QGLFunctions *funcs,
QObject *parent):
QGLShaderProgram(curContext, parent)
{
context = curContext;
f = funcs;
vertexShaderCode = vrtxShaderCode;
fragmentShaderCode = frgmntShaderCode;
vertexShader = new QGLShader(QGLShader::Vertex);
fragmentShader = new QGLShader(QGLShader::Fragment);
}
void cls::initialize()
{
}
void cls::compile()
{
RETURN_IS_NOT_INITIALIZE();
bool ok = true;
ok = vertexShader->compileSourceCode(vertexShaderCode);
if (! ok)
{
DEBUG_NM(vertexShader->log());
}
ok = fragmentShader->compileSourceCode(fragmentShaderCode);
if (! ok)
{
DEBUG_NM(fragmentShader->log());
}
}
bool cls::link()
{
RETURN_IS_NOT_INITIALIZE(false);
addShader(vertexShader);
addShader(fragmentShader);
bool ok = QGLShaderProgram::link();
if (! ok)
{
DEBUG_NM(log());
}
return ok;
}
void cls::use()
{
RETURN_IS_NOT_INITIALIZE();
bind();
}
void cls::deleteShaders()
{
}
bool cls::isInitialize()
{
return ((context != 0) && (f != 0));
}