aboutsummaryrefslogtreecommitdiff
path: root/src/opengl_mesh.cc
diff options
context:
space:
mode:
authorccolin2020-12-22 13:15:23 +0100
committerccolin2020-12-22 13:15:23 +0100
commit7fbe0814d52ba861a02b0560d4e6872845ef241e (patch)
tree1a8f6fd67b5d1606a58c0df00fbab285f1206d36 /src/opengl_mesh.cc
initial commit
Diffstat (limited to 'src/opengl_mesh.cc')
-rw-r--r--src/opengl_mesh.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/opengl_mesh.cc b/src/opengl_mesh.cc
new file mode 100644
index 0000000..cca91da
--- /dev/null
+++ b/src/opengl_mesh.cc
@@ -0,0 +1,19 @@
+#include "opengl_mesh.hh"
+
+#include "opengl_widget.hh"
+
+
+OpenGLMesh::OpenGLMesh(QVector<float> verts) {
+ OpenGLWidget::instance->makeCurrent();
+ QOpenGLFunctions_4_4_Core *glf = OpenGLWidget::instance;
+ nverts = verts.size() / 3;
+ glf->glGenVertexArrays(1, &vao);
+ glf->glGenBuffers(1, &vbo);
+ glf->glBindVertexArray(vao);
+ glf->glBindBuffer(GL_ARRAY_BUFFER, vbo);
+ glf->glBufferData(GL_ARRAY_BUFFER, nverts * 3 * sizeof (GLfloat), verts.data(), GL_STATIC_DRAW);
+ glf->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
+ glf->glEnableVertexAttribArray(0);
+ glf->glBindVertexArray(0);
+ OpenGLWidget::instance->doneCurrent();
+}