#ifndef SDL_H_A2226476 #define SDL_H_A2226476 #include #include #include #include class sdl_error : public std::logic_error { public: sdl_error() : std::logic_error(SDL_GetError()) {} }; class ttf_error : public std::logic_error { public: ttf_error() : std::logic_error(TTF_GetError()) {} }; class net_error : public std::logic_error { public: net_error() : std::logic_error(SDLNet_GetError()) {} }; class sdl_wrapper { public: sdl_wrapper() { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) { sdl_error ex; SDL_Quit(); throw ex; } } ~sdl_wrapper() { SDL_Quit(); } }; class ttf_wrapper { public: ttf_wrapper() { if (TTF_Init() == -1) { ttf_error ex; TTF_Quit(); throw ex; } } ~ttf_wrapper() { TTF_Quit(); } }; class net_wrapper { public: net_wrapper() { if (SDLNet_Init() == -1) { net_error ex; SDLNet_Quit(); throw ex; } } ~net_wrapper() { SDLNet_Quit(); } }; class window_deleter { public: void operator()(SDL_Window* ptr) { SDL_DestroyWindow(ptr); } }; using window_ptr = std::unique_ptr; class renderer_deleter { public: void operator()(SDL_Renderer* ptr) { SDL_DestroyRenderer(ptr); } }; using renderer_ptr = std::unique_ptr; class surface_deleter { public: void operator()(SDL_Surface* ptr) { SDL_FreeSurface(ptr); } }; using surface_ptr = std::unique_ptr; class texture_deleter { public: void operator()(SDL_Texture* ptr) { SDL_DestroyTexture(ptr); } }; using texture_ptr = std::unique_ptr; class font_deleter { public: void operator()(TTF_Font* ptr) { TTF_CloseFont(ptr); } }; using font_ptr = std::unique_ptr; #endif /* end of include guard: SDL_H_A2226476 */