diff options
Diffstat (limited to 'wrapsdl2.cpp')
-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"); } |