X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2Finit.cpp;h=dfadffe16f0c1591dc76810a47c7dfbeae3c6463;hb=HEAD;hp=f4bcd01f45a230c4a1d928f967f60c0ff494ba19;hpb=86d82a0b535e88d841a927f3574cc9bd228f55fe;p=blank.git diff --git a/src/app/init.cpp b/src/app/init.cpp index f4bcd01..dfadffe 100644 --- a/src/app/init.cpp +++ b/src/app/init.cpp @@ -6,76 +6,12 @@ #include #include #include +#include #include -namespace { - -std::string sdl_error_append(std::string msg) { - const char *error = SDL_GetError(); - if (*error != '\0') { - msg += ": "; - msg += error; - SDL_ClearError(); - } - 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') { - msg += ": "; - msg += error; - } - return msg; -} - -} - namespace blank { -AlutError::AlutError(ALenum num) -: std::runtime_error(alutGetErrorString(num)) { - -} - -AlutError::AlutError(ALenum num, const std::string &msg) -: std::runtime_error(alut_error_append(num, 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()) { - -} - -SDLError::SDLError(const std::string &msg) -: std::runtime_error(sdl_error_append(msg)) { - -} - - InitSDL::InitSDL() { if (SDL_Init(SDL_INIT_EVENTS) != 0) { throw SDLError("SDL_Init(SDL_INIT_EVENTS)"); @@ -91,6 +27,8 @@ 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() { @@ -137,7 +75,7 @@ InitAL::InitAL() { } } -InitAL::~InitAL() { +InitAL::~InitAL() throw(AlutError) { if (!alutExit()) { throw AlutError(alutGetError(), "alutExit"); } @@ -155,9 +93,9 @@ InitGL::InitGL(bool double_buffer, int sample_size) { throw SDLError("SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE)"); } - if (double_buffer) { - if (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) != 0) { - throw SDLError("SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1)"); + if (!double_buffer) { + if (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0) != 0) { + throw SDLError("SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0)"); } }