From c96f4f89905f96492bdfc87bc3d45bf5cbd7b005 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 26 Apr 2023 01:42:45 +0100 Subject: Draw rail vehicle classes and foliage with new mesh instance helper --- game/vehicles/railVehicleClass.cpp | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'game/vehicles') 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(count)); - glBindVertexArray(instancesBogiesVAO.front()); - glDrawElementsInstanced(bogies.front()->type(), bogies.front()->count(), GL_UNSIGNED_INT, nullptr, - static_cast(instancesBogies.front().count())); - glBindVertexArray(instancesBogiesVAO.back()); - glDrawElementsInstanced(bogies.back()->type(), bogies.back()->count(), GL_UNSIGNED_INT, nullptr, - static_cast(instancesBogies.back().count())); - glBindVertexArray(0); + bodyMesh->DrawInstanced(instanceVAO, static_cast(count)); + bogies.front()->DrawInstanced( + instancesBogiesVAO.front(), static_cast(instancesBogies.front().count())); + bogies.back()->DrawInstanced(instancesBogiesVAO.back(), static_cast(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(count)); - glBindVertexArray(instancesBogiesVAO.front()); - glDrawElementsInstanced(bogies.front()->type(), bogies.front()->count(), GL_UNSIGNED_INT, nullptr, - static_cast(instancesBogies.front().count())); - glBindVertexArray(instancesBogiesVAO.back()); - glDrawElementsInstanced(bogies.back()->type(), bogies.back()->count(), GL_UNSIGNED_INT, nullptr, - static_cast(instancesBogies.back().count())); - glBindVertexArray(0); + bodyMesh->DrawInstanced(instanceVAO, static_cast(count)); + bogies.front()->DrawInstanced( + instancesBogiesVAO.front(), static_cast(instancesBogies.front().count())); + bogies.back()->DrawInstanced(instancesBogiesVAO.back(), static_cast(instancesBogies.back().count())); } } -- cgit v1.2.3