EGL: Request sRGB framebuffer in correct place.
The EGL_GL_COLORSPACE_KHR is an attribute for eglCreate*Surface.
As written in EGL_KHR_gl_colorspace documentation:
Accepted as an attribute name by eglCreateWindowSurface,
eglCreatePbufferSurface and eglCreatePixmapSurface
EGL_GL_COLORSPACE_KHR 0x309D
(...)
1.1 --- a/src/video/SDL_egl.c Wed Jan 17 13:17:10 2018 -0800
1.2 +++ b/src/video/SDL_egl.c Tue Jan 16 21:29:32 2018 +0100
1.3 @@ -519,18 +519,6 @@
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, SDL_EGL_DISPLAY_EXTENSION, "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 @@ -799,6 +787,10 @@
1.23 EGLSurface *
1.24 SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
1.25 {
1.26 + /* max 2 values plus terminator. */
1.27 + EGLint attribs[3];
1.28 + int attr = 0;
1.29 +
1.30 EGLSurface * surface;
1.31
1.32 if (SDL_EGL_ChooseConfig(_this) != 0) {
1.33 @@ -818,11 +810,25 @@
1.34 ANativeWindow_setBuffersGeometry(nw, 0, 0, format);
1.35 }
1.36 #endif
1.37 + if (_this->gl_config.framebuffer_srgb_capable) {
1.38 +#ifdef EGL_KHR_gl_colorspace
1.39 + if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) {
1.40 + attribs[attr++] = EGL_GL_COLORSPACE_KHR;
1.41 + attribs[attr++] = EGL_GL_COLORSPACE_SRGB_KHR;
1.42 + } else
1.43 +#endif
1.44 + {
1.45 + SDL_SetError("EGL implementation does not support sRGB system framebuffers");
1.46 + return EGL_NO_SURFACE;
1.47 + }
1.48 + }
1.49 +
1.50 + attribs[attr++] = EGL_NONE;
1.51
1.52 surface = _this->egl_data->eglCreateWindowSurface(
1.53 _this->egl_data->egl_display,
1.54 _this->egl_data->egl_config,
1.55 - nw, NULL);
1.56 + nw, &attribs[0]);
1.57 if (surface == EGL_NO_SURFACE) {
1.58 SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface");
1.59 }