diff options
-rw-r--r-- | gfx/gl/shaders/uiShader.fs | 11 | ||||
-rw-r--r-- | gfx/gl/shaders/uiShader.vs | 13 | ||||
-rw-r--r-- | gfx/gl/shaders/uiShaderFont.fs | 12 | ||||
-rw-r--r-- | gfx/gl/uiShader.cpp | 27 | ||||
-rw-r--r-- | gfx/gl/uiShader.h | 47 | ||||
-rw-r--r-- | ui/editNetwork.cpp | 2 | ||||
-rw-r--r-- | ui/editNetwork.h | 2 | ||||
-rw-r--r-- | ui/gameMainSelector.cpp | 6 | ||||
-rw-r--r-- | ui/gameMainSelector.h | 5 | ||||
-rw-r--r-- | ui/gameMainWindow.cpp | 6 | ||||
-rw-r--r-- | ui/manualCameraController.cpp | 2 | ||||
-rw-r--r-- | ui/manualCameraController.h | 3 | ||||
-rw-r--r-- | ui/queryTool.cpp | 2 | ||||
-rw-r--r-- | ui/queryTool.h | 2 | ||||
-rw-r--r-- | ui/uiComponent.h | 3 | ||||
-rw-r--r-- | ui/windowContent.cpp | 2 | ||||
-rw-r--r-- | ui/windowContent.h | 6 |
17 files changed, 16 insertions, 135 deletions
diff --git a/gfx/gl/shaders/uiShader.fs b/gfx/gl/shaders/uiShader.fs deleted file mode 100644 index c5f4e92..0000000 --- a/gfx/gl/shaders/uiShader.fs +++ /dev/null @@ -1,11 +0,0 @@ -#version 330 core - -in vec2 texCoord0; - -uniform sampler2D sampler; - -void -main() -{ - gl_FragColor = texture(sampler, texCoord0); -} diff --git a/gfx/gl/shaders/uiShader.vs b/gfx/gl/shaders/uiShader.vs deleted file mode 100644 index e9e4373..0000000 --- a/gfx/gl/shaders/uiShader.vs +++ /dev/null @@ -1,13 +0,0 @@ -#version 330 core - -in vec4 position; - -out vec2 texCoord0; -uniform mat4 uiProjection; - -void -main() -{ - gl_Position = uiProjection * vec4(position.xy, 0.0, 1.0); - texCoord0 = position.zw; -} diff --git a/gfx/gl/shaders/uiShaderFont.fs b/gfx/gl/shaders/uiShaderFont.fs deleted file mode 100644 index a1ef6ef..0000000 --- a/gfx/gl/shaders/uiShaderFont.fs +++ /dev/null @@ -1,12 +0,0 @@ -#version 330 core - -in vec2 texCoord0; - -uniform sampler2D sampler; -uniform vec3 colour; - -void -main() -{ - gl_FragColor = vec4(colour, texture(sampler, texCoord0).r); -} diff --git a/gfx/gl/uiShader.cpp b/gfx/gl/uiShader.cpp deleted file mode 100644 index 23da9dc..0000000 --- a/gfx/gl/uiShader.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "uiShader.h" -#include "gl_traits.h" -#include <gfx/gl/program.h> -#include <gfx/gl/shader.h> -#include <gfx/gl/shaders/fs-uiShader.h> -#include <gfx/gl/shaders/fs-uiShaderFont.h> -#include <gfx/gl/shaders/vs-uiShader.h> -#include <glm/glm.hpp> -#include <glm/gtc/type_ptr.hpp> - -UIShader::IconProgram::IconProgram(const glm::mat4 & vp) : UIProgram {vp, uiShader_vs, uiShader_fs} { } - -UIShader::TextProgram::TextProgram(const glm::mat4 & vp) : UIProgram {vp, uiShader_vs, uiShaderFont_fs} { } - -UIShader::UIShader(size_t width, size_t height) : - UIShader {glm::ortho<float>(0, static_cast<float>(width), 0, static_cast<float>(height))} -{ -} - -UIShader::UIShader(const glm::mat4 & viewProjection) : icon {viewProjection}, text {viewProjection} { } - -void -UIShader::TextProgram::use(const RGB & colour) const -{ - Program::use(); - glUniform(colorLoc, colour); -} diff --git a/gfx/gl/uiShader.h b/gfx/gl/uiShader.h deleted file mode 100644 index 6d00166..0000000 --- a/gfx/gl/uiShader.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include "config/types.h" -#include "gl_traits.h" -#include "program.h" -#include <cstddef> -#include <glad/gl.h> -#include <glm/glm.hpp> -#include <glm/gtc/type_ptr.hpp> - -class UIShader { -public: - UIShader(std::size_t width, std::size_t height); - -private: - explicit UIShader(const glm::mat4 & viewProjection); - - class UIProgram : public Program { - public: - template<typename... S> - explicit UIProgram(const glm::mat4 & vp, S &&... srcs) : Program {std::forward<S>(srcs)...} - { - const RequiredUniformLocation uiProjectionLoc {*this, "uiProjection"}; - glUseProgram(*this); - glUniform(uiProjectionLoc, vp); - } - }; - - class IconProgram : public UIProgram { - public: - explicit IconProgram(const glm::mat4 & vp); - using Program::use; - }; - - class TextProgram : public UIProgram { - public: - explicit TextProgram(const glm::mat4 & vp); - void use(const RGB & colour) const; - - private: - RequiredUniformLocation colorLoc {*this, "colour"}; - }; - -public: - IconProgram icon; - TextProgram text; -}; diff --git a/ui/editNetwork.cpp b/ui/editNetwork.cpp index ac9aef9..3a28af7 100644 --- a/ui/editNetwork.cpp +++ b/ui/editNetwork.cpp @@ -65,7 +65,7 @@ EditNetwork::Builder::setHeightsFor(Network * network, const Link::CCollection & } void -EditNetwork::render(const UIShader &) +EditNetwork::render() { ImGui::Begin("Edit Network"); diff --git a/ui/editNetwork.h b/ui/editNetwork.h index c25bef2..aa5676a 100644 --- a/ui/editNetwork.h +++ b/ui/editNetwork.h @@ -17,7 +17,7 @@ public: bool move(const SDL_MouseMotionEvent & e, const Ray<GlobalPosition3D> &) override; bool handleInput(const SDL_Event & e) override; void render(const SceneShader &, const Frustum &) const override; - void render(const UIShader & shader) override; + void render() override; using NetworkClickPos = std::variant<GlobalPosition3D, Node::Ptr>; diff --git a/ui/gameMainSelector.cpp b/ui/gameMainSelector.cpp index 7878eb4..55d0ae0 100644 --- a/ui/gameMainSelector.cpp +++ b/ui/gameMainSelector.cpp @@ -13,10 +13,10 @@ GameMainSelector::GameMainSelector(const Camera * c) : camera {c} { } constexpr ScreenAbsCoord TargetPos {5, 45}; void -GameMainSelector::render(const UIShader & shader) const +GameMainSelector::render() const { if (target) { - target->render(shader); + target->render(); } } @@ -86,7 +86,7 @@ GameMainSelector::Component::handleInput(const SDL_Event &) } void -GameMainSelector::Component::render(const UIShader &) +GameMainSelector::Component::render() { } diff --git a/ui/gameMainSelector.h b/ui/gameMainSelector.h index 9560fc6..e6a86d2 100644 --- a/ui/gameMainSelector.h +++ b/ui/gameMainSelector.h @@ -9,7 +9,6 @@ class SceneShader; template<typename> class Ray; -class UIShader; class Camera; class GameMainSelector : public UIComponent, public WorldOverlay { @@ -21,13 +20,13 @@ public: virtual bool click(const SDL_MouseButtonEvent &, const Ray<GlobalPosition3D> &); virtual bool move(const SDL_MouseMotionEvent &, const Ray<GlobalPosition3D> &); virtual bool handleInput(const SDL_Event &); - virtual void render(const UIShader & shader); + virtual void render(); virtual void render(const SceneShader &, const Frustum &) const; }; GameMainSelector(const Camera * c); - void render(const UIShader & shader) const override; + void render() const override; void render(const SceneShader & shader, const Frustum &) const override; bool handleInput(const SDL_Event & e) override; diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp index 280d1a8..cfc64e3 100644 --- a/ui/gameMainWindow.cpp +++ b/ui/gameMainWindow.cpp @@ -25,7 +25,7 @@ public: explicit GameMainToolbar(GameMainSelector * gms) : gms {gms} { } void - render(const UIShader &) const override + render() const override { if (IltGui::BeginToolbar("bottomBar", ImGuiDir_Down, TOOLBAR_HEIGHT)) { if (ImGui::ImageButton("Build rails", *buildRailsIcon, TOOLBAR_ICON_SIZE)) { @@ -49,7 +49,7 @@ private: GameMainSelector * gms; }; -GameMainWindow::GameMainWindow(size_t w, size_t h) : WindowContent {w, h}, SceneRenderer {{w, h}, 0} +GameMainWindow::GameMainWindow(size_t w, size_t h) : SceneRenderer {{w, h}, 0} { uiComponents.create<ManualCameraController>(glm::vec2 {310'727'624, 494'018'810}); auto gms = uiComponents.create<GameMainSelector>(&camera); @@ -90,7 +90,7 @@ GameMainWindow::render() const glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_DEPTH_TEST); - uiComponents.apply(&UIComponent::render, uiShader); + uiComponents.apply(&UIComponent::render); } void diff --git a/ui/manualCameraController.cpp b/ui/manualCameraController.cpp index 128701d..557945e 100644 --- a/ui/manualCameraController.cpp +++ b/ui/manualCameraController.cpp @@ -72,7 +72,7 @@ ManualCameraController::handleInput(const SDL_Event & e) } void -ManualCameraController::render(const UIShader &) const +ManualCameraController::render() const { } diff --git a/ui/manualCameraController.h b/ui/manualCameraController.h index 0cfa38c..d3bf0c4 100644 --- a/ui/manualCameraController.h +++ b/ui/manualCameraController.h @@ -6,7 +6,6 @@ #include <glm/glm.hpp> #include <maths.h> -class UIShader; class Camera; class ManualCameraController : public CameraController, public UIComponent { @@ -14,7 +13,7 @@ public: explicit ManualCameraController(GlobalPosition2D f) : focus {f} { } bool handleInput(const SDL_Event & e) override; - void render(const UIShader &) const override; + void render() const override; void updateCamera(Camera * camera) const override; diff --git a/ui/queryTool.cpp b/ui/queryTool.cpp index e046084..d016afa 100644 --- a/ui/queryTool.cpp +++ b/ui/queryTool.cpp @@ -31,7 +31,7 @@ QueryTool::click(const SDL_MouseButtonEvent & event, const Ray<GlobalPosition3D> } void -QueryTool::render(const UIShader &) +QueryTool::render() { ImGui::Begin("Query Tool"); ImGui::TextUnformatted(clicked.c_str()); diff --git a/ui/queryTool.h b/ui/queryTool.h index cef4b75..4d16960 100644 --- a/ui/queryTool.h +++ b/ui/queryTool.h @@ -7,7 +7,7 @@ protected: using GameMainSelector::Component::render; bool click(const SDL_MouseButtonEvent &, const Ray<GlobalPosition3D> &) override; - void render(const UIShader & shader) override; + void render() override; private: std::string clicked; diff --git a/ui/uiComponent.h b/ui/uiComponent.h index 9178c6b..6ee347e 100644 --- a/ui/uiComponent.h +++ b/ui/uiComponent.h @@ -3,7 +3,6 @@ #include <glm/glm.hpp> #include <special_members.h> -class UIShader; union SDL_Event; class UIComponent { @@ -14,6 +13,6 @@ public: NO_MOVE(UIComponent); NO_COPY(UIComponent); - virtual void render(const UIShader &) const = 0; + virtual void render() const = 0; virtual bool handleInput(const SDL_Event &) = 0; }; diff --git a/ui/windowContent.cpp b/ui/windowContent.cpp index f55a8d5..0f6dc04 100644 --- a/ui/windowContent.cpp +++ b/ui/windowContent.cpp @@ -1,8 +1,6 @@ #include "windowContent.h" #include "SDL_events.h" -WindowContent::WindowContent(size_t width, size_t height) : uiShader {width, height} { } - void WindowContent::tick(TickDuration) { diff --git a/ui/windowContent.h b/ui/windowContent.h index 474445a..d7fcad2 100644 --- a/ui/windowContent.h +++ b/ui/windowContent.h @@ -2,16 +2,13 @@ #include "chronology.h" #include "collection.h" -#include "gfx/gl/uiShader.h" #include "special_members.h" #include "stdTypeDefs.h" #include "uiComponent.h" // IWYU pragma: keep -#include <functional> class WindowContent : public StdTypeDefs<WindowContent> { public: - using Factory = std::function<Ptr(size_t width, size_t height)>; - WindowContent(size_t width, size_t height); + WindowContent() = default; virtual ~WindowContent() = default; NO_MOVE(WindowContent); NO_COPY(WindowContent); @@ -22,5 +19,4 @@ public: protected: ::Collection<UIComponent> uiComponents; - UIShader uiShader; }; |