diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-12-03 01:59:49 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-12-03 01:59:49 +0000 |
commit | 68fcd4676cc6f4ffce2597690d2fca26f782f3d6 (patch) | |
tree | 78788c8552decc8ceb5484bf6c3c4c0e745069b8 | |
parent | Split SceneProvider out (diff) | |
download | ilt-68fcd4676cc6f4ffce2597690d2fca26f782f3d6.tar.bz2 ilt-68fcd4676cc6f4ffce2597690d2fca26f782f3d6.tar.xz ilt-68fcd4676cc6f4ffce2597690d2fca26f782f3d6.zip |
Check error state during setup, set OpenGL version to 3.3 core
Updates all shaders to 330 core too.
-rw-r--r-- | gfx/gl/shaders/uiShader.fs | 2 | ||||
-rw-r--r-- | gfx/gl/shaders/uiShader.vs | 2 | ||||
-rw-r--r-- | gfx/gl/shaders/uiShaderFont.fs | 2 | ||||
-rw-r--r-- | ui/applicationBase.cpp | 32 |
4 files changed, 23 insertions, 15 deletions
diff --git a/gfx/gl/shaders/uiShader.fs b/gfx/gl/shaders/uiShader.fs index 907c4f1..c5f4e92 100644 --- a/gfx/gl/shaders/uiShader.fs +++ b/gfx/gl/shaders/uiShader.fs @@ -1,4 +1,4 @@ -#version 130 +#version 330 core in vec2 texCoord0; diff --git a/gfx/gl/shaders/uiShader.vs b/gfx/gl/shaders/uiShader.vs index 0d00fed..e9e4373 100644 --- a/gfx/gl/shaders/uiShader.vs +++ b/gfx/gl/shaders/uiShader.vs @@ -1,4 +1,4 @@ -#version 130 +#version 330 core in vec4 position; diff --git a/gfx/gl/shaders/uiShaderFont.fs b/gfx/gl/shaders/uiShaderFont.fs index bee455d..a1ef6ef 100644 --- a/gfx/gl/shaders/uiShaderFont.fs +++ b/gfx/gl/shaders/uiShaderFont.fs @@ -1,4 +1,4 @@ -#version 130 +#version 330 core in vec2 texCoord0; 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() |