]> git.sur5r.net Git - fstl/blob - src/backdrop.cpp
Change tabulation
[fstl] / src / backdrop.cpp
1 #include "backdrop.h"
2
3 Backdrop::Backdrop()
4 {
5     shader.addShaderFromSourceFile(QGLShader::Vertex, ":/gl/quad.vert");
6     shader.addShaderFromSourceFile(QGLShader::Fragment, ":/gl/quad.frag");
7     shader.link();
8
9     float vbuf[] = {
10         -1, -1, 0.00, 0.10, 0.15,
11         -1,  1, 0.03, 0.21, 0.26,
12          1, -1, 0.00, 0.12, 0.18,
13          1,  1, 0.06, 0.26, 0.30};
14
15     vertices.create();
16     vertices.bind();
17     vertices.allocate(vbuf, sizeof(vbuf));
18     vertices.release();
19 }
20
21 void Backdrop::draw()
22 {
23     shader.bind();
24     vertices.bind();
25
26     const GLuint vp = shader.attributeLocation("vertex_position");
27     const GLuint vc = shader.attributeLocation("vertex_color");
28
29     glEnableVertexAttribArray(vp);
30     glEnableVertexAttribArray(vc);
31
32     glVertexAttribPointer(vp, 2, GL_FLOAT, false,
33                           5 * sizeof(GLfloat), 0);
34     glVertexAttribPointer(vc, 3, GL_FLOAT, false,
35                           5 * sizeof(GLfloat),
36                           (GLvoid*)(2 * sizeof(GLfloat)));
37
38     glDrawArrays(GL_TRIANGLE_STRIP, 0, 8);
39
40     vertices.release();
41     shader.release();
42 }