diff options
author | Nao Pross <naopross@thearcway.org> | 2019-01-21 20:11:29 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2019-01-21 20:25:38 +0100 |
commit | 8a0f6d6eee6162d1a10b20512e2f2c86a0278a34 (patch) | |
tree | 44c8202165566c7206bf6ac44b2febed0919588e /wrapsdl2.cpp | |
parent | Update wrapsdl2::window to use Renderer instead of Surface (diff) | |
download | libwsdl2-8a0f6d6eee6162d1a10b20512e2f2c86a0278a34.tar.gz libwsdl2-8a0f6d6eee6162d1a10b20512e2f2c86a0278a34.zip |
Add events wrapper
Diffstat (limited to '')
-rw-r--r-- | wrapsdl2.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/wrapsdl2.cpp b/wrapsdl2.cpp index f9f346b..3828abc 100644 --- a/wrapsdl2.cpp +++ b/wrapsdl2.cpp @@ -1,24 +1,44 @@ #include "wrapsdl2.hpp" #include "debug.hpp" +#ifdef WRAPSDL2_EXCEPTIONS +#include <exception> +#endif + extern "C" { #include <SDL2/SDL.h> } bool wrapsdl2::initialize(void) { if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { - npdebug("failed to initialize sdl video subsystem"); +#ifdef WRAPSDL2_EXCEPTIONS + throw std::runtime_error("failed to initialize sdl video subsystem"); +#endif + return false; + } + + if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0) { +#ifdef WRAPSDL2_EXCEPTIONS + throw std::runtime_error("failed to initialzie sdl events subsystem"); +#endif return false; } + npdebug("initialized sdl2"); + return true; } void wrapsdl2::quit(void) { if (SDL_WasInit(SDL_INIT_VIDEO)) SDL_QuitSubSystem(SDL_INIT_VIDEO); - + + if (SDL_WasInit(SDL_INIT_EVENTS)) + SDL_QuitSubSystem(SDL_INIT_EVENTS); + SDL_Quit(); + + npdebug("deinitialized (quit) sdl2"); } |