From 8a0f6d6eee6162d1a10b20512e2f2c86a0278a34 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Mon, 21 Jan 2019 20:11:29 +0100 Subject: Add events wrapper --- wrapsdl2.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'wrapsdl2.cpp') 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 +#endif + extern "C" { #include } 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"); } -- cgit v1.2.1