From c89a633f59d0e393695c10f28c4ba8635eadffba Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 7 Mar 2026 11:42:46 +0000 Subject: Replace glContainer with glAllocator glContainer is no longer required, as we can use std::vector with a custom allocator which uses OpenGL buffers for storage. Minor irritation is that the mapped buffers aren't guaranteed to be flushed in the tests, so sometimes we're missing bits in a test render. --- game/scenary/illuminator.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'game/scenary/illuminator.cpp') diff --git a/game/scenary/illuminator.cpp b/game/scenary/illuminator.cpp index 590062e..7ab17fe 100644 --- a/game/scenary/illuminator.cpp +++ b/game/scenary/illuminator.cpp @@ -41,14 +41,13 @@ Illuminator::postLoad() } texture = getTexture(); bodyMesh->configureVAO(instanceVAO, 0) - .addAttribs(1, instances.bufferName()); + .addAttribs(1); if (!spotLight.empty()) { instancesSpotLightVAO.emplace(); instancesSpotLightVAO->configure() .addAttribs( - 0, instancesSpotLight.bufferName()) - .addAttribs(1, instances.bufferName()); + &SpotLightVertex::colour, &SpotLightVertex::kq, &SpotLightVertex::arc>(0) + .addAttribs(1); std::transform( spotLight.begin(), spotLight.end(), std::back_inserter(spotLightInstances), [this](const auto & s) { return instancesSpotLight.acquire(*s); @@ -58,8 +57,8 @@ Illuminator::postLoad() instancesPointLightVAO.emplace(); instancesPointLightVAO->configure() .addAttribs(0, instancesPointLight.bufferName()) - .addAttribs(1, instances.bufferName()); + &PointLightVertex::kq>(0) + .addAttribs(1); std::transform( pointLight.begin(), pointLight.end(), std::back_inserter(pointLightInstances), [this](const auto & s) { return instancesPointLight.acquire(*s); @@ -75,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(count)); } } @@ -86,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(scount), static_cast(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(pcount), static_cast(count)); } -- cgit v1.3