summaryrefslogtreecommitdiff
path: root/game/vehicles/railVehicleClass.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-05-07 01:41:31 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-05-07 01:41:31 +0100
commit9ab2aad4aa00afe3373b3a779377fa049459fb4d (patch)
tree18bf013e3be660b0769cd1a601e670eb79355324 /game/vehicles/railVehicleClass.cpp
parentRename strings.h to something that won't conflict with a system header (diff)
parentTemplated BufferedLocation and single buffer storage for RVC locations (diff)
downloadilt-9ab2aad4aa00afe3373b3a779377fa049459fb4d.tar.bz2
ilt-9ab2aad4aa00afe3373b3a779377fa049459fb4d.tar.xz
ilt-9ab2aad4aa00afe3373b3a779377fa049459fb4d.zip
Merge branch 'containers'
Diffstat (limited to 'game/vehicles/railVehicleClass.cpp')
-rw-r--r--game/vehicles/railVehicleClass.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp
index 64a21be..324148c 100644
--- a/game/vehicles/railVehicleClass.cpp
+++ b/game/vehicles/railVehicleClass.cpp
@@ -4,6 +4,7 @@
#include "gfx/gl/vertexArrayObject.h"
#include "gfx/models/mesh.h"
#include "gfx/models/texture.h"
+#include "stream_support.h"
#include <algorithm>
#include <array>
#include <cache.h>
@@ -34,38 +35,36 @@ void
RailVehicleClass::postLoad()
{
texture = getTexture();
- bodyMesh->configureVAO(instanceVAO).addAttribs<glm::mat4>(instancesBody.bufferName(), 1);
+ bodyMesh->configureVAO(instanceVAO).addAttribs<LocationVertex, &LocationVertex::body>(instances.bufferName(), 1);
bogies.front()
->configureVAO(instancesBogiesVAO.front())
- .addAttribs<glm::mat4>(instancesBogies.front().bufferName(), 1);
+ .addAttribs<LocationVertex, &LocationVertex::front>(instances.bufferName(), 1);
bogies.back()
->configureVAO(instancesBogiesVAO.back())
- .addAttribs<glm::mat4>(instancesBogies.back().bufferName(), 1);
+ .addAttribs<LocationVertex, &LocationVertex::back>(instances.bufferName(), 1);
}
void
RailVehicleClass::render(const SceneShader & shader) const
{
- if (const auto count = instancesBody.count()) {
+ if (const auto count = static_cast<GLsizei>(instances.size())) {
if (texture) {
texture->bind();
}
shader.basicInst.use();
- bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count));
- bogies.front()->DrawInstanced(
- instancesBogiesVAO.front(), static_cast<GLsizei>(instancesBogies.front().count()));
- bogies.back()->DrawInstanced(instancesBogiesVAO.back(), static_cast<GLsizei>(instancesBogies.back().count()));
+ bodyMesh->DrawInstanced(instanceVAO, count);
+ bogies.front()->DrawInstanced(instancesBogiesVAO.front(), count);
+ bogies.back()->DrawInstanced(instancesBogiesVAO.back(), count);
}
}
void
RailVehicleClass::shadows(const ShadowMapper & mapper) const
{
- if (const auto count = instancesBody.count()) {
+ if (const auto count = static_cast<GLsizei>(instances.size())) {
mapper.dynamicPointInst.use();
- bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count));
- bogies.front()->DrawInstanced(
- instancesBogiesVAO.front(), static_cast<GLsizei>(instancesBogies.front().count()));
- bogies.back()->DrawInstanced(instancesBogiesVAO.back(), static_cast<GLsizei>(instancesBogies.back().count()));
+ bodyMesh->DrawInstanced(instanceVAO, count);
+ bogies.front()->DrawInstanced(instanceVAO, count);
+ bogies.back()->DrawInstanced(instanceVAO, count);
}
}