summaryrefslogtreecommitdiff
path: root/ui/mainWindow.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-07-02 18:20:22 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-07-02 18:20:22 +0100
commit9d6d2c0eb21b6295b2668c23f0ef386d5827a83f (patch)
treeec4bedce6f3a695aa75412f30259e0f791f46f82 /ui/mainWindow.cpp
parentAdd an InstanceVertices partition perf test (diff)
parentBuild ImGui as a static library (diff)
downloadilt-9d6d2c0eb21b6295b2668c23f0ef386d5827a83f.tar.bz2
ilt-9d6d2c0eb21b6295b2668c23f0ef386d5827a83f.tar.xz
ilt-9d6d2c0eb21b6295b2668c23f0ef386d5827a83f.zip
Psycho-rebased branch imgui on top of main
Diffstat (limited to 'ui/mainWindow.cpp')
-rw-r--r--ui/mainWindow.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/ui/mainWindow.cpp b/ui/mainWindow.cpp
new file mode 100644
index 0000000..38d6a6e
--- /dev/null
+++ b/ui/mainWindow.cpp
@@ -0,0 +1,27 @@
+#include "mainWindow.h"
+#include <format>
+#include <stdexcept>
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
+#include "backends/imgui_impl_opengl3.h"
+#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_OPENGL} { }
+
+MainWindow::MainWindow(size_t w, size_t h, const std::string & 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)};
+ }
+
+ ImGui_ImplSDL2_InitForOpenGL(m_window, glContext.get());
+ ImGui_ImplOpenGL3_Init();
+}
+
+MainWindow::~MainWindow()
+{
+ ImGui_ImplOpenGL3_Shutdown();
+ ImGui_ImplSDL2_Shutdown();
+}