aboutsummaryrefslogtreecommitdiff
path: root/src/opengl_mesh.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl_mesh.cc')
-rw-r--r--src/opengl_mesh.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/opengl_mesh.cc b/src/opengl_mesh.cc
index 01a73ff..a1f5a23 100644
--- a/src/opengl_mesh.cc
+++ b/src/opengl_mesh.cc
@@ -4,8 +4,9 @@
#include <QOpenGLFunctions>
-OpenGLMesh::OpenGLMesh(QVector<float> verts, QOpenGLTexture *tex)
- :tex(tex) {
+OpenGLMesh::OpenGLMesh(QVector<float> verts, QOpenGLTexture *tex, QOpenGLShaderProgram *program)
+ :tex(tex),
+ program(program) {
OpenGLWidget::instance->makeCurrent();
QOpenGLExtraFunctions *glf = OpenGLWidget::instance;
nverts = verts.size() / 8;
@@ -24,3 +25,13 @@ OpenGLMesh::OpenGLMesh(QVector<float> verts, QOpenGLTexture *tex)
glf->glBindVertexArray(0);
OpenGLWidget::instance->doneCurrent();
}
+
+
+void OpenGLMesh::draw(QOpenGLExtraFunctions *f, const QMatrix4x4 &mat) const {
+ program->bind();
+ program->setUniformValue("model", mat);
+ f->glBindVertexArray(vao);
+ tex->bind();
+ f->glDrawArrays(GL_TRIANGLES, 0, nverts);
+ tex->release();
+}