#include "init.hpp"
#include <algorithm>
+#include <alut.h>
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
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()) {
}
+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)");