From e751ab465bbbf1365ec6e108c64dafd03ce42f1d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 23 Apr 2023 21:46:21 +0100 Subject: Pop and complete instanced shadow support --- game/scenary/foliage.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'game/scenary/foliage.cpp') diff --git a/game/scenary/foliage.cpp b/game/scenary/foliage.cpp index 35be051..e54dfbd 100644 --- a/game/scenary/foliage.cpp +++ b/game/scenary/foliage.cpp @@ -34,6 +34,13 @@ Foliage::render(const SceneShader & shader) const } void -Foliage::shadows(const ShadowMapper &) const +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(count)); + glBindVertexArray(0); + } } -- cgit v1.2.3 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/scenary/foliage.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'game/scenary/foliage.cpp') 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(count)); - glBindVertexArray(0); + bodyMesh->DrawInstanced(instanceVAO, static_cast(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(count)); - glBindVertexArray(0); + bodyMesh->DrawInstanced(instanceVAO, static_cast(count)); } } -- cgit v1.2.3