diff options
Diffstat (limited to 'src/libjin/render/window.cpp')
-rw-r--r-- | src/libjin/render/window.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/libjin/render/window.cpp b/src/libjin/render/window.cpp index 70e7e2d..1f55be8 100644 --- a/src/libjin/render/window.cpp +++ b/src/libjin/render/window.cpp @@ -18,17 +18,17 @@ namespace render { } - onlyonce void Window::init(const Window::Setting& setting) + onlyonce bool Window::_init(const SettingBase* s) { - CallOnce(_init(setting)); - } + if (SDL_Init(SDL_INIT_VIDEO) < 0) + return false; - inline void Window::_init(const Setting& setting) - { - width = setting.width; - height = setting.height; - const char* title = setting.title; - bool vsync = setting.vsync; + WindowSetting* setting = (WindowSetting*)s; + + width = setting->width; + height = setting->height; + bool vsync = setting->vsync; + const char* title = setting->title; if (wnd) { @@ -54,7 +54,11 @@ namespace render wy = SDL_WINDOWPOS_UNDEFINED; wnd = SDL_CreateWindow(title, wx, wy, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL); + if (wnd == NULL) + return false; ctx = SDL_GL_CreateContext(wnd); + if (ctx == NULL) + return false; SDL_GL_SetSwapInterval(vsync ? 1 : 0); SDL_GL_MakeCurrent(wnd, ctx); glClearColor(0.f, 0.f, 0.f, 1.f); @@ -66,6 +70,7 @@ namespace render Canvas::unbind(); swapBuffers(); + return true; } SDL_Window* Window::getWnd() @@ -78,11 +83,11 @@ namespace render return ctx; } - inline void Window::swapBuffers() - { - if (wnd) - SDL_GL_SwapWindow(wnd); - } + inline void Window::swapBuffers() + { + if (wnd) + SDL_GL_SwapWindow(wnd); + } } }
\ No newline at end of file |