summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/applicationBase.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/ui/applicationBase.cpp b/ui/applicationBase.cpp
index cad449d..5278228 100644
--- a/ui/applicationBase.cpp
+++ b/ui/applicationBase.cpp
@@ -1,22 +1,30 @@
#include "applicationBase.h"
#include <SDL2/SDL.h>
+#include <stdexcept>
ApplicationBase::ApplicationBase()
{
- SDL_Init(SDL_INIT_EVERYTHING);
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
+ throw std::runtime_error(SDL_GetError());
+ }
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+ const auto setGlAttribute = [](auto attr, auto value) {
+ if (SDL_GL_SetAttribute(attr, value) < 0) {
+ throw std::runtime_error(SDL_GetError());
+ }
+ };
+ setGlAttribute(SDL_GL_RED_SIZE, 8);
+ setGlAttribute(SDL_GL_GREEN_SIZE, 8);
+ setGlAttribute(SDL_GL_BLUE_SIZE, 8);
+ setGlAttribute(SDL_GL_ALPHA_SIZE, 8);
+ setGlAttribute(SDL_GL_BUFFER_SIZE, 32);
+ setGlAttribute(SDL_GL_DEPTH_SIZE, 16);
+ setGlAttribute(SDL_GL_DOUBLEBUFFER, 1);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 5);
- SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
+ setGlAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
+ setGlAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
+ setGlAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
+ setGlAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
}
ApplicationBase::~ApplicationBase()