-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbackdrop.cpp
44 lines (34 loc) · 1.12 KB
/
backdrop.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
#include "backdrop.h"
Backdrop::Backdrop()
{
initializeOpenGLFunctions();
shader.addShaderFromSourceFile(QOpenGLShader::Vertex, ":/gl/quad.vert");
shader.addShaderFromSourceFile(QOpenGLShader::Fragment, ":/gl/quad.frag");
shader.link();
float vbuf[] = {
-1, -1, 0.00, 0.10, 0.15,
-1, 1, 0.03, 0.21, 0.26,
1, -1, 0.00, 0.12, 0.18,
1, 1, 0.06, 0.26, 0.30};
vertices.create();
vertices.bind();
vertices.allocate(vbuf, sizeof(vbuf));
vertices.release();
}
void Backdrop::draw()
{
shader.bind();
vertices.bind();
const GLuint vp = shader.attributeLocation("vertex_position");
const GLuint vc = shader.attributeLocation("vertex_color");
glEnableVertexAttribArray(vp);
glEnableVertexAttribArray(vc);
glVertexAttribPointer(vp, 2, GL_FLOAT, false,
5 * sizeof(GLfloat), 0);
glVertexAttribPointer(vc, 3, GL_FLOAT, false,
5 * sizeof(GLfloat),
(GLvoid*)(2 * sizeof(GLfloat)));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 8);
vertices.release();
shader.release();
}