summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/gameMainWindow.cpp14
-rw-r--r--ui/gameMainWindow.h6
-rw-r--r--ui/window.cpp6
-rw-r--r--ui/window.h6
4 files changed, 12 insertions, 20 deletions
diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp
index 41d55da..b904388 100644
--- a/ui/gameMainWindow.cpp
+++ b/ui/gameMainWindow.cpp
@@ -33,10 +33,7 @@ public:
class GameMainSelector : public UIComponent {
public:
- GameMainSelector(const Camera * c, glm::vec2 size, const GameState * gs) :
- UIComponent {{{}, size}}, camera {c}, gameState {gs}
- {
- }
+ GameMainSelector(const Camera * c, glm::vec2 size) : UIComponent {{{}, size}}, camera {c} { }
void
render(const UIShader &, const Position &) const override
@@ -63,13 +60,12 @@ public:
private:
const Camera * camera;
- const GameState * gameState;
};
-GameMainWindow::GameMainWindow(size_t w, size_t h, const GameState * gameState) :
+GameMainWindow::GameMainWindow(size_t w, size_t h) :
Window {w, h, "I Like Trains"}, camera {{-1250.0F, -1250.0F, 35.0F}, quarter_pi, rdiv(w, h), 0.1F, 10000.0F}
{
- uiComponents.create<GameMainSelector>(&camera, glm::vec2 {w, h}, gameState);
+ uiComponents.create<GameMainSelector>(&camera, glm::vec2 {w, h});
uiComponents.create<GameMainToolbar>();
uiComponents.create<ManualCameraController>(glm::vec2 {-1150, -1150});
@@ -86,9 +82,9 @@ GameMainWindow::tick(TickDuration)
}
void
-GameMainWindow::render(const GameState * gameState) const
+GameMainWindow::render() const
{
glEnable(GL_DEPTH_TEST);
gameState->world.apply<Renderable>(&Renderable::render, shader);
- Window::render(gameState);
+ Window::render();
}
diff --git a/ui/gameMainWindow.h b/ui/gameMainWindow.h
index e26ad2d..68ad7ad 100644
--- a/ui/gameMainWindow.h
+++ b/ui/gameMainWindow.h
@@ -6,15 +6,13 @@
#include "window.h"
#include <cstddef>
-class GameState;
-
class GameMainWindow : public Window {
public:
- GameMainWindow(size_t w, size_t h, const GameState *);
+ GameMainWindow(size_t w, size_t h);
void tick(TickDuration) override;
- void render(const GameState * gameState) const override;
+ void render() const override;
private:
Shader shader;
diff --git a/ui/window.cpp b/ui/window.cpp
index 6a263aa..74a3a2f 100644
--- a/ui/window.cpp
+++ b/ui/window.cpp
@@ -77,18 +77,18 @@ Window::glContext() const
}
void
-Window::refresh(const GameState * gameState) const
+Window::refresh() const
{
SDL_GL_MakeCurrent(m_window, glContext());
clear(0.0F, 0.0F, 0.0F, 1.0F);
- render(gameState);
+ render();
swapBuffers();
}
void
-Window::render(const GameState *) const
+Window::render() const
{
glDisable(GL_DEPTH_TEST);
uiComponents.apply(&UIComponent::render, uiShader, UIComponent::Position {});
diff --git a/ui/window.h b/ui/window.h
index 49cdf45..b6ade60 100644
--- a/ui/window.h
+++ b/ui/window.h
@@ -10,8 +10,6 @@
#include <special_members.hpp>
#include <string>
-class GameState;
-
class Window {
public:
Window(size_t width, size_t height, const std::string & title);
@@ -21,7 +19,7 @@ public:
NO_MOVE(Window);
virtual void tick(TickDuration elapsed) = 0;
- void refresh(const GameState *) const;
+ void refresh() const;
bool handleInput(const SDL_Event & e);
void clear(float r, float g, float b, float a) const;
@@ -29,7 +27,7 @@ public:
protected:
[[nodiscard]] SDL_GLContext glContext() const;
- virtual void render(const GameState *) const;
+ virtual void render() const;
using SDL_WindowPtr = wrapped_ptrt<SDL_Window, SDL_CreateWindow, SDL_DestroyWindow>;
SDL_WindowPtr m_window;