summaryrefslogtreecommitdiff
path: root/game/water.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-04-07 19:38:18 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-04-07 19:38:18 +0100
commit97d4db588bfc4254e09e4305fb0525a04748f84e (patch)
tree049049622e338b3ad72d9b1639a51b65250caeba /game/water.cpp
parentCreate water squares/polygons only where required (diff)
downloadilt-97d4db588bfc4254e09e4305fb0525a04748f84e.tar.bz2
ilt-97d4db588bfc4254e09e4305fb0525a04748f84e.tar.xz
ilt-97d4db588bfc4254e09e4305fb0525a04748f84e.zip
Stripped down water vertex and simplified shaders
Diffstat (limited to 'game/water.cpp')
-rw-r--r--game/water.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/game/water.cpp b/game/water.cpp
index 3dc1916..f720e3e 100644
--- a/game/water.cpp
+++ b/game/water.cpp
@@ -9,7 +9,6 @@
#include <gfx/models/mesh.h>
#include <gfx/models/vertex.h>
#include <glm/glm.hpp>
-#include <iterator>
#include <location.h>
#include <maths.h>
#include <set>
@@ -24,6 +23,13 @@ namespace glm {
}
}
+template<>
+VertexArrayObject &
+VertexArrayObject::addAttribsFor<Water::Vertex>(const GLuint arrayBuffer, const GLuint divisor)
+{
+ return addAttribs<Water::Vertex, &Water::Vertex::pos>(arrayBuffer, divisor);
+}
+
Water::Water(std::shared_ptr<GeoData> tm) : geoData {std::move(tm)}, water {std::make_shared<Texture>("water.png")}
{
generateMeshes();
@@ -77,8 +83,7 @@ Water::generateMeshes()
const auto v = vertexIndex.emplace(pos, vertices.size());
if (v.second) {
const auto cpos = glm::clamp(pos, std::get<0>(extents).xy(), std::get<1>(extents).xy());
- vertices.emplace_back(RelativePosition3D {geoData->positionAt(cpos)},
- TextureRelCoord(pos / TILE_SIZE), up);
+ vertices.emplace_back(geoData->positionAt(cpos));
}
*out++ = static_cast<unsigned int>(v.first->second);
}
@@ -87,7 +92,7 @@ Water::generateMeshes()
indices.push_back(currentIndices[i]);
}
});
- meshes.create<Mesh>(vertices, indices);
+ meshes.create<MeshT<Vertex>>(vertices, indices);
}
void
@@ -101,5 +106,5 @@ Water::render(const SceneShader & shader) const
{
shader.water.use(waveCycle);
water->bind();
- meshes.apply(&Mesh::Draw);
+ meshes.apply(&MeshT<GlobalPosition3D>::Draw);
}