-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasicShaderProgram.cpp
83 lines (70 loc) · 2.11 KB
/
BasicShaderProgram.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
82
83
#include "BasicShaderProgram.h"
#include "BasicVertexShader.h"
#include "BasicFragmentShader.h"
BasicShaderProgram::BasicShaderProgram(QObject *parent) :
QGLShaderProgram(parent)
{
_vertexShader = new BasicVertexShader();
_fragmentShader = new BasicFragmentShader();
addShader(_vertexShader);
addShader(_fragmentShader);
link();
_vertexAttributeLocation = attributeLocation("vertex");
enableAttributeArray(_vertexAttributeLocation);
_normalAttributeLocation = attributeLocation("normal");
enableAttributeArray(_normalAttributeLocation);
_texCoordsAttributeLocation = attributeLocation("texCoordsAttr");
enableAttributeArray(_texCoordsAttributeLocation);
_mvpUniformLocation = uniformLocation("mvp");
_mUniformLocation = uniformLocation("m");
_vUniformLocation = uniformLocation("v");
_colorUniformLocation = uniformLocation("color");
_hasTextureUniformLocation = uniformLocation("hasTexture");
_diffuseCoefUniformLocation = uniformLocation("diffuseCoef");
_specularCoefUniformLocation = uniformLocation("specularCoef");
}
BasicShaderProgram::~BasicShaderProgram()
{
delete _vertexShader;
delete _fragmentShader;
}
int BasicShaderProgram::vertexAttributeLocation() const
{
return _vertexAttributeLocation;
}
int BasicShaderProgram::normalAttributeLocation() const
{
return _normalAttributeLocation;
}
int BasicShaderProgram::texCoordsAttributeLocation() const
{
return _texCoordsAttributeLocation;
}
int BasicShaderProgram::mvpUniformLocation() const
{
return _mvpUniformLocation;
}
int BasicShaderProgram::mUniformLocation() const
{
return _mUniformLocation;
}
int BasicShaderProgram::vUniformLocation() const
{
return _vUniformLocation;
}
int BasicShaderProgram::colorUniformLocation() const
{
return _colorUniformLocation;
}
int BasicShaderProgram::hasTextureUniformLocation() const
{
return _hasTextureUniformLocation;
}
int BasicShaderProgram::diffuseCoefUniformLocation() const
{
return _diffuseCoefUniformLocation;
}
int BasicShaderProgram::specularCoefUniformLocation() const
{
return _specularCoefUniformLocation;
}