X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2Finit.cpp;h=18816a424bdb3a972341311d72a9cda19fa19ac6;hb=745729c1935276e6f49d108a0a465214aa93c3cb;hp=1cc0c2485b50db7e79a5fdd5baf242ef4201a72d;hpb=5d2da8a07411ad6417d6ed8d1be997189cf5ce89;p=blank.git diff --git a/src/app/init.cpp b/src/app/init.cpp index 1cc0c24..18816a4 100644 --- a/src/app/init.cpp +++ b/src/app/init.cpp @@ -1,6 +1,7 @@ #include "init.hpp" #include +#include #include #include #include @@ -19,10 +20,30 @@ std::string sdl_error_append(std::string msg) { 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)) { + +} + + SDLError::SDLError() : std::runtime_error(SDL_GetError()) { @@ -67,6 +88,19 @@ InitTTF::~InitTTF() { } +InitAL::InitAL() { + if (!alutInit(nullptr, nullptr)) { + throw AlutError(alutGetError(), "alutInit"); + } +} + +InitAL::~InitAL() { + if (!alutExit()) { + throw AlutError(alutGetError(), "alutExit"); + } +} + + InitGL::InitGL(bool double_buffer, int sample_size) { if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) != 0) { throw SDLError("SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3)");