diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-12-18 19:28:54 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-12-18 19:28:54 +0000 |
commit | bcdc5c98b356d926939b226a3962d97763295d3b (patch) | |
tree | b56079b97c51e2d457dc68ba3f7ce1cfa867c5d9 /ui | |
parent | Need a way to select the UI shader (diff) | |
download | ilt-bcdc5c98b356d926939b226a3962d97763295d3b.tar.bz2 ilt-bcdc5c98b356d926939b226a3962d97763295d3b.tar.xz ilt-bcdc5c98b356d926939b226a3962d97763295d3b.zip |
Window handles UIComponent rendering
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gameMainWindow.cpp | 3 | ||||
-rw-r--r-- | ui/gameMainWindow.h | 1 | ||||
-rw-r--r-- | ui/uiComponent.h | 12 | ||||
-rw-r--r-- | ui/window.cpp | 11 | ||||
-rw-r--r-- | ui/window.h | 2 |
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;
|