diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-04-07 01:16:19 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-04-07 01:16:19 +0100 |
commit | 7e7ddf53b54e52f2106c4adce2818df7877254f1 (patch) | |
tree | 4dd85dd843d218683459778f329cd9424e4d5708 /ui | |
parent | Default environment direction light shines down, not up (diff) | |
download | ilt-7e7ddf53b54e52f2106c4adce2818df7877254f1.tar.bz2 ilt-7e7ddf53b54e52f2106c4adce2818df7877254f1.tar.xz ilt-7e7ddf53b54e52f2106c4adce2818df7877254f1.zip |
More uniform/flexible window constructors
Diffstat (limited to 'ui')
-rw-r--r-- | ui/mainWindow.cpp | 7 | ||||
-rw-r--r-- | ui/mainWindow.h | 6 | ||||
-rw-r--r-- | ui/window.cpp | 6 | ||||
-rw-r--r-- | ui/window.h | 2 |
4 files changed, 7 insertions, 14 deletions
diff --git a/ui/mainWindow.cpp b/ui/mainWindow.cpp index 73c0b5b..8d46d43 100644 --- a/ui/mainWindow.cpp +++ b/ui/mainWindow.cpp @@ -8,12 +8,7 @@ #include "backends/imgui_impl_sdl2.h" #pragma GCC diagnostic pop -MainWindow::MainWindow(size_t w, size_t h) : - MainWindow {w, h, "I Like Trains", SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL} -{ -} - -MainWindow::MainWindow(size_t w, size_t h, const std::string & title, Uint32 flags) : Window {w, h, title, flags} +MainWindow::MainWindow(size_t w, size_t h, const char * title, Uint32 flags) : Window {w, h, title, flags} { if (const auto version = gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress)); version < 30003) { throw std::runtime_error {std::format("Insufficient OpenGL version: {}", version)}; diff --git a/ui/mainWindow.h b/ui/mainWindow.h index fe26c5c..490ef09 100644 --- a/ui/mainWindow.h +++ b/ui/mainWindow.h @@ -5,12 +5,10 @@ class MainWindow : public Window { public: - MainWindow(size_t w, size_t h); + MainWindow( + size_t width, size_t height, const char * title, Uint32 flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL); ~MainWindow() override; NO_MOVE(MainWindow); NO_COPY(MainWindow); - -protected: - MainWindow(size_t width, size_t height, const std::string & title, Uint32 flags); }; diff --git a/ui/window.cpp b/ui/window.cpp index 732e9ef..3d4634e 100644 --- a/ui/window.cpp +++ b/ui/window.cpp @@ -7,10 +7,10 @@ #include "backends/imgui_impl_sdl2.h" #pragma GCC diagnostic pop -Window::Window(size_t width, size_t height, const std::string & title, Uint32 flags) : +Window::Window(size_t width, size_t height, const char * title, Uint32 flags) : size {static_cast<int>(width), static_cast<int>(height)}, - m_window {title.c_str(), static_cast<int>(SDL_WINDOWPOS_CENTERED), static_cast<int>(SDL_WINDOWPOS_CENTERED), size.x, - size.y, flags}, + m_window {title, static_cast<int>(SDL_WINDOWPOS_CENTERED), static_cast<int>(SDL_WINDOWPOS_CENTERED), size.x, size.y, + flags}, glContext {m_window} { } diff --git a/ui/window.h b/ui/window.h index 62c34de..0316a1f 100644 --- a/ui/window.h +++ b/ui/window.h @@ -15,7 +15,7 @@ using SDL_GLContextPtr = wrapped_ptrt<GL_Context, SDL_GL_CreateContext, SDL_GL_D class Window { public: - Window(size_t width, size_t height, const std::string & title, Uint32 flags); + Window(size_t width, size_t height, const char * title, Uint32 flags); virtual ~Window() = default; NO_COPY(Window); |