diff options
-rw-r--r-- | ui/gameMainWindow.cpp | 5 | ||||
-rw-r--r-- | ui/gameMainWindow.h | 1 | ||||
-rw-r--r-- | ui/window.cpp | 13 | ||||
-rw-r--r-- | ui/window.h | 4 |
4 files changed, 13 insertions, 10 deletions
diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp index 7d5e19b..b41fc56 100644 --- a/ui/gameMainWindow.cpp +++ b/ui/gameMainWindow.cpp @@ -13,10 +13,7 @@ #include <memory> GameMainWindow::GameMainWindow(size_t w, size_t h) : - Window {static_cast<int>(w), static_cast<int>(h), "I Like Trains"}, uiShader {w, h}, camera {{-1250.0F, -1250.0F, - 35.0F}, - 70.0F, rdiv(w, h), - 0.1F, 10000.0F} + Window {w, h, "I Like Trains"}, camera {{-1250.0F, -1250.0F, 35.0F}, 70.0F, rdiv(w, h), 0.1F, 10000.0F} { inputStack.create<ManualCameraController>(glm::vec2 {-1150, -1150}); diff --git a/ui/gameMainWindow.h b/ui/gameMainWindow.h index 124d776..36f8e80 100644 --- a/ui/gameMainWindow.h +++ b/ui/gameMainWindow.h @@ -19,7 +19,6 @@ public: void render(const GameState * gameState) const override; private: - UIShader uiShader; Shader shader; Camera camera; }; diff --git a/ui/window.cpp b/ui/window.cpp index 2dc0c2a..d9e0467 100644 --- a/ui/window.cpp +++ b/ui/window.cpp @@ -21,11 +21,16 @@ SDL_GL_CreateContextAndGlewInit(SDL_Window * w) using GL_Context = std::remove_pointer_t<SDL_GLContext>;
using SDL_GLContextPtr = wrapped_ptrt<GL_Context, SDL_GL_CreateContextAndGlewInit, SDL_GL_DeleteContext>;
-Window::Window(int width, int height, const std::string & title) :
- m_window {title.c_str(), static_cast<int>(SDL_WINDOWPOS_CENTERED), static_cast<int>(SDL_WINDOWPOS_CENTERED), width,
- height, static_cast<Uint32>(SDL_WINDOW_OPENGL)}
+Window::Window(size_t width, size_t height, const std::string & title) :
+ m_window {title.c_str(), static_cast<int>(SDL_WINDOWPOS_CENTERED), static_cast<int>(SDL_WINDOWPOS_CENTERED),
+ static_cast<int>(width), static_cast<int>(height), static_cast<Uint32>(SDL_WINDOW_OPENGL)},
+ uiShader {[this](auto w) {
+ // must call glContent before creating the shader
+ glContext();
+ return w;
+ }(width),
+ height}
{
- glContext();
}
void
diff --git a/ui/window.h b/ui/window.h index 8bfc9c3..97a0253 100644 --- a/ui/window.h +++ b/ui/window.h @@ -3,6 +3,7 @@ #include "chronology.hpp"
#include "collection.hpp"
+#include "gfx/gl/uiShader.h"
#include "inputHandler.h" // IWYU pragma: keep
#include "ptr.hpp"
#include <SDL2/SDL.h>
@@ -14,7 +15,7 @@ class GameState; class Window {
public:
- Window(int width, int height, const std::string & title);
+ Window(size_t width, size_t height, const std::string & title);
virtual ~Window() = default;
NO_COPY(Window);
@@ -34,6 +35,7 @@ protected: using SDL_WindowPtr = wrapped_ptrt<SDL_Window, SDL_CreateWindow, SDL_DestroyWindow>;
SDL_WindowPtr m_window;
Collection<InputHandler> inputStack;
+ UIShader uiShader;
};
#endif
|