Added SDL_GL_FRAMEBUFFER_SRGB_CAPABLE (thanks, David!).
authorRyan C. Gordon <icculus@icculus.org>
Sun, 20 Oct 2013 21:18:05 -0400
changeset 78534861edda71d1
parent 7852 042ad8cbb550
child 7854 6d79888998f5
Added SDL_GL_FRAMEBUFFER_SRGB_CAPABLE (thanks, David!).

Fixes Bugzilla #1985.
include/SDL_video.h
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/windows/SDL_windowsopengl.c
src/video/x11/SDL_x11opengl.c
     1.1 --- a/include/SDL_video.h	Sun Oct 20 20:24:00 2013 -0400
     1.2 +++ b/include/SDL_video.h	Sun Oct 20 21:18:05 2013 -0400
     1.3 @@ -187,7 +187,8 @@
     1.4      SDL_GL_CONTEXT_EGL,
     1.5      SDL_GL_CONTEXT_FLAGS,
     1.6      SDL_GL_CONTEXT_PROFILE_MASK,
     1.7 -    SDL_GL_SHARE_WITH_CURRENT_CONTEXT
     1.8 +    SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
     1.9 +    SDL_GL_FRAMEBUFFER_SRGB_CAPABLE
    1.10  } SDL_GLattr;
    1.11  
    1.12  typedef enum
     2.1 --- a/src/video/SDL_sysvideo.h	Sun Oct 20 20:24:00 2013 -0400
     2.2 +++ b/src/video/SDL_sysvideo.h	Sun Oct 20 21:18:05 2013 -0400
     2.3 @@ -293,6 +293,7 @@
     2.4          int flags;
     2.5          int profile_mask;
     2.6          int share_with_current_context;
     2.7 +        int framebuffer_srgb_capable;
     2.8          int retained_backing;
     2.9          int driver_loaded;
    2.10          char driver_path[256];
     3.1 --- a/src/video/SDL_video.c	Sun Oct 20 20:24:00 2013 -0400
     3.2 +++ b/src/video/SDL_video.c	Sun Oct 20 21:18:05 2013 -0400
     3.3 @@ -2570,7 +2570,10 @@
     3.4          break;
     3.5      case SDL_GL_SHARE_WITH_CURRENT_CONTEXT:
     3.6          _this->gl_config.share_with_current_context = value;
     3.7 -    break;
     3.8 +        break;
     3.9 +    case SDL_GL_FRAMEBUFFER_SRGB_CAPABLE:
    3.10 +        _this->gl_config.framebuffer_srgb_capable = value;
    3.11 +        break;
    3.12      default:
    3.13          retval = SDL_SetError("Unknown OpenGL attribute");
    3.14          break;
    3.15 @@ -2741,6 +2744,11 @@
    3.16              *value = _this->gl_config.share_with_current_context;
    3.17              return 0;
    3.18          }
    3.19 +    case SDL_GL_FRAMEBUFFER_SRGB_CAPABLE:
    3.20 +        {
    3.21 +            *value = _this->gl_config.framebuffer_srgb_capable;
    3.22 +            return 0;
    3.23 +        }
    3.24      default:
    3.25          return SDL_SetError("Unknown OpenGL attribute");
    3.26      }
     4.1 --- a/src/video/windows/SDL_windowsopengl.c	Sun Oct 20 20:24:00 2013 -0400
     4.2 +++ b/src/video/windows/SDL_windowsopengl.c	Sun Oct 20 21:18:05 2013 -0400
     4.3 @@ -67,6 +67,11 @@
     4.4  #define WGL_CONTEXT_ES_PROFILE_BIT_EXT            0x00000004
     4.5  #endif
     4.6  
     4.7 +#ifndef WGL_ARB_framebuffer_sRGB
     4.8 +#define WGL_ARB_framebuffer_sRGB
     4.9 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB                0x20A9
    4.10 +#endif
    4.11 +
    4.12  typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC,
    4.13                                                              HGLRC
    4.14                                                              hShareContext,
    4.15 @@ -495,6 +500,11 @@
    4.16          *iAttr++ = _this->gl_config.multisamplesamples;
    4.17      }
    4.18  
    4.19 +    if (_this->gl_config.framebuffer_srgb_capable) {
    4.20 +        *iAttr++ = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB;
    4.21 +        *iAttr++ = _this->gl_config.framebuffer_srgb_capable;
    4.22 +    }
    4.23 +
    4.24      /* We always choose either FULL or NO accel on Windows, because of flaky
    4.25         drivers. If the app didn't specify, we use FULL, because that's
    4.26         probably what they wanted (and if you didn't care and got FULL, that's
     5.1 --- a/src/video/x11/SDL_x11opengl.c	Sun Oct 20 20:24:00 2013 -0400
     5.2 +++ b/src/video/x11/SDL_x11opengl.c	Sun Oct 20 21:18:05 2013 -0400
     5.3 @@ -106,6 +106,13 @@
     5.4  #endif
     5.5  #endif
     5.6  
     5.7 +#ifndef GLX_ARB_framebuffer_sRGB
     5.8 +#define GLX_ARB_framebuffer_sRGB
     5.9 +#ifndef GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB
    5.10 +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB                0x20B2
    5.11 +#endif
    5.12 +#endif
    5.13 +
    5.14  #ifndef GLX_EXT_swap_control
    5.15  #define GLX_SWAP_INTERVAL_EXT              0x20F1
    5.16  #define GLX_MAX_SWAP_INTERVAL_EXT          0x20F2
    5.17 @@ -472,6 +479,13 @@
    5.18          attribs[i++] = _this->gl_config.multisamplesamples;
    5.19      }
    5.20  
    5.21 +    if (_this->gl_config.framebuffer_srgb_capable) {
    5.22 +        attribs[i++] = GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB;
    5.23 +        if( for_FBConfig ) {
    5.24 +            attribs[i++] = True;
    5.25 +        }
    5.26 +    }
    5.27 +
    5.28      if (_this->gl_config.accelerated >= 0 &&
    5.29          _this->gl_data->HAS_GLX_EXT_visual_rating) {
    5.30          attribs[i++] = GLX_VISUAL_CAVEAT_EXT;