EGL: Added support for sRGB system framebuffers, when the required EGL extension is present.
authorAlex Szpakowski <slime73@gmail.com>
Sat, 01 Aug 2015 15:16:57 -0300
changeset 98276f0b76fa61e7
parent 9826 0b5b4bf90f02
child 9828 4e0e4f544027
EGL: Added support for sRGB system framebuffers, when the required EGL extension is present.
src/video/SDL_egl.c
     1.1 --- a/src/video/SDL_egl.c	Fri Jul 31 20:16:58 2015 +0200
     1.2 +++ b/src/video/SDL_egl.c	Sat Aug 01 15:16:57 2015 -0300
     1.3 @@ -340,6 +340,18 @@
     1.4          attribs[i++] = _this->gl_config.multisamplesamples;
     1.5      }
     1.6  
     1.7 +    if (_this->gl_config.framebuffer_srgb_capable) {
     1.8 +#ifdef EGL_KHR_gl_colorspace
     1.9 +        if (SDL_EGL_HasExtension(_this, "EGL_KHR_gl_colorspace")) {
    1.10 +            attribs[i++] = EGL_GL_COLORSPACE_KHR;
    1.11 +            attribs[i++] = EGL_GL_COLORSPACE_SRGB_KHR;
    1.12 +        } else
    1.13 +#endif
    1.14 +        {
    1.15 +            return SDL_SetError("EGL implementation does not support sRGB system framebuffers");
    1.16 +        }
    1.17 +    }
    1.18 +
    1.19      attribs[i++] = EGL_RENDERABLE_TYPE;
    1.20      if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
    1.21  #ifdef EGL_KHR_create_context
    1.22 @@ -358,9 +370,9 @@
    1.23          attribs[i++] = EGL_OPENGL_BIT;
    1.24          _this->egl_data->eglBindAPI(EGL_OPENGL_API);
    1.25      }
    1.26 -    
    1.27 +
    1.28      attribs[i++] = EGL_NONE;
    1.29 -   
    1.30 +
    1.31      if (_this->egl_data->eglChooseConfig(_this->egl_data->egl_display,
    1.32          attribs,
    1.33          configs, SDL_arraysize(configs),
    1.34 @@ -368,7 +380,7 @@
    1.35          found_configs == 0) {
    1.36          return SDL_SetError("Couldn't find matching EGL config");
    1.37      }
    1.38 -    
    1.39 +
    1.40      /* eglChooseConfig returns a number of configurations that match or exceed the requested attribs. */
    1.41      /* From those, we select the one that matches our requirements more closely via a makeshift algorithm */
    1.42