summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui/gameMainWindow.cpp3
-rw-r--r--ui/gameMainWindow.h1
-rw-r--r--ui/uiComponent.h12
-rw-r--r--ui/window.cpp11
-rw-r--r--ui/window.h2
5 files changed, 24 insertions, 5 deletions
diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp
index b41fc56..cd9d3e4 100644
--- a/ui/gameMainWindow.cpp
+++ b/ui/gameMainWindow.cpp
@@ -34,6 +34,5 @@ GameMainWindow::render(const GameState * gameState) const
{
glEnable(GL_DEPTH_TEST);
gameState->world.apply<Renderable>(&Renderable::render, shader);
- glDisable(GL_DEPTH_TEST);
- // do ui bits
+ Window::render(gameState);
}
diff --git a/ui/gameMainWindow.h b/ui/gameMainWindow.h
index 36f8e80..8b88f11 100644
--- a/ui/gameMainWindow.h
+++ b/ui/gameMainWindow.h
@@ -4,7 +4,6 @@
#include "chronology.hpp"
#include "gfx/gl/camera.h"
#include "gfx/gl/shader.h"
-#include "gfx/gl/uiShader.h"
#include "window.h"
#include <cstddef>
diff --git a/ui/uiComponent.h b/ui/uiComponent.h
new file mode 100644
index 0000000..cd21de3
--- /dev/null
+++ b/ui/uiComponent.h
@@ -0,0 +1,12 @@
+#ifndef UICOMPONENT_H
+#define UICOMPONENT_H
+
+class UIShader;
+
+class UIComponent {
+public:
+ virtual ~UIComponent() = default;
+ virtual void render(const UIShader &) const = 0;
+};
+
+#endif
diff --git a/ui/window.cpp b/ui/window.cpp
index d9e0467..cd4a202 100644
--- a/ui/window.cpp
+++ b/ui/window.cpp
@@ -1,5 +1,6 @@
#include "window.h"
-#include "ui/inputHandler.h"
+#include "inputHandler.h"
+#include "uiComponent.h"
#include <GL/glew.h>
#include <optional>
#include <stdexcept>
@@ -73,3 +74,11 @@ Window::refresh(const GameState * gameState) const
swapBuffers();
}
+
+void
+Window::render(const GameState *) const
+{
+ uiShader.use();
+ glDisable(GL_DEPTH_TEST);
+ inputStack.apply<UIComponent>(&UIComponent::render, uiShader);
+}
diff --git a/ui/window.h b/ui/window.h
index 97a0253..9c6d023 100644
--- a/ui/window.h
+++ b/ui/window.h
@@ -30,7 +30,7 @@ public:
protected:
SDL_GLContext glContext() const;
- virtual void render(const GameState *) const = 0;
+ virtual void render(const GameState *) const;
using SDL_WindowPtr = wrapped_ptrt<SDL_Window, SDL_CreateWindow, SDL_DestroyWindow>;
SDL_WindowPtr m_window;