diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-03-07 11:50:47 +0000 |
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-03-07 11:50:47 +0000 |
| commit | adb0096046d357a6463ae2ce66c182546c8de9c2 (patch) | |
| tree | 0e06a281efc2da637ebc19dca38f160e86516d9f /game/scenary | |
| parent | Update stencils and billboards less often (diff) | |
| parent | Replace glContainer with glAllocator (diff) | |
| download | ilt-adb0096046d357a6463ae2ce66c182546c8de9c2.tar.bz2 ilt-adb0096046d357a6463ae2ce66c182546c8de9c2.tar.xz ilt-adb0096046d357a6463ae2ce66c182546c8de9c2.zip | |
Merge branch 'glalloc'
Diffstat (limited to 'game/scenary')
| -rw-r--r-- | game/scenary/foliage.cpp | 13 | ||||
| -rw-r--r-- | game/scenary/illuminator.cpp | 25 |
2 files changed, 22 insertions, 16 deletions
diff --git a/game/scenary/foliage.cpp b/game/scenary/foliage.cpp index 0981ffc..cf2d82e 100644 --- a/game/scenary/foliage.cpp +++ b/game/scenary/foliage.cpp @@ -4,7 +4,6 @@ #include "gfx/gl/sceneShader.h" #include "gfx/gl/shadowMapper.h" #include "gfx/gl/shadowStenciller.h" -#include "gfx/gl/vertexArrayObject.h" #include <location.h> static_assert(std::is_constructible_v<Foliage>); @@ -38,11 +37,9 @@ void Foliage::postLoad() { texture = getTexture(); - bodyMesh->configureVAO(instanceVAO) - .addAttribs<LocationVertex, &LocationVertex::rotation, &LocationVertex::position>( - instances.bufferName(), 1); - VertexArrayObject {instancePointVAO}.addAttribs<LocationVertex, &LocationVertex::position, &LocationVertex::yaw>( - instances.bufferName()); + bodyMesh->configureVAO(instanceVAO, 0) + .addAttribs<LocationVertex, &LocationVertex::rotation, &LocationVertex::position>(1); + instancePointVAO.configure().addAttribs<LocationVertex, &LocationVertex::position, &LocationVertex::yaw>(0); const auto & size = bodyMesh->getDimensions().size; billboardSize = billboardTextureSizeForObject(size); @@ -105,6 +102,7 @@ Foliage::render(const SceneShader & shader, const Frustum &) const billboard[1].bind(GL_TEXTURE_2D_ARRAY, GL_TEXTURE1); billboard[2].bind(GL_TEXTURE_2D_ARRAY, GL_TEXTURE2); glBindVertexArray(instancePointVAO); + glVertexArrayVertexBuffer(instancePointVAO, 0, instances.bufferName(), 0, sizeof(LocationVertex)); glDrawArrays(GL_POINTS, static_cast<GLint>(instancePartitions.second.first), static_cast<GLsizei>(count)); glBindVertexArray(0); } @@ -114,6 +112,7 @@ Foliage::render(const SceneShader & shader, const Frustum &) const if (texture) { texture->bind(); } + glVertexArrayVertexBuffer(instanceVAO, 1, instances.bufferName(), 0, sizeof(LocationVertex)); bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count)); } } @@ -130,6 +129,7 @@ Foliage::shadows(const ShadowMapper & mapper, const Frustum &) const mapper.stencilShadowProgram.use(dimensions.centre, dimensions.size); shadowStencil.bind(GL_TEXTURE_2D_ARRAY, GL_TEXTURE0); glBindVertexArray(instancePointVAO); + glVertexArrayVertexBuffer(instancePointVAO, 0, instances.bufferName(), 0, sizeof(LocationVertex)); glDrawArrays(GL_POINTS, static_cast<GLint>(instancePartitions.second.first), static_cast<GLsizei>(count)); glBindVertexArray(0); } @@ -141,6 +141,7 @@ Foliage::shadows(const ShadowMapper & mapper, const Frustum &) const else { mapper.dynamicPointInst.use(); } + glVertexArrayVertexBuffer(instanceVAO, 1, instances.bufferName(), 0, sizeof(LocationVertex)); bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count)); } } diff --git a/game/scenary/illuminator.cpp b/game/scenary/illuminator.cpp index d8e4c4e..7ab17fe 100644 --- a/game/scenary/illuminator.cpp +++ b/game/scenary/illuminator.cpp @@ -1,6 +1,5 @@ #include "illuminator.h" #include "gfx/gl/sceneShader.h" -#include "gfx/gl/vertexArrayObject.h" #include "gfx/models/texture.h" // IWYU pragma: keep #include <location.h> @@ -41,15 +40,14 @@ Illuminator::postLoad() throw std::logic_error {"Illuminator has no lights"}; } texture = getTexture(); - bodyMesh->configureVAO(instanceVAO) - .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(instances.bufferName(), 1); + bodyMesh->configureVAO(instanceVAO, 0) + .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(1); if (!spotLight.empty()) { instancesSpotLightVAO.emplace(); - VertexArrayObject {*instancesSpotLightVAO} + instancesSpotLightVAO->configure() .addAttribs<SpotLightVertex, &SpotLightVertex::position, &SpotLightVertex::direction, - &SpotLightVertex::colour, &SpotLightVertex::kq, &SpotLightVertex::arc>( - instancesSpotLight.bufferName(), 0) - .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(instances.bufferName(), 1); + &SpotLightVertex::colour, &SpotLightVertex::kq, &SpotLightVertex::arc>(0) + .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(1); std::transform( spotLight.begin(), spotLight.end(), std::back_inserter(spotLightInstances), [this](const auto & s) { return instancesSpotLight.acquire(*s); @@ -57,10 +55,10 @@ Illuminator::postLoad() } if (!pointLight.empty()) { instancesPointLightVAO.emplace(); - VertexArrayObject {*instancesPointLightVAO} + instancesPointLightVAO->configure() .addAttribs<PointLightVertex, &PointLightVertex::position, &PointLightVertex::colour, - &PointLightVertex::kq>(instancesPointLight.bufferName(), 0) - .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(instances.bufferName(), 1); + &PointLightVertex::kq>(0) + .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(1); std::transform( pointLight.begin(), pointLight.end(), std::back_inserter(pointLightInstances), [this](const auto & s) { return instancesPointLight.acquire(*s); @@ -76,6 +74,7 @@ Illuminator::render(const SceneShader & shader, const Frustum &) const if (texture) { texture->bind(); } + glVertexArrayVertexBuffer(instanceVAO, 1, instances.bufferName(), 0, sizeof(LocationVertex)); bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count)); } } @@ -87,11 +86,17 @@ Illuminator::lights(const SceneShader & shader) const if (const auto scount = instancesSpotLight.size()) { shader.spotLightInst.use(); glBindVertexArray(*instancesSpotLightVAO); + glVertexArrayVertexBuffer( + *instancesSpotLightVAO, 0, instancesSpotLight.bufferName(), 0, sizeof(SpotLightVertex)); + glVertexArrayVertexBuffer(*instancesSpotLightVAO, 1, instances.bufferName(), 0, sizeof(LocationVertex)); glDrawArraysInstanced(GL_POINTS, 0, static_cast<GLsizei>(scount), static_cast<GLsizei>(count)); } if (const auto pcount = instancesPointLight.size()) { shader.pointLightInst.use(); glBindVertexArray(*instancesPointLightVAO); + glVertexArrayVertexBuffer( + *instancesPointLightVAO, 0, instancesPointLight.bufferName(), 0, sizeof(PointLightVertex)); + glVertexArrayVertexBuffer(*instancesPointLightVAO, 1, instances.bufferName(), 0, sizeof(LocationVertex)); glDrawArraysInstanced(GL_POINTS, 0, static_cast<GLsizei>(pcount), static_cast<GLsizei>(count)); } |
