X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2Finit.cpp;h=a0ea7b51ba5d614a3df13814c4eee90468d6fe1d;hb=fda38181732e58537331c919dd699eaa830ead50;hp=18816a424bdb3a972341311d72a9cda19fa19ac6;hpb=7c2a8b8285278b8a3077b311d82f05ea0463a96e;p=blank.git diff --git a/src/app/init.cpp b/src/app/init.cpp index 18816a4..a0ea7b5 100644 --- a/src/app/init.cpp +++ b/src/app/init.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -20,6 +21,15 @@ std::string sdl_error_append(std::string msg) { return msg; } +std::string net_error_append(std::string msg) { + const char *error = SDLNet_GetError(); + if (*error != '\0') { + msg += ": "; + msg += error; + } + return msg; +} + std::string alut_error_append(ALenum num, std::string msg) { const char *error = alutGetErrorString(num); if (*error != '\0') { @@ -44,6 +54,17 @@ AlutError::AlutError(ALenum num, const std::string &msg) } +NetError::NetError() +: std::runtime_error(SDLNet_GetError()) { + +} + +NetError::NetError(const std::string &msg) +: std::runtime_error(net_error_append(msg)) { + +} + + SDLError::SDLError() : std::runtime_error(SDL_GetError()) { @@ -56,8 +77,8 @@ SDLError::SDLError(const std::string &msg) InitSDL::InitSDL() { - if (SDL_Init(SDL_INIT_VIDEO) != 0) { - throw SDLError("SDL_Init(SDL_INIT_VIDEO)"); + if (SDL_Init(SDL_INIT_EVENTS) != 0) { + throw SDLError("SDL_Init(SDL_INIT_EVENTS)"); } } @@ -66,6 +87,19 @@ InitSDL::~InitSDL() { } +InitVideo::InitVideo() { + if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) { + throw SDLError("SDL_InitSubSystem(SDL_INIT_VIDEO)"); + } + // SDL seems to start out in text input state + SDL_StopTextInput(); +} + +InitVideo::~InitVideo() { + SDL_QuitSubSystem(SDL_INIT_VIDEO); +} + + InitIMG::InitIMG() { if (IMG_Init(IMG_INIT_PNG) == 0) { throw SDLError("IMG_Init(IMG_INIT_PNG)"); @@ -77,6 +111,17 @@ InitIMG::~InitIMG() { } +InitNet::InitNet() { + if (SDLNet_Init() != 0) { + throw SDLError("SDLNet_Init()"); + } +} + +InitNet::~InitNet() { + SDLNet_Quit(); +} + + InitTTF::InitTTF() { if (TTF_Init() != 0) { throw SDLError("TTF_Init()"); @@ -198,8 +243,14 @@ InitGLEW::InitGLEW() { } -Init::Init(bool double_buffer, int sample_size) +InitHeadless::InitHeadless() : init_sdl() +, init_net() { + +} + +Init::Init(bool double_buffer, int sample_size) +: init_video() , init_img() , init_ttf() , init_gl(double_buffer, sample_size)