summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-11-03 18:25:28 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-11-03 18:25:28 +0000
commitf848ad0e672d913c36fcb86533cbc11a9cf9d9ea (patch)
treee8384bdb074a4e3e53fd9a218b9d9910e6a8256d
parentTidied Scene Renderer (diff)
downloadilt-f848ad0e672d913c36fcb86533cbc11a9cf9d9ea.tar.bz2
ilt-f848ad0e672d913c36fcb86533cbc11a9cf9d9ea.tar.xz
ilt-f848ad0e672d913c36fcb86533cbc11a9cf9d9ea.zip
Rename Shader to SceneShader
-rw-r--r--game/network/network.h4
-rw-r--r--game/network/network.impl.h6
-rw-r--r--game/network/rail.cpp2
-rw-r--r--game/network/rail.h4
-rw-r--r--game/terrain.cpp8
-rw-r--r--game/terrain.h4
-rw-r--r--game/vehicles/railVehicle.cpp2
-rw-r--r--game/vehicles/railVehicle.h4
-rw-r--r--game/vehicles/railVehicleClass.cpp5
-rw-r--r--game/vehicles/railVehicleClass.h4
-rw-r--r--game/vehicles/train.cpp2
-rw-r--r--game/vehicles/train.h4
-rw-r--r--gfx/gl/sceneShader.cpp (renamed from gfx/gl/shader.cpp)12
-rw-r--r--gfx/gl/sceneShader.h (renamed from gfx/gl/shader.h)4
-rw-r--r--gfx/renderable.h4
-rw-r--r--ui/editNetwork.cpp8
-rw-r--r--ui/editNetwork.h4
-rw-r--r--ui/gameMainSelector.cpp4
-rw-r--r--ui/gameMainSelector.h4
-rw-r--r--ui/gameMainWindow.cpp2
-rw-r--r--ui/gameMainWindow.h6
-rw-r--r--ui/sceneRenderer.h2
-rw-r--r--ui/window.h4
-rw-r--r--ui/worldOverlay.h4
24 files changed, 54 insertions, 53 deletions
diff --git a/game/network/network.h b/game/network/network.h
index 4a2f56a..e7a65b5 100644
--- a/game/network/network.h
+++ b/game/network/network.h
@@ -12,7 +12,7 @@
#include <variant>
class Texture;
-class Shader;
+class SceneShader;
class Ray;
template<size_t... n> using GenDef = std::tuple<glm::vec<n, float>...>;
@@ -96,7 +96,7 @@ public:
float findNodeDirection(Node::AnyCPtr) const override;
- void render(const Shader &) const override;
+ void render(const SceneShader &) const override;
protected:
Link::CCollection addJoins();
diff --git a/game/network/network.impl.h b/game/network/network.impl.h
index 597e3aa..5f60c80 100644
--- a/game/network/network.impl.h
+++ b/game/network/network.impl.h
@@ -1,13 +1,13 @@
#include "network.h"
-#include <gfx/gl/shader.h>
+#include <gfx/gl/sceneShader.h>
#include <gfx/models/texture.h>
template<typename T>
void
-NetworkOf<T>::render(const Shader & shader) const
+NetworkOf<T>::render(const SceneShader & shader) const
{
if constexpr (std::is_base_of_v<Renderable, T>) {
- shader.setModel(Location {}, Shader::Program::StaticPos);
+ shader.setModel(Location {}, SceneShader::Program::StaticPos);
texture->bind();
links.apply(&Renderable::render, shader);
}
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index 2efa87a..2f09d88 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -94,7 +94,7 @@ RailLink::defaultMesh(const std::span<Vertex> vertices)
}
void
-RailLink::render(const Shader &) const
+RailLink::render(const SceneShader &) const
{
mesh->Draw();
}
diff --git a/game/network/rail.h b/game/network/rail.h
index 6850463..8edc363 100644
--- a/game/network/rail.h
+++ b/game/network/rail.h
@@ -11,7 +11,7 @@
#include <span>
#include <special_members.hpp>
-class Shader;
+class SceneShader;
class Vertex;
struct Arc;
@@ -26,7 +26,7 @@ public:
using StraightLink = RailLinkStraight;
using CurveLink = RailLinkCurve;
- void render(const Shader &) const override;
+ void render(const SceneShader &) const override;
NO_COPY(RailLink);
NO_MOVE(RailLink);
diff --git a/game/terrain.cpp b/game/terrain.cpp
index 3a35c42..911a541 100644
--- a/game/terrain.cpp
+++ b/game/terrain.cpp
@@ -6,7 +6,7 @@
#include <cache.h>
#include <cstddef>
#include <filesystem>
-#include <gfx/gl/shader.h>
+#include <gfx/gl/sceneShader.h>
#include <gfx/image.h>
#include <gfx/models/mesh.h>
#include <gfx/models/vertex.hpp>
@@ -83,13 +83,13 @@ Terrain::tick(TickDuration dur)
}
void
-Terrain::render(const Shader & shader) const
+Terrain::render(const SceneShader & shader) const
{
- shader.setModel(Location {}, Shader::Program::LandMass);
+ shader.setModel(Location {}, SceneShader::Program::LandMass);
grass->bind();
meshes.apply(&Mesh::Draw);
- shader.setModel(Location {}, Shader::Program::Water);
+ shader.setModel(Location {}, SceneShader::Program::Water);
shader.setUniform("waves", {waveCycle, 0, 0});
water->bind();
meshes.apply(&Mesh::Draw);
diff --git a/game/terrain.h b/game/terrain.h
index b13efb6..70f947c 100644
--- a/game/terrain.h
+++ b/game/terrain.h
@@ -7,7 +7,7 @@
#include <gfx/renderable.h>
#include <memory>
-class Shader;
+class SceneShader;
class Texture;
class GeoData;
@@ -15,7 +15,7 @@ class Terrain : public WorldObject, public Renderable {
public:
explicit Terrain(std::shared_ptr<GeoData>);
- void render(const Shader & shader) const override;
+ void render(const SceneShader & shader) const override;
void tick(TickDuration) override;
float waveCycle {0.F};
diff --git a/game/vehicles/railVehicle.cpp b/game/vehicles/railVehicle.cpp
index fb42a28..0cf4e72 100644
--- a/game/vehicles/railVehicle.cpp
+++ b/game/vehicles/railVehicle.cpp
@@ -12,7 +12,7 @@
#include <ray.hpp>
void
-RailVehicle::render(const Shader & shader) const
+RailVehicle::render(const SceneShader & shader) const
{
rvClass->render(shader, location, bogies);
}
diff --git a/game/vehicles/railVehicle.h b/game/vehicles/railVehicle.h
index 5fbe1ed..39900cc 100644
--- a/game/vehicles/railVehicle.h
+++ b/game/vehicles/railVehicle.h
@@ -9,7 +9,7 @@
#include <memory>
#include <utility>
-class Shader;
+class SceneShader;
class Ray;
class Train;
@@ -19,7 +19,7 @@ public:
void move(const Train *, float & trailBy);
- void render(const Shader & shader) const override;
+ void render(const SceneShader & shader) const override;
[[nodiscard]] bool intersectRay(const Ray &, glm::vec2 *, float *) const override;
Location location;
diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp
index 7eb4495..7d69338 100644
--- a/game/vehicles/railVehicleClass.cpp
+++ b/game/vehicles/railVehicleClass.cpp
@@ -1,5 +1,5 @@
#include "railVehicleClass.h"
-#include "gfx/gl/shader.h"
+#include "gfx/gl/sceneShader.h"
#include "gfx/models/mesh.h"
#include "gfx/models/obj.h"
#include "gfx/models/texture.h"
@@ -39,7 +39,8 @@ RailVehicleClass::RailVehicleClass(std::unique_ptr<ObjParser> o, std::shared_ptr
}
void
-RailVehicleClass::render(const Shader & shader, const Location & location, const std::array<Location, 2> & bl) const
+RailVehicleClass::render(
+ const SceneShader & shader, const Location & location, const std::array<Location, 2> & bl) const
{
texture->bind();
for (auto b = 0U; b < bogies.size(); ++b) {
diff --git a/game/vehicles/railVehicleClass.h b/game/vehicles/railVehicleClass.h
index 604af6a..7249e76 100644
--- a/game/vehicles/railVehicleClass.h
+++ b/game/vehicles/railVehicleClass.h
@@ -5,7 +5,7 @@
#include <memory>
#include <string>
-class Shader;
+class SceneShader;
class Texture;
class ObjParser;
class Location;
@@ -14,7 +14,7 @@ class RailVehicleClass {
public:
explicit RailVehicleClass(const std::string & name);
- void render(const Shader &, const Location &, const std::array<Location, 2> &) const;
+ void render(const SceneShader &, const Location &, const std::array<Location, 2> &) const;
std::array<Mesh::Ptr, 2> bogies;
Mesh::Ptr bodyMesh;
diff --git a/game/vehicles/train.cpp b/game/vehicles/train.cpp
index d1122f8..8fb48f5 100644
--- a/game/vehicles/train.cpp
+++ b/game/vehicles/train.cpp
@@ -12,7 +12,7 @@
class Ray;
void
-Train::render(const Shader & shader) const
+Train::render(const SceneShader & shader) const
{
apply(&Renderable::render, shader);
}
diff --git a/game/vehicles/train.h b/game/vehicles/train.h
index 58e5e29..dfdcf62 100644
--- a/game/vehicles/train.h
+++ b/game/vehicles/train.h
@@ -13,7 +13,7 @@
#include <memory>
#include <vector>
-class Shader;
+class SceneShader;
class Ray;
class Train : public Vehicle, public Collection<RailVehicle, false>, public Can<Go>, public Can<Idle> {
@@ -26,7 +26,7 @@ public:
return objects.front()->location;
}
- void render(const Shader & shader) const override;
+ void render(const SceneShader & shader) const override;
[[nodiscard]] bool intersectRay(const Ray &, glm::vec2 *, float *) const override;
diff --git a/gfx/gl/shader.cpp b/gfx/gl/sceneShader.cpp
index a196e07..48c0f42 100644
--- a/gfx/gl/shader.cpp
+++ b/gfx/gl/sceneShader.cpp
@@ -1,4 +1,4 @@
-#include "shader.h"
+#include "sceneShader.h"
#include "gfx/gl/glSource.h"
#include <array>
#include <cstddef>
@@ -15,7 +15,7 @@
#include <location.hpp>
#include <maths.h>
-Shader::ProgramHandle::ProgramHandle(GLuint vs, GLuint fs) : ProgramHandleBase {vs, fs}
+SceneShader::ProgramHandle::ProgramHandle(GLuint vs, GLuint fs) : ProgramHandleBase {vs, fs}
{
glBindAttribLocation(m_program, 0, "position");
glBindAttribLocation(m_program, 1, "texCoord");
@@ -25,7 +25,7 @@ Shader::ProgramHandle::ProgramHandle(GLuint vs, GLuint fs) : ProgramHandleBase {
model_uniform = glGetUniformLocation(m_program, "model");
}
-Shader::Shader() :
+SceneShader::SceneShader() :
programs {{{
basicShader_vs.compile(),
basicShader_fs.compile(),
@@ -46,7 +46,7 @@ Shader::Shader() :
}
void
-Shader::setView(glm::mat4 proj) const
+SceneShader::setView(glm::mat4 proj) const
{
for (const auto & prog : programs) {
glUseProgram(prog.m_program);
@@ -55,7 +55,7 @@ Shader::setView(glm::mat4 proj) const
}
void
-Shader::setUniform(const GLchar * uniform, glm::vec3 v) const
+SceneShader::setUniform(const GLchar * uniform, glm::vec3 v) const
{
for (const auto & prog : programs) {
if (auto loc = glGetUniformLocation(prog.m_program, uniform); loc >= 0) {
@@ -66,7 +66,7 @@ Shader::setUniform(const GLchar * uniform, glm::vec3 v) const
}
void
-Shader::setModel(const Location & loc, Program pid) const
+SceneShader::setModel(const Location & loc, Program pid) const
{
auto & prog = programs[static_cast<std::size_t>(pid)];
glUseProgram(prog.m_program);
diff --git a/gfx/gl/shader.h b/gfx/gl/sceneShader.h
index 8411b94..61c159b 100644
--- a/gfx/gl/shader.h
+++ b/gfx/gl/sceneShader.h
@@ -7,11 +7,11 @@
class Location;
-class Shader {
+class SceneShader {
public:
enum class Program { Basic = 0, Water = 1, LandMass = 2, StaticPos = 3 };
- Shader();
+ SceneShader();
void setView(glm::mat4 view) const;
void setModel(const Location &, Program = Program::Basic) const;
diff --git a/gfx/renderable.h b/gfx/renderable.h
index 565f705..9b25645 100644
--- a/gfx/renderable.h
+++ b/gfx/renderable.h
@@ -2,7 +2,7 @@
#include <special_members.hpp>
-class Shader;
+class SceneShader;
class Renderable {
public:
@@ -10,5 +10,5 @@ public:
virtual ~Renderable() = default;
DEFAULT_MOVE_COPY(Renderable);
- virtual void render(const Shader & shader) const = 0;
+ virtual void render(const SceneShader & shader) const = 0;
};
diff --git a/ui/editNetwork.cpp b/ui/editNetwork.cpp
index 277407f..991cbc3 100644
--- a/ui/editNetwork.cpp
+++ b/ui/editNetwork.cpp
@@ -5,7 +5,7 @@
#include "text.h"
#include <game/gamestate.h>
#include <game/geoData.h>
-#include <gfx/gl/shader.h>
+#include <gfx/gl/sceneShader.h>
#include <gfx/models/texture.h>
constexpr const glm::u8vec4 TRANSPARENT_BLUE {30, 50, 255, 200};
@@ -47,17 +47,17 @@ EditNetwork::handleInput(const SDL_Event & e, const UIComponent::Position & pare
}
void
-EditNetwork::render(const Shader & shader) const
+EditNetwork::render(const SceneShader & shader) const
{
if (builder) {
blue.bind();
- shader.setModel(Location {}, Shader::Program::StaticPos);
+ shader.setModel(Location {}, SceneShader::Program::StaticPos);
builder->render(shader);
}
}
void
-EditNetwork::Builder::render(const Shader & shader) const
+EditNetwork::Builder::render(const SceneShader & shader) const
{
candidateLinks.apply<const Renderable>(&Renderable::render, shader);
}
diff --git a/ui/editNetwork.h b/ui/editNetwork.h
index 3501ac9..1ba2e13 100644
--- a/ui/editNetwork.h
+++ b/ui/editNetwork.h
@@ -18,7 +18,7 @@ public:
bool click(const SDL_MouseButtonEvent & e, const Ray &) override;
bool move(const SDL_MouseMotionEvent & e, const Ray &) override;
bool handleInput(const SDL_Event & e, const UIComponent::Position &) override;
- void render(const Shader &) const override;
+ void render(const SceneShader &) const override;
void render(const UIShader & shader, const UIComponent::Position & pos) const override;
using NetworkClickPos = std::variant<glm::vec3, Node::Ptr>;
@@ -26,7 +26,7 @@ public:
class Builder {
public:
virtual ~Builder() = default;
- virtual void render(const Shader & shader) const;
+ virtual void render(const SceneShader & shader) const;
virtual std::string hint() const = 0;
virtual void click(Network *, const GeoData *, const SDL_MouseButtonEvent &, const Ray &) = 0;
virtual void move(Network *, const GeoData *, const SDL_MouseMotionEvent &, const Ray &) = 0;
diff --git a/ui/gameMainSelector.cpp b/ui/gameMainSelector.cpp
index a5356ab..0fbf687 100644
--- a/ui/gameMainSelector.cpp
+++ b/ui/gameMainSelector.cpp
@@ -29,7 +29,7 @@ GameMainSelector::render(const UIShader & shader, const Position & parentPos) co
}
void
-GameMainSelector::render(const Shader & shader) const
+GameMainSelector::render(const SceneShader & shader) const
{
if (target) {
target->render(shader);
@@ -112,6 +112,6 @@ GameMainSelector::Component::render(const UIShader &, const UIComponent::Positio
}
void
-GameMainSelector::Component::render(const Shader &) const
+GameMainSelector::Component::render(const SceneShader &) const
{
}
diff --git a/ui/gameMainSelector.h b/ui/gameMainSelector.h
index 38d8eb1..9c05127 100644
--- a/ui/gameMainSelector.h
+++ b/ui/gameMainSelector.h
@@ -21,13 +21,13 @@ public:
virtual bool move(const SDL_MouseMotionEvent &, const Ray &);
virtual bool handleInput(const SDL_Event &, const Position & pos);
virtual void render(const UIShader & shader, const Position & pos) const;
- virtual void render(const Shader &) const;
+ virtual void render(const SceneShader &) const;
};
GameMainSelector(const Camera * c, glm::vec2 size);
void render(const UIShader & shader, const Position & pos) const override;
- void render(const Shader & shader) const override;
+ void render(const SceneShader & shader) const override;
bool handleInput(const SDL_Event & e, const Position &) override;
diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp
index c08588d..792ffab 100644
--- a/ui/gameMainWindow.cpp
+++ b/ui/gameMainWindow.cpp
@@ -59,7 +59,7 @@ GameMainWindow::render() const
Window::render();
}
-const Shader &
+const SceneShader &
GameMainWindow::getShader() const
{
return shader;
diff --git a/ui/gameMainWindow.h b/ui/gameMainWindow.h
index 2c2c501..09d17d1 100644
--- a/ui/gameMainWindow.h
+++ b/ui/gameMainWindow.h
@@ -2,7 +2,7 @@
#include "chronology.hpp"
#include "gfx/gl/camera.h"
-#include "gfx/gl/shader.h"
+#include "gfx/gl/sceneShader.h"
#include "sceneRenderer.h"
#include "window.h"
#include <cstddef>
@@ -16,7 +16,7 @@ public:
void render() const override;
private:
- const Shader & getShader() const override;
- Shader shader;
+ const SceneShader & getShader() const override;
+ SceneShader shader;
Camera camera;
};
diff --git a/ui/sceneRenderer.h b/ui/sceneRenderer.h
index 1c01069..6176f1b 100644
--- a/ui/sceneRenderer.h
+++ b/ui/sceneRenderer.h
@@ -1,6 +1,6 @@
#pragma once
-#include "gfx/gl/shader.h"
+#include "gfx/gl/sceneShader.h"
#include "lib/glArrays.h"
#include <functional>
diff --git a/ui/window.h b/ui/window.h
index dc3c528..b3d3f68 100644
--- a/ui/window.h
+++ b/ui/window.h
@@ -10,7 +10,7 @@
#include <special_members.hpp>
#include <string>
-class Shader;
+class SceneShader;
class Window {
public:
@@ -30,7 +30,7 @@ public:
protected:
[[nodiscard]] SDL_GLContext glContext() const;
virtual void render() const;
- virtual const Shader & getShader() const = 0;
+ virtual const SceneShader & getShader() const = 0;
using SDL_WindowPtr = wrapped_ptrt<SDL_Window, SDL_CreateWindow, SDL_DestroyWindow>;
const glm::ivec2 size;
diff --git a/ui/worldOverlay.h b/ui/worldOverlay.h
index 028122a..18fab3f 100644
--- a/ui/worldOverlay.h
+++ b/ui/worldOverlay.h
@@ -1,9 +1,9 @@
#pragma once
-class Shader;
+class SceneShader;
class WorldOverlay {
public:
virtual ~WorldOverlay() = default;
- virtual void render(const Shader &) const = 0;
+ virtual void render(const SceneShader &) const = 0;
};