--- /dev/null
+#include "backdrop.h"
+
+Backdrop::Backdrop()
+{
+ shader.addShaderFromSourceFile(QGLShader::Vertex, ":/gl/quad.vert");
+ shader.addShaderFromSourceFile(QGLShader::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();
+}
#include <QDebug>
#include "canvas.h"
+#include "backdrop.h"
#include "glmesh.h"
#include "mesh.h"
mesh_shader.addShaderFromSourceFile(QGLShader::Fragment, ":/gl/mesh.frag");
mesh_shader.link();
+ backdrop = new Backdrop();
+
glClearColor(0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST);
}
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ backdrop->draw();
if (mesh) draw_mesh();
}