summaryrefslogtreecommitdiff
path: root/game/scenary/illuminator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'game/scenary/illuminator.cpp')
-rw-r--r--game/scenary/illuminator.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/game/scenary/illuminator.cpp b/game/scenary/illuminator.cpp
index 6f51506..3de4e52 100644
--- a/game/scenary/illuminator.cpp
+++ b/game/scenary/illuminator.cpp
@@ -12,9 +12,16 @@ Illuminator::SpotLight::persist(Persistence::PersistenceStore & store)
}
bool
+Illuminator::PointLight::persist(Persistence::PersistenceStore & store)
+{
+ return STORE_TYPE && STORE_MEMBER(position) && STORE_MEMBER(colour) && STORE_MEMBER(kq);
+}
+
+bool
Illuminator::persist(Persistence::PersistenceStore & store)
{
return STORE_TYPE && STORE_HELPER(bodyMesh, Asset::MeshConstruct)
+ && STORE_HELPER(pointLight, Persistence::Appender<decltype(pointLight)>)
&& STORE_HELPER(spotLight, Persistence::Appender<decltype(spotLight)>) && Asset::persist(store);
}
@@ -32,6 +39,14 @@ Illuminator::postLoad()
std::transform(spotLight.begin(), spotLight.end(), std::back_inserter(spotLightInstances), [this](const auto & s) {
return instancesSpotLight.acquire(*s);
});
+ VertexArrayObject {instancesPointLightVAO}
+ .addAttribs<PointLightVertex, &PointLightVertex::position, &PointLightVertex::colour,
+ &PointLightVertex::kq>(instancesPointLight.bufferName(), 0)
+ .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(instances.bufferName(), 1);
+ std::transform(
+ pointLight.begin(), pointLight.end(), std::back_inserter(pointLightInstances), [this](const auto & s) {
+ return instancesPointLight.acquire(*s);
+ });
}
void
@@ -55,6 +70,11 @@ Illuminator::lights(const SceneShader & shader) const
glBindVertexArray(instancesSpotLightVAO);
glDrawArraysInstanced(GL_POINTS, 0, static_cast<GLsizei>(scount), static_cast<GLsizei>(count));
}
+ if (const auto pcount = instancesPointLight.size()) {
+ shader.pointLightInst.use();
+ glBindVertexArray(instancesPointLightVAO);
+ glDrawArraysInstanced(GL_POINTS, 0, static_cast<GLsizei>(pcount), static_cast<GLsizei>(count));
+ }
glBindVertexArray(0);
}