summaryrefslogtreecommitdiff
path: root/src/utils/sdl2helper.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-03 02:52:18 +0300
committerAndrei Karas <akaras@inbox.ru>2016-09-03 02:52:49 +0300
commit694329376df2a2a491f1f665e4231a167ff11a3f (patch)
treea60f4ba0863cf011901f1cad92d4a6bf27128813 /src/utils/sdl2helper.cpp
parent6007cebe8ac49ca4f3d09b6bed5e3d41a197221a (diff)
downloadmv-694329376df2a2a491f1f665e4231a167ff11a3f.tar.gz
mv-694329376df2a2a491f1f665e4231a167ff11a3f.tar.bz2
mv-694329376df2a2a491f1f665e4231a167ff11a3f.tar.xz
mv-694329376df2a2a491f1f665e4231a167ff11a3f.zip
Fix context switching in SDL 2.
Diffstat (limited to 'src/utils/sdl2helper.cpp')
-rw-r--r--src/utils/sdl2helper.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/utils/sdl2helper.cpp b/src/utils/sdl2helper.cpp
index f0a3b7616..7a9a92c88 100644
--- a/src/utils/sdl2helper.cpp
+++ b/src/utils/sdl2helper.cpp
@@ -104,26 +104,26 @@ void *SDL::createGLContext(SDL_Window *const window,
// SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
SDL_ClearError();
void *context = SDL_GL_CreateContext(window);
- if (SDL_GetError())
+ if (context == nullptr)
{
logger->log("Error to switch to context %d.%d: %s",
major,
minor,
SDL_GetError());
}
- if (SDL_GetError() && (major > 3 || (major == 3 && minor > 3)))
+ if (context == nullptr && (major > 3 || (major == 3 && minor > 3)))
{
- logger->log("Try fallback to OpenGL 3.3 core context");
+ logger->log("Try fallback to OpenGL 3.3 context");
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_ClearError();
context = SDL_GL_CreateContext(window);
- if (SDL_GetError())
+ if (context == nullptr)
{
- logger->log("Error to switch to core context 3.3: %s",
+ logger->log("Error to switch to context 3.3: %s",
SDL_GetError());
}
- if (SDL_GetError() && profile == 0x01)
+ if (context == nullptr && profile == 0x01)
{
logger->log("Try fallback to OpenGL 3.3 compatibility context");
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
@@ -131,14 +131,14 @@ void *SDL::createGLContext(SDL_Window *const window,
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0x02);
SDL_ClearError();
context = SDL_GL_CreateContext(window);
- if (SDL_GetError())
+ if (context == nullptr)
{
logger->log("Error to switch to compatibility context 3.3: %s",
SDL_GetError());
}
}
}
- if (SDL_GetError() && (major > 3 || (major == 3 && minor > 0)))
+ if (context == nullptr && (major > 3 || (major == 3 && minor > 0)))
{
logger->log("Error to switch to core context %d.%d: %s",
major,
@@ -149,25 +149,29 @@ void *SDL::createGLContext(SDL_Window *const window,
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile);
context = SDL_GL_CreateContext(window);
- if (SDL_GetError())
+ if (context == nullptr)
{
logger->log("Error to switch to core context 3.0: %s",
SDL_GetError());
}
}
- if (SDL_GetError() && (major > 2 || (major == 2 && minor > 1)))
+ if (context == nullptr && (major > 2 || (major == 2 && minor > 1)))
{
logger->log("Try fallback to OpenGL 2.1 compatibility context");
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0x02);
context = SDL_GL_CreateContext(window);
- if (SDL_GetError())
+ if (context == nullptr)
{
logger->log("Error to switch to compatibility context 2.1: %s",
SDL_GetError());
}
}
+ if (context == nullptr)
+ {
+ logger->log("Cant find working context.");
+ }
return context;
}