summaryrefslogtreecommitdiff
path: root/ui/mainWindow.cpp
blob: 8d46d43f5a155f3f39079ffd9d9ffdfd48e7116a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#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, 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)};
	}

	ImGui_ImplSDL2_InitForOpenGL(m_window, glContext.get());
	ImGui_ImplOpenGL3_Init();
}

MainWindow::~MainWindow()
{
	ImGui_ImplOpenGL3_Shutdown();
	ImGui_ImplSDL2_Shutdown();
}