Skip to content
Permalink
Browse files
EGL: OpenGL ES 3.0 contexts can now be created without the EGL_KHR_cr…
…eate_context extension.

Fixes bugzilla #2994.
  • Loading branch information
slime73 committed May 26, 2015
1 parent d5a5785 commit a4f0daedaea0fe20bafe94b49ced914f8efd839d
Showing with 17 additions and 8 deletions.
  1. +17 −8 src/video/SDL_egl.c
@@ -414,6 +414,9 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)

EGLContext egl_context, share_context = EGL_NO_CONTEXT;
EGLint profile_mask = _this->gl_config.profile_mask;
EGLint major_version = _this->gl_config.major_version;
EGLint minor_version = _this->gl_config.minor_version;
SDL_bool profile_es = (profile_mask == SDL_GL_CONTEXT_PROFILE_ES);

if (!_this->egl_data) {
/* The EGL library wasn't loaded, SDL_GetError() should have info */
@@ -425,12 +428,18 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
}

/* Set the context version and other attributes. */
if (_this->gl_config.major_version < 3 && _this->gl_config.flags == 0 &&
(profile_mask == 0 || profile_mask == SDL_GL_CONTEXT_PROFILE_ES)) {
/* Create a context without using EGL_KHR_create_context attribs. */
if (profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
if ((major_version < 3 || (minor_version == 0 && profile_es)) &&
_this->gl_config.flags == 0 &&
(profile_mask == 0 || profile_es)) {
/* Create a context without using EGL_KHR_create_context attribs.
* When creating a GLES context without EGL_KHR_create_context we can
* only specify the major version. When creating a desktop GL context
* we can't specify any version, so we only try in that case when the
* version is less than 3.0 (matches SDL's GLX/WGL behavior.)
*/
if (profile_es) {
attribs[attr++] = EGL_CONTEXT_CLIENT_VERSION;
attribs[attr++] = SDL_max(_this->gl_config.major_version, 1);
attribs[attr++] = SDL_max(major_version, 1);
}
} else {
#ifdef EGL_KHR_create_context
@@ -439,9 +448,9 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
*/
if (SDL_EGL_HasExtension(_this, "EGL_KHR_create_context")) {
attribs[attr++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
attribs[attr++] = _this->gl_config.major_version;
attribs[attr++] = major_version;
attribs[attr++] = EGL_CONTEXT_MINOR_VERSION_KHR;
attribs[attr++] = _this->gl_config.minor_version;
attribs[attr++] = minor_version;

/* SDL profile bits match EGL profile bits. */
if (profile_mask != 0 && profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
@@ -465,7 +474,7 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
attribs[attr++] = EGL_NONE;

/* Bind the API */
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
if (profile_es) {
_this->egl_data->eglBindAPI(EGL_OPENGL_ES_API);
} else {
_this->egl_data->eglBindAPI(EGL_OPENGL_API);

0 comments on commit a4f0dae

Please sign in to comment.