diff options
Diffstat (limited to 'src/sdl_main_window.cpp')
-rw-r--r-- | src/sdl_main_window.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/sdl_main_window.cpp b/src/sdl_main_window.cpp new file mode 100644 index 0000000..54b5388 --- /dev/null +++ b/src/sdl_main_window.cpp @@ -0,0 +1,34 @@ +#include "sdl_main_window.hpp" + +#include <stdexcept> + +namespace bookmouse { + +SdlMainWindow::SdlMainWindow(const SdlContext& sdlContext) +{ + sdlContext.setAttribute(SDL_GL_DOUBLEBUFFER, 1); + sdlContext.setAttribute(SDL_GL_DEPTH_SIZE, 24); + sdlContext.setAttribute(SDL_GL_STENCIL_SIZE, 8); + + SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | + SDL_WINDOW_ALLOW_HIGHDPI); + m_window = SDL_CreateWindow( + "Dear ImGui SDL2+OpenGL3 example", + SDL_WINDOWPOS_CENTERED, + SDL_WINDOWPOS_CENTERED, + 1280, + 720, + window_flags); + + if (m_window == nullptr) { + const auto* lastError = SDL_GetError(); + throw std::runtime_error{lastError}; + } +} + +SdlMainWindow::~SdlMainWindow() +{ + SDL_DestroyWindow(m_window); +} + +} // namespace bookmouse |