From 539a7a4a394891e60a289adadc10fbc737c31971 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 26 Jan 2021 21:16:46 +0000 Subject: Use vector sizes when passing terrain to opengl --- game/terrain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/game/terrain.cpp b/game/terrain.cpp index 1669a62..85a6d32 100644 --- a/game/terrain.cpp +++ b/game/terrain.cpp @@ -48,7 +48,7 @@ Terrain::Terrain() : glGenBuffers(2, m_vertexArrayBuffers.data()); glBindBuffer(GL_ARRAY_BUFFER, m_vertexArrayBuffers[0]); - glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * verticesCount, vertices.data(), GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * vertices.size(), vertices.data(), GL_STATIC_DRAW); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void *)offsetof(Vertex, pos)); @@ -60,7 +60,7 @@ Terrain::Terrain() : glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void *)offsetof(Vertex, normal)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_vertexArrayBuffers[1]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices[0]) * indicesCount, indices.data(), GL_STATIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices[0]) * indices.size(), indices.data(), GL_STATIC_DRAW); glBindVertexArray(0); } @@ -81,7 +81,7 @@ Terrain::render(const Shader & shader) const texture->Bind(); glBindVertexArray(m_vertexArrayObject); - glDrawElementsBaseVertex(GL_TRIANGLES, indicesCount, GL_UNSIGNED_INT, nullptr, 0); + glDrawElementsBaseVertex(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, nullptr, 0); glBindVertexArray(0); } -- cgit v1.2.3