summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/scenary/foliage.cpp10
-rw-r--r--game/vehicles/railVehicleClass.cpp28
2 files changed, 10 insertions, 28 deletions
diff --git a/game/scenary/foliage.cpp b/game/scenary/foliage.cpp
index e54dfbd..0913c6e 100644
--- a/game/scenary/foliage.cpp
+++ b/game/scenary/foliage.cpp
@@ -26,10 +26,7 @@ Foliage::render(const SceneShader & shader) const
if (texture) {
texture->bind();
}
- glBindVertexArray(instanceVAO);
- glDrawElementsInstanced(
- bodyMesh->type(), bodyMesh->count(), GL_UNSIGNED_INT, nullptr, static_cast<GLsizei>(count));
- glBindVertexArray(0);
+ bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count));
}
}
@@ -38,9 +35,6 @@ Foliage::shadows(const ShadowMapper & mapper) const
{
if (const auto count = instances.count()) {
mapper.dynamicPointInst.use();
- glBindVertexArray(instanceVAO);
- glDrawElementsInstanced(
- bodyMesh->type(), bodyMesh->count(), GL_UNSIGNED_INT, nullptr, static_cast<GLsizei>(count));
- glBindVertexArray(0);
+ bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count));
}
}
diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp
index 66d7ba3..82a442e 100644
--- a/game/vehicles/railVehicleClass.cpp
+++ b/game/vehicles/railVehicleClass.cpp
@@ -51,16 +51,10 @@ RailVehicleClass::render(const SceneShader & shader) const
texture->bind();
}
shader.basicInst.use();
- glBindVertexArray(instanceVAO);
- glDrawElementsInstanced(
- bodyMesh->type(), bodyMesh->count(), GL_UNSIGNED_INT, nullptr, static_cast<GLsizei>(count));
- glBindVertexArray(instancesBogiesVAO.front());
- glDrawElementsInstanced(bogies.front()->type(), bogies.front()->count(), GL_UNSIGNED_INT, nullptr,
- static_cast<GLsizei>(instancesBogies.front().count()));
- glBindVertexArray(instancesBogiesVAO.back());
- glDrawElementsInstanced(bogies.back()->type(), bogies.back()->count(), GL_UNSIGNED_INT, nullptr,
- static_cast<GLsizei>(instancesBogies.back().count()));
- glBindVertexArray(0);
+ bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count));
+ bogies.front()->DrawInstanced(
+ instancesBogiesVAO.front(), static_cast<GLsizei>(instancesBogies.front().count()));
+ bogies.back()->DrawInstanced(instancesBogiesVAO.back(), static_cast<GLsizei>(instancesBogies.back().count()));
}
}
@@ -69,15 +63,9 @@ RailVehicleClass::shadows(const ShadowMapper & mapper) const
{
if (const auto count = instancesBody.count()) {
mapper.dynamicPointInst.use();
- glBindVertexArray(instanceVAO);
- glDrawElementsInstanced(
- bodyMesh->type(), bodyMesh->count(), GL_UNSIGNED_INT, nullptr, static_cast<GLsizei>(count));
- glBindVertexArray(instancesBogiesVAO.front());
- glDrawElementsInstanced(bogies.front()->type(), bogies.front()->count(), GL_UNSIGNED_INT, nullptr,
- static_cast<GLsizei>(instancesBogies.front().count()));
- glBindVertexArray(instancesBogiesVAO.back());
- glDrawElementsInstanced(bogies.back()->type(), bogies.back()->count(), GL_UNSIGNED_INT, nullptr,
- static_cast<GLsizei>(instancesBogies.back().count()));
- glBindVertexArray(0);
+ bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count));
+ bogies.front()->DrawInstanced(
+ instancesBogiesVAO.front(), static_cast<GLsizei>(instancesBogies.front().count()));
+ bogies.back()->DrawInstanced(instancesBogiesVAO.back(), static_cast<GLsizei>(instancesBogies.back().count()));
}
}