summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
authorDan Goodliffe <dan.goodliffe@octal.co.uk>2026-04-01 12:07:58 +0100
committerDan Goodliffe <dan.goodliffe@octal.co.uk>2026-04-01 12:07:58 +0100
commit56207fbf4e8662b6cf93632193ba68d2576c2d4e (patch)
treedec327a00b301149e76f691728053c7ef5bb9119 /game
parentMove light vertex structs out (diff)
downloadilt-56207fbf4e8662b6cf93632193ba68d2576c2d4e.tar.bz2
ilt-56207fbf4e8662b6cf93632193ba68d2576c2d4e.tar.xz
ilt-56207fbf4e8662b6cf93632193ba68d2576c2d4e.zip
Helper to instantiate transient static values as required
Diffstat (limited to 'game')
-rw-r--r--game/scenary/foliage.cpp7
-rw-r--r--game/scenary/illuminator.cpp4
2 files changed, 5 insertions, 6 deletions
diff --git a/game/scenary/foliage.cpp b/game/scenary/foliage.cpp
index 5902e09..f27ac26 100644
--- a/game/scenary/foliage.cpp
+++ b/game/scenary/foliage.cpp
@@ -4,6 +4,7 @@
#include "gfx/gl/sceneShader.h"
#include "gfx/gl/shadowMapper.h"
#include "gfx/gl/shadowStenciller.h"
+#include "util.h"
#include <location.h>
static_assert(std::is_constructible_v<Foliage>);
@@ -40,12 +41,10 @@ Foliage::postLoad()
{
texture = getTexture();
glDebugScope _ {0};
- if (!(instanceVAO = commonInstanceVAO.lock())) {
- commonInstanceVAO = instanceVAO = std::make_shared<glVertexArray>();
+ if (createIfRequired(instanceVAO, commonInstanceVAO)) {
bodyMesh->configureVAO(*instanceVAO, 0).addAttribs<InstanceVertex, &InstanceVertex::location>(1);
}
- if (!(instancePointVAO = commonInstancePointVAO.lock())) {
- commonInstancePointVAO = instancePointVAO = std::make_shared<glVertexArray>();
+ if (createIfRequired(instancePointVAO, commonInstancePointVAO)) {
instancePointVAO->configure().addAttribs<InstanceVertex, &InstanceVertex::location>(0);
}
const auto & size = bodyMesh->getDimensions().size;
diff --git a/game/scenary/illuminator.cpp b/game/scenary/illuminator.cpp
index e991baa..3b73cd3 100644
--- a/game/scenary/illuminator.cpp
+++ b/game/scenary/illuminator.cpp
@@ -1,6 +1,7 @@
#include "illuminator.h"
#include "gfx/gl/sceneShader.h"
#include "gfx/models/texture.h" // IWYU pragma: keep
+#include "util.h"
#include <location.h>
static_assert(std::is_constructible_v<Illuminator>);
@@ -44,8 +45,7 @@ Illuminator::postLoad()
}
texture = getTexture();
glDebugScope _ {0};
- if (!(instanceVAO = commonInstanceVAO.lock())) {
- commonInstanceVAO = instanceVAO = std::make_shared<glVertexArray>();
+ if (createIfRequired(instanceVAO, commonInstanceVAO)) {
bodyMesh->configureVAO(*instanceVAO, 0).addAttribs<InstanceVertex, &InstanceVertex::location>(1);
}
if (!spotLight.empty()) {