diff --git a/src/Platform/Implementation/EglContextHandler.cpp b/src/Platform/Implementation/EglContextHandler.cpp index 4d65cdc4b..121af16f8 100644 --- a/src/Platform/Implementation/EglContextHandler.cpp +++ b/src/Platform/Implementation/EglContextHandler.cpp @@ -65,8 +65,12 @@ VisualId EglContextHandler::getVisualId(EGLNativeDisplayType nativeDisplay) { EGL_DEPTH_SIZE, 1, #ifndef MAGNUM_TARGET_GLES EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, - #else + #elif defined(MAGNUM_TARGET_GLES3) + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, + #elif defined(MAGNUM_TARGET_GLES2) EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + #else + #error Unsupported OpenGL edition #endif EGL_NONE }; @@ -125,7 +129,13 @@ void EglContextHandler::createContext(const AbstractXApplication::Configuration& #ifdef MAGNUM_TARGET_GLES else { attributes[0] = EGL_CONTEXT_CLIENT_VERSION; + #ifdef MAGNUM_TARGET_GLES3 + attributes[1] = 3; + #elif defined(MAGNUM_TARGET_GLES2) attributes[1] = 2; + #else + #error Unsupported OpenGL ES version + #endif } #endif diff --git a/src/Platform/Implementation/GlxContextHandler.cpp b/src/Platform/Implementation/GlxContextHandler.cpp index 32983ce12..bc90befc3 100644 --- a/src/Platform/Implementation/GlxContextHandler.cpp +++ b/src/Platform/Implementation/GlxContextHandler.cpp @@ -108,7 +108,13 @@ void GlxContextHandler::createContext(const AbstractXApplication::Configuration& #ifdef MAGNUM_TARGET_GLES else { attributes[0] = GLX_CONTEXT_MAJOR_VERSION_ARB; + #ifdef MAGNUM_TARGET_GLES3 + attributes[1] = 3; + #elif defined(MAGNUM_TARGET_GLES2) attributes[1] = 2; + #else + #error Unsupported OpenGL ES version + #endif attributes[2] = GLX_CONTEXT_MINOR_VERSION_ARB; attributes[3] = 0; attributes[4] = GLX_CONTEXT_PROFILE_MASK_ARB; diff --git a/src/Platform/Sdl2Application.cpp b/src/Platform/Sdl2Application.cpp index 5dfabdf48..93635eab7 100644 --- a/src/Platform/Sdl2Application.cpp +++ b/src/Platform/Sdl2Application.cpp @@ -124,15 +124,30 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) { #ifndef MAGNUM_TARGET_GLES SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, configuration.version() >= Version::GL310 ? SDL_GL_CONTEXT_PROFILE_CORE : SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); + #else + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); #endif } + #ifdef MAGNUM_TARGET_GLES + else { + #ifdef MAGNUM_TARGET_GLES3 + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); + #elif defined(MAGNUM_TARGET_GLES2) + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + #else + #error Unsupported OpenGL ES version + #endif + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + } + /* 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__ + #elif defined(__APPLE__) else { SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); diff --git a/src/Platform/Sdl2Application.h b/src/Platform/Sdl2Application.h index 990bea5fe..837966012 100644 --- a/src/Platform/Sdl2Application.h +++ b/src/Platform/Sdl2Application.h @@ -54,12 +54,13 @@ namespace Platform { Application using [Simple DirectMedia Layer](http://www.libsdl.org/) toolkit. Supports keyboard and mouse handling. -This application library is available on desktop OpenGL (Linux, Windows, OS X) -and in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". It depends on **SDL2** -library (Emscripten has it built in) and is built if `WITH_SDL2APPLICATION` is -enabled in CMake. To use it, you need to copy `FindSDL2.cmake` from `modules/` -directory in %Magnum source to `modules/` dir in your project (so CMake is able -to find SDL2), request `%Sdl2Application` component in CMake, add +This application library is in theory available for all platforms for which +SDL2 is ported (thus also @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten", but not +@ref CORRADE_TARGET_NACL "NaCl"). It depends on **SDL2** library (Emscripten +has it built in) and is built if `WITH_SDL2APPLICATION` is enabled in CMake. To +use it, you need to copy `FindSDL2.cmake` from `modules/` directory in %Magnum +source to `modules/` dir in your project (so CMake is able to find SDL2), +request `%Sdl2Application` component in CMake, add `${MAGNUM_SDL2APPLICATION_INCLUDE_DIRS}` to include path and link to `${MAGNUM_SDL2APPLICATION_LIBRARIES}`. If no other application is requested, you can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}` and diff --git a/src/Platform/WindowlessGlxApplication.cpp b/src/Platform/WindowlessGlxApplication.cpp index 30c20b3cf..a84592ad1 100644 --- a/src/Platform/WindowlessGlxApplication.cpp +++ b/src/Platform/WindowlessGlxApplication.cpp @@ -77,7 +77,13 @@ bool WindowlessGlxApplication::tryCreateContext(const Configuration&) { GLint contextAttributes[] = { #ifdef MAGNUM_TARGET_GLES + #ifdef MAGNUM_TARGET_GLES3 + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, + #elif defined(MAGNUM_TARGET_GLES2) GLX_CONTEXT_MAJOR_VERSION_ARB, 2, + #else + #error Unsupported OpenGL ES version + #endif GLX_CONTEXT_MINOR_VERSION_ARB, 0, GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES2_PROFILE_BIT_EXT, #endif