summaryrefslogtreecommitdiff
path: root/game/scenary
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2026-03-07 11:42:46 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2026-03-07 11:42:46 +0000
commitc89a633f59d0e393695c10f28c4ba8635eadffba (patch)
tree0e06a281efc2da637ebc19dca38f160e86516d9f /game/scenary
parentRemove VertexArrayObject and supporting non-DSA gl_traits helpers (diff)
downloadilt-c89a633f59d0e393695c10f28c4ba8635eadffba.tar.bz2
ilt-c89a633f59d0e393695c10f28c4ba8635eadffba.tar.xz
ilt-c89a633f59d0e393695c10f28c4ba8635eadffba.zip
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.
Diffstat (limited to 'game/scenary')
-rw-r--r--game/scenary/foliage.cpp10
-rw-r--r--game/scenary/illuminator.cpp18
2 files changed, 18 insertions, 10 deletions
diff --git a/game/scenary/foliage.cpp b/game/scenary/foliage.cpp
index 49a4831..cf2d82e 100644
--- a/game/scenary/foliage.cpp
+++ b/game/scenary/foliage.cpp
@@ -38,10 +38,8 @@ Foliage::postLoad()
{
texture = getTexture();
bodyMesh->configureVAO(instanceVAO, 0)
- .addAttribs<LocationVertex, &LocationVertex::rotation, &LocationVertex::position>(
- 1, instances.bufferName());
- instancePointVAO.configure().addAttribs<LocationVertex, &LocationVertex::position, &LocationVertex::yaw>(
- 0, instances.bufferName());
+ .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);
@@ -104,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);
}
@@ -113,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));
}
}
@@ -129,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);
}
@@ -140,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 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<LocationVertex, &LocationVertex::first, &LocationVertex::second>(1, instances.bufferName());
+ .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(1);
if (!spotLight.empty()) {
instancesSpotLightVAO.emplace();
instancesSpotLightVAO->configure()
.addAttribs<SpotLightVertex, &SpotLightVertex::position, &SpotLightVertex::direction,
- &SpotLightVertex::colour, &SpotLightVertex::kq, &SpotLightVertex::arc>(
- 0, instancesSpotLight.bufferName())
- .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(1, instances.bufferName());
+ &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);
@@ -58,8 +57,8 @@ Illuminator::postLoad()
instancesPointLightVAO.emplace();
instancesPointLightVAO->configure()
.addAttribs<PointLightVertex, &PointLightVertex::position, &PointLightVertex::colour,
- &PointLightVertex::kq>(0, instancesPointLight.bufferName())
- .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(1, instances.bufferName());
+ &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);
@@ -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<GLsizei>(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<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));
}