|
|
|
|
@ -111,23 +111,30 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) {
|
|
|
|
|
|
|
|
|
|
/** @todo Remove when Emscripten has proper SDL2 support */ |
|
|
|
|
#ifndef CORRADE_TARGET_EMSCRIPTEN |
|
|
|
|
|
|
|
|
|
/* On OS X we need to create 3.2 context, as the default (2.1) contains
|
|
|
|
|
compatibility features which are not implemented for newer GL versions |
|
|
|
|
in Apple's GL drivers, thus we would be forever stuck on 2.1 without the |
|
|
|
|
new features. In practice SDL fails to create 2.1 context on recent OS X |
|
|
|
|
versions. */ |
|
|
|
|
#ifdef __APPLE__ |
|
|
|
|
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); |
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); |
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if(!(window = SDL_CreateWindow(configuration.title().data(), |
|
|
|
|
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, |
|
|
|
|
configuration.size().x(), configuration.size().y(), |
|
|
|
|
SDL_WINDOW_OPENGL|flags))){ |
|
|
|
|
Error() << "Platform::Sdl2Application::tryCreateContext(): cannot create core window:" << SDL_GetError(); |
|
|
|
|
return false; |
|
|
|
|
SDL_WINDOW_OPENGL|flags))) |
|
|
|
|
{ |
|
|
|
|
Error() << "Platform::Sdl2Application::tryCreateContext(): cannot create window:" << SDL_GetError(); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Fall back to GL 2.1, if 3.2 context creation fails on OS X */ |
|
|
|
|
#ifdef __APPLE__ |
|
|
|
|
if(!(context = SDL_GL_CreateContext(window))){ |
|
|
|
|
Error() << "Platform::Sdl2Application::tryCreateContext(): cannot create core context:" << SDL_GetError() << " falling back to compatibility context."; |
|
|
|
|
Warning() << "Platform::Sdl2Application::tryCreateContext(): cannot create core context:" << SDL_GetError() << "(falling back to compatibility context)"; |
|
|
|
|
SDL_DestroyWindow(window); |
|
|
|
|
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); |
|
|
|
|
@ -137,9 +144,10 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) {
|
|
|
|
|
if(!(window = SDL_CreateWindow(configuration.title().data(), |
|
|
|
|
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, |
|
|
|
|
configuration.size().x(), configuration.size().y(), |
|
|
|
|
SDL_WINDOW_OPENGL|flags))){ |
|
|
|
|
Error() << "Platform::Sdl2Application::tryCreateContext(): cannot create window:" << SDL_GetError(); |
|
|
|
|
return false; |
|
|
|
|
SDL_WINDOW_OPENGL|flags))) |
|
|
|
|
{ |
|
|
|
|
Error() << "Platform::Sdl2Application::tryCreateContext(): cannot create window:" << SDL_GetError(); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!(context = SDL_GL_CreateContext(window))){ |
|
|
|
|
@ -149,16 +157,7 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) {
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#else |
|
|
|
|
if(!(window = SDL_CreateWindow(configuration.title().data(), |
|
|
|
|
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, |
|
|
|
|
configuration.size().x(), configuration.size().y(), |
|
|
|
|
SDL_WINDOW_OPENGL|flags))) { |
|
|
|
|
Error() << "Platform::Sdl2Application::tryCreateContext(): cannot create window:" << SDL_GetError(); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!(context = SDL_GL_CreateContext(window))) { |
|
|
|
|
Error() << "Platform::Sdl2Application::tryCreateContext(): cannot create context:" << SDL_GetError(); |
|
|
|
|
SDL_DestroyWindow(window); |
|
|
|
|
|