Browse Source

Platform: implement ES2 and ES3 support for SDL2 and X-based applications.

Currently XEglApplication and GlxApplication were requesting only ES2
context and SDL2 was not requesting anything in particular (but in
theory should work on ES-only systems flawlessly). Now explicitly
requesting ES3 if MAGNUM_TARGET_GLES3 is enabled and also explicitly
requesting ES in SDL2, so it is usable also with
MAGNUM_TARGET_DESKTOP_GLES.
pull/51/head
Vladimír Vondruš 13 years ago
parent
commit
00dec60d33
  1. 12
      src/Platform/Implementation/EglContextHandler.cpp
  2. 6
      src/Platform/Implementation/GlxContextHandler.cpp
  3. 17
      src/Platform/Sdl2Application.cpp
  4. 13
      src/Platform/Sdl2Application.h
  5. 6
      src/Platform/WindowlessGlxApplication.cpp

12
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

6
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;

17
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);

13
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

6
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

Loading…
Cancel
Save