summaryrefslogtreecommitdiff
path: root/game/scenary/illuminator.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-09 20:17:55 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-09 20:17:55 +0000
commitbb693756b9aace889f806a768b54655023d163ab (patch)
tree47216b8c5bef15acd5a84124a64c9a036498d25f /game/scenary/illuminator.cpp
parentInteger support in persistence (diff)
downloadilt-bb693756b9aace889f806a768b54655023d163ab.tar.bz2
ilt-bb693756b9aace889f806a768b54655023d163ab.tar.xz
ilt-bb693756b9aace889f806a768b54655023d163ab.zip
Add the Illuminator (type) and Light (instance) classes
Diffstat (limited to 'game/scenary/illuminator.cpp')
-rw-r--r--game/scenary/illuminator.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/game/scenary/illuminator.cpp b/game/scenary/illuminator.cpp
new file mode 100644
index 0000000..4989933
--- /dev/null
+++ b/game/scenary/illuminator.cpp
@@ -0,0 +1,40 @@
+#include "illuminator.h"
+#include "gfx/gl/sceneShader.h"
+#include "gfx/gl/vertexArrayObject.h"
+#include "gfx/models/texture.h"
+#include "location.h"
+
+bool
+Illuminator::persist(Persistence::PersistenceStore & store)
+{
+ return STORE_TYPE && STORE_HELPER(bodyMesh, Asset::MeshConstruct) && Asset::persist(store);
+}
+
+void
+Illuminator::postLoad()
+{
+ texture = getTexture();
+ bodyMesh->configureVAO(instanceVAO)
+ .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(instances.bufferName(), 1);
+}
+
+void
+Illuminator::render(const SceneShader & shader) const
+{
+ if (const auto count = instances.size()) {
+ shader.basicInst.use();
+ if (texture) {
+ texture->bind();
+ }
+ bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count));
+ }
+}
+
+void
+Illuminator::lights(const SceneShader &) const
+{
+ if (const auto count = instances.size()) {
+ // shader.pointLight.use();
+ // bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count));
+ }
+}