diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-24 02:13:18 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-24 02:13:18 +0000 |
commit | 738754c684a1c2d736bae7940a52a9ee058e83e5 (patch) | |
tree | 1cb3e4e7da4caef32c13b8af39948e46dd11b27c /gfx/gl/sceneShader.cpp | |
parent | Merge remote-tracking branch 'origin/instanced-networks' (diff) | |
download | ilt-738754c684a1c2d736bae7940a52a9ee058e83e5.tar.bz2 ilt-738754c684a1c2d736bae7940a52a9ee058e83e5.tar.xz ilt-738754c684a1c2d736bae7940a52a9ee058e83e5.zip |
Single list of all shader programs
Pushes common stuff through a helper function
Diffstat (limited to 'gfx/gl/sceneShader.cpp')
-rw-r--r-- | gfx/gl/sceneShader.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/gfx/gl/sceneShader.cpp b/gfx/gl/sceneShader.cpp index bc64a88..2dd9612 100644 --- a/gfx/gl/sceneShader.cpp +++ b/gfx/gl/sceneShader.cpp @@ -23,6 +23,15 @@ #include <location.h> #include <maths.h> +inline void +SceneShader::allPrograms(auto member, auto &&... ps) const +{ + for (const auto & prog : std::initializer_list<const SceneProgram *> {&basic, &basicInst, &water, &landmass, + &absolute, &pointLightInst, &spotLightInst, &networkStraight, &networkCurve}) { + (prog->*member)(std::forward<decltype(ps)>(ps)...); + } +} + SceneShader::SceneShader() : basicInst {dynamicPointInst_vs, material_fs}, landmass {fixedPoint_vs, landmass_fs}, absolute {fixedPoint_vs, material_fs}, spotLightInst {spotLight_vs, spotLight_gs, spotLight_fs}, @@ -35,19 +44,13 @@ SceneShader::SceneShader() : void SceneShader::setViewProjection(const GlobalPosition3D & viewPoint, const glm::mat4 & viewProjection) const { - for (const auto & prog : std::initializer_list<const SceneProgram *> {&basic, &basicInst, &water, &landmass, - &absolute, &pointLightInst, &spotLightInst, &networkStraight, &networkCurve}) { - prog->setViewProjection(viewPoint, viewProjection); - } + allPrograms(&SceneProgram::setViewProjection, viewPoint, viewProjection); } void SceneShader::setViewPort(const ViewPort & viewPort) const { - for (const auto & prog : std::initializer_list<const SceneProgram *> {&basic, &basicInst, &water, &landmass, - &absolute, &pointLightInst, &spotLightInst, &networkStraight, &networkCurve}) { - prog->setViewPort(viewPort); - } + allPrograms(&SceneProgram::setViewPort, viewPort); } void |