From bb693756b9aace889f806a768b54655023d163ab Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 9 Jan 2024 20:17:55 +0000 Subject: Add the Illuminator (type) and Light (instance) classes --- game/scenary/illuminator.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 game/scenary/illuminator.cpp (limited to 'game/scenary/illuminator.cpp') 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(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(count)); + } +} + +void +Illuminator::lights(const SceneShader &) const +{ + if (const auto count = instances.size()) { + // shader.pointLight.use(); + // bodyMesh->DrawInstanced(instanceVAO, static_cast(count)); + } +} -- cgit v1.2.3