From c7af64b7061c59c987958d0830838f1c05caeb29 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 19 Jan 2024 00:23:56 +0000 Subject: Render rail network using new shaders Non-functional, totally unimplemented at this stage --- gfx/gl/sceneShader.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'gfx/gl/sceneShader.cpp') diff --git a/gfx/gl/sceneShader.cpp b/gfx/gl/sceneShader.cpp index 1b3b27c..146e642 100644 --- a/gfx/gl/sceneShader.cpp +++ b/gfx/gl/sceneShader.cpp @@ -1,14 +1,19 @@ #include "sceneShader.h" #include #include +#include #include #include #include +#include +#include #include #include #include #include #include +#include +#include #include #include #include @@ -21,15 +26,17 @@ SceneShader::SceneShader() : basicInst {dynamicPointInst_vs, material_fs}, landmass {fixedPoint_vs, landmass_fs}, absolute {fixedPoint_vs, material_fs}, spotLightInst {spotLight_vs, spotLight_gs, spotLight_fs}, - pointLightInst {pointLight_vs, pointLight_gs, pointLight_fs} + pointLightInst {pointLight_vs, pointLight_gs, pointLight_fs}, + networkStraight {networkStraight_vs, networkStraight_gs, network_fs}, + networkCurve {networkCurve_vs, networkCurve_gs, network_fs} { } void SceneShader::setViewProjection(const GlobalPosition3D & viewPoint, const glm::mat4 & viewProjection) const { - for (const auto & prog : std::initializer_list { - &basic, &basicInst, &water, &landmass, &absolute, &pointLightInst, &spotLightInst}) { + for (const auto & prog : std::initializer_list {&basic, &basicInst, &water, &landmass, + &absolute, &pointLightInst, &spotLightInst, &networkStraight, &networkCurve}) { prog->setViewProjection(viewPoint, viewProjection); } } @@ -37,8 +44,8 @@ SceneShader::setViewProjection(const GlobalPosition3D & viewPoint, const glm::ma void SceneShader::setViewPort(const ViewPort & viewPort) const { - for (const auto & prog : std::initializer_list { - &basic, &basicInst, &water, &landmass, &absolute, &pointLightInst, &spotLightInst}) { + for (const auto & prog : std::initializer_list {&basic, &basicInst, &water, &landmass, + &absolute, &pointLightInst, &spotLightInst, &networkStraight, &networkCurve}) { prog->setViewPort(viewPort); } } -- cgit v1.2.3 From 961f69d8cda0364c04ec98efc70a6f21e0a091e6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 22 Jan 2024 02:25:47 +0000 Subject: Bind the network profile in as uniforms Makes the network shaders generic to network type --- gfx/gl/sceneShader.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gfx/gl/sceneShader.cpp') diff --git a/gfx/gl/sceneShader.cpp b/gfx/gl/sceneShader.cpp index 146e642..bc64a88 100644 --- a/gfx/gl/sceneShader.cpp +++ b/gfx/gl/sceneShader.cpp @@ -86,6 +86,23 @@ SceneShader::BasicProgram::use(Location const & location) const setModel(location); } +template +SceneShader::NetworkProgram::NetworkProgram(S &&... s) : + AbsolutePosProgram {std::forward(s)...}, profileLoc {*this, "profile"}, texturePosLoc {*this, "texturePos"}, + profileLengthLoc {*this, "profileLength"} +{ +} + +void +SceneShader::NetworkProgram::use( + const std::span profile, const std::span texturePos) const +{ + Program::use(); + glUniform(profileLoc, profile); + glUniform(texturePosLoc, texturePos); + glUniform(profileLengthLoc, static_cast(profile.size())); +} + SceneShader::WaterProgram::WaterProgram() : SceneProgram {water_vs, water_fs}, waveLoc {*this, "waves"} { } void -- cgit v1.2.3