Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
    (...)
  • Loading branch information
deveee committed Jan 16, 2018
1 parent 35554ca commit 61261e5
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/video/SDL_egl.c
Expand Up @@ -519,18 +519,6 @@ SDL_EGL_ChooseConfig(_THIS)
attribs[i++] = _this->gl_config.multisamplesamples;
}

if (_this->gl_config.framebuffer_srgb_capable) {
#ifdef EGL_KHR_gl_colorspace
if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) {
attribs[i++] = EGL_GL_COLORSPACE_KHR;
attribs[i++] = EGL_GL_COLORSPACE_SRGB_KHR;
} else
#endif
{
return SDL_SetError("EGL implementation does not support sRGB system framebuffers");
}
}

attribs[i++] = EGL_RENDERABLE_TYPE;
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
#ifdef EGL_KHR_create_context
Expand Down Expand Up @@ -799,6 +787,10 @@ SDL_EGL_DeleteContext(_THIS, SDL_GLContext context)
EGLSurface *
SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
{
/* max 2 values plus terminator. */
EGLint attribs[3];
int attr = 0;

EGLSurface * surface;

if (SDL_EGL_ChooseConfig(_this) != 0) {
Expand All @@ -818,11 +810,25 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
ANativeWindow_setBuffersGeometry(nw, 0, 0, format);
}
#endif
if (_this->gl_config.framebuffer_srgb_capable) {
#ifdef EGL_KHR_gl_colorspace
if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) {
attribs[attr++] = EGL_GL_COLORSPACE_KHR;
attribs[attr++] = EGL_GL_COLORSPACE_SRGB_KHR;
} else
#endif
{
SDL_SetError("EGL implementation does not support sRGB system framebuffers");
return EGL_NO_SURFACE;
}
}

attribs[attr++] = EGL_NONE;

surface = _this->egl_data->eglCreateWindowSurface(
_this->egl_data->egl_display,
_this->egl_data->egl_config,
nw, NULL);
nw, &attribs[0]);
if (surface == EGL_NO_SURFACE) {
SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface");
}
Expand Down

0 comments on commit 61261e5

Please sign in to comment.