14 InitAlut::InitAlut() {
15 if (!alutInit(nullptr, nullptr)) {
16 throw AlutError("alutInit(nullptr, nullptr)");
20 InitAlut::~InitAlut() {
22 throw AlutError("alutExit()");
27 InitGL::InitGL(bool double_buffer, int multi_sample) {
28 if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) != 0) {
29 throw SDLError("SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3)");
31 if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3) != 0) {
32 throw SDLError("SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3)");
34 if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE) != 0) {
35 throw SDLError("SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE)");
39 if (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0) != 0) {
40 throw SDLError("SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0)");
44 if (multi_sample > 1) {
45 if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1) != 0) {
46 throw SDLError("SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1)");
48 if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, multi_sample) != 0) {
49 throw SDLError("SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, x)");
56 if (IMG_Init(IMG_INIT_PNG) == 0) {
57 throw SDLError("IMG_Init(IMG_INIT_PNG)");
61 InitIMG::~InitIMG() noexcept {
67 if (SDL_Init(SDL_INIT_VIDEO) != 0) {
68 throw SDLError("SDL_Init(SDL_INIT_VIDEO)");
70 // SDL seems to start out in text input state
74 InitSDL::~InitSDL() noexcept {
80 if (TTF_Init() != 0) {
81 throw SDLError("TTF_Init()");
85 InitTTF::~InitTTF() noexcept {
90 Init::Init(const Config &config)
92 , gl(config.double_buffer, config.multi_sample)