summaryrefslogtreecommitdiff
path: root/game/network/rail.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-19 00:23:56 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-20 15:08:43 +0000
commitc7af64b7061c59c987958d0830838f1c05caeb29 (patch)
tree8195696b2130eb6a2674c075416b15a352440b61 /game/network/rail.cpp
parentCopy render vital link data to vertex buffer (diff)
downloadilt-c7af64b7061c59c987958d0830838f1c05caeb29.tar.bz2
ilt-c7af64b7061c59c987958d0830838f1c05caeb29.tar.xz
ilt-c7af64b7061c59c987958d0830838f1c05caeb29.zip
Render rail network using new shaders
Non-functional, totally unimplemented at this stage
Diffstat (limited to 'game/network/rail.cpp')
-rw-r--r--game/network/rail.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index 3d29ea5..9766851 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -127,7 +127,7 @@ RailLinkStraight::RailLinkStraight(
NetworkLinkHolder<RailLinkStraight> & instances, Node::Ptr a, Node::Ptr b, const RelativePosition3D & diff) :
Link({std::move(a), vector_yaw(diff)}, {std::move(b), vector_yaw(-diff)}, glm::length(diff)),
instance {instances.vertices.acquire(
- ends[0].node->pos, ends[1].node->pos, flat_orientation(diff), round_sleepers(length / 2.F))}
+ ends[0].node->pos, ends[1].node->pos, flat_orientation(diff), round_sleepers(length / 2000.F))}
{
if (glGenVertexArrays) {
std::vector<::Vertex> vertices;
@@ -155,7 +155,7 @@ RailLinkCurve::RailLinkCurve(NetworkLinkHolder<RailLinkCurve> & instances, const
Link({a, normalize(arc.first + half_pi)}, {b, normalize(arc.second - half_pi)},
glm::length(RelativePosition3D(a->pos - c)) * arc_length(arc)),
LinkCurve {c, glm::length(RelativePosition3D(ends[0].node->pos - c)), arc},
- instance {instances.vertices.acquire(ends[0].node->pos, ends[1].node->pos, c, round_sleepers(length / 2.F))}
+ instance {instances.vertices.acquire(ends[0].node->pos, ends[1].node->pos, c, round_sleepers(length / 2000.F))}
{
if (glGenVertexArrays) {
@@ -185,3 +185,21 @@ RailLink::vehiclePositionOffset() const
{
return RAIL_HEIGHT;
}
+
+void
+RailLinks::render(const SceneShader & shader) const
+{
+ auto renderType = [](auto & v, auto & s) {
+ if (auto count = v.size()) {
+ s.use();
+ glBindBuffer(GL_VERTEX_ARRAY, v.bufferName());
+ glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(count));
+ }
+ };
+ if (!links.objects.empty()) {
+ texture->bind();
+ renderType(NetworkLinkHolder<RailLinkStraight>::vertices, shader.networkStraight);
+ renderType(NetworkLinkHolder<RailLinkCurve>::vertices, shader.networkCurve);
+ glBindBuffer(GL_VERTEX_ARRAY, 0);
+ }
+}