From ef37119f4e94c83a6357ebc0b94a39e4e53b20d7 Mon Sep 17 00:00:00 2001 From: ccolin Date: Sat, 26 Dec 2020 21:46:12 +0100 Subject: add some sunlight --- src/opengl_mesh.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/opengl_mesh.cc') diff --git a/src/opengl_mesh.cc b/src/opengl_mesh.cc index 1d7d1b7..6e1ff72 100644 --- a/src/opengl_mesh.cc +++ b/src/opengl_mesh.cc @@ -8,16 +8,18 @@ OpenGLMesh::OpenGLMesh(QVector verts, QOpenGLTexture *tex) :tex(tex) { OpenGLWidget::instance->makeCurrent(); QOpenGLFunctions_4_4_Core *glf = OpenGLWidget::instance; - nverts = verts.size() / 5; + nverts = verts.size() / 8; glf->glGenVertexArrays(1, &vao); glf->glGenBuffers(1, &vbo); glf->glBindVertexArray(vao); glf->glBindBuffer(GL_ARRAY_BUFFER, vbo); - 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->glBufferData(GL_ARRAY_BUFFER, nverts * 8 * sizeof (float), verts.data(), GL_STATIC_DRAW); + glf->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof (float), 0); glf->glEnableVertexAttribArray(0); - glf->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof (float), (void *) (3 * sizeof (float))); + glf->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof (float), (void *) (3 * sizeof (float))); glf->glEnableVertexAttribArray(1); + glf->glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof (float), (void *) (6 * sizeof (float))); + glf->glEnableVertexAttribArray(2); tex->bind(); glf->glBindVertexArray(0); OpenGLWidget::instance->doneCurrent(); -- cgit v1.2.3-70-g09d2