aboutsummaryrefslogtreecommitdiff
path: root/src/opengl_mesh.cc
diff options
context:
space:
mode:
authorccolin2020-12-26 01:21:28 +0100
committerccolin2020-12-26 01:21:28 +0100
commita6d3f3d779b031f8ca70510abe90fade909a8d0d (patch)
tree10f50d6ad13ea0216779b18443bd2958b9f4d79e /src/opengl_mesh.cc
parentc0116528a7b618d185ac688b31e0fa8752924375 (diff)
textures and whatnot i forgot to commit for a while lol
Diffstat (limited to 'src/opengl_mesh.cc')
-rw-r--r--src/opengl_mesh.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/opengl_mesh.cc b/src/opengl_mesh.cc
index cca91da..1d7d1b7 100644
--- a/src/opengl_mesh.cc
+++ b/src/opengl_mesh.cc
@@ -1,19 +1,24 @@
#include "opengl_mesh.hh"
-
#include "opengl_widget.hh"
+#include <QOpenGLFunctions>
+
-OpenGLMesh::OpenGLMesh(QVector<float> verts) {
+OpenGLMesh::OpenGLMesh(QVector<float> verts, QOpenGLTexture *tex)
+ :tex(tex) {
OpenGLWidget::instance->makeCurrent();
QOpenGLFunctions_4_4_Core *glf = OpenGLWidget::instance;
- nverts = verts.size() / 3;
+ nverts = verts.size() / 5;
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->glBufferData(GL_ARRAY_BUFFER, nverts * 5 * sizeof (float), verts.data(), GL_STATIC_DRAW);
+ glf->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof (float), 0);
glf->glEnableVertexAttribArray(0);
+ glf->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof (float), (void *) (3 * sizeof (float)));
+ glf->glEnableVertexAttribArray(1);
+ tex->bind();
glf->glBindVertexArray(0);
OpenGLWidget::instance->doneCurrent();
}