diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-01-26 21:16:46 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-01-26 21:16:46 +0000 |
commit | 539a7a4a394891e60a289adadc10fbc737c31971 (patch) | |
tree | bfc90954a689d161c5db39ac09c57f3ae771bd2b /game | |
parent | Remove magic number and float flags from texture loader (diff) | |
download | ilt-539a7a4a394891e60a289adadc10fbc737c31971.tar.bz2 ilt-539a7a4a394891e60a289adadc10fbc737c31971.tar.xz ilt-539a7a4a394891e60a289adadc10fbc737c31971.zip |
Use vector sizes when passing terrain to opengl
Diffstat (limited to 'game')
-rw-r--r-- | game/terrain.cpp | 6 |
1 files 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); } |