Added SDL_GL_FRAMEBUFFER_SRGB_CAPABLE (thanks, David!). Fixes Bugzilla #1985.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
diff --git a/include/SDL_video.h b/include/SDL_video.h
index aa2dc69..4a53f9b 100644
--- a/include/SDL_video.h
+++ b/include/SDL_video.h
@@ -187,7 +187,8 @@ typedef enum
SDL_GL_CONTEXT_EGL,
SDL_GL_CONTEXT_FLAGS,
SDL_GL_CONTEXT_PROFILE_MASK,
- SDL_GL_SHARE_WITH_CURRENT_CONTEXT
+ SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
+ SDL_GL_FRAMEBUFFER_SRGB_CAPABLE
} SDL_GLattr;
typedef enum
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index beedc74..2d41234 100644
--- a/src/video/SDL_sysvideo.h
+++ b/src/video/SDL_sysvideo.h
@@ -293,6 +293,7 @@ struct SDL_VideoDevice
int flags;
int profile_mask;
int share_with_current_context;
+ int framebuffer_srgb_capable;
int retained_backing;
int driver_loaded;
char driver_path[256];
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 4088afe..a2078a7 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -2570,7 +2570,10 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value)
break;
case SDL_GL_SHARE_WITH_CURRENT_CONTEXT:
_this->gl_config.share_with_current_context = value;
- break;
+ break;
+ case SDL_GL_FRAMEBUFFER_SRGB_CAPABLE:
+ _this->gl_config.framebuffer_srgb_capable = value;
+ break;
default:
retval = SDL_SetError("Unknown OpenGL attribute");
break;
@@ -2741,6 +2744,11 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
*value = _this->gl_config.share_with_current_context;
return 0;
}
+ case SDL_GL_FRAMEBUFFER_SRGB_CAPABLE:
+ {
+ *value = _this->gl_config.framebuffer_srgb_capable;
+ return 0;
+ }
default:
return SDL_SetError("Unknown OpenGL attribute");
}
diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c
index 9cda415..3cc6737 100644
--- a/src/video/windows/SDL_windowsopengl.c
+++ b/src/video/windows/SDL_windowsopengl.c
@@ -67,6 +67,11 @@
#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004
#endif
+#ifndef WGL_ARB_framebuffer_sRGB
+#define WGL_ARB_framebuffer_sRGB
+#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
+#endif
+
typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC,
HGLRC
hShareContext,
@@ -495,6 +500,11 @@ WIN_GL_SetupWindowInternal(_THIS, SDL_Window * window)
*iAttr++ = _this->gl_config.multisamplesamples;
}
+ if (_this->gl_config.framebuffer_srgb_capable) {
+ *iAttr++ = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB;
+ *iAttr++ = _this->gl_config.framebuffer_srgb_capable;
+ }
+
/* We always choose either FULL or NO accel on Windows, because of flaky
drivers. If the app didn't specify, we use FULL, because that's
probably what they wanted (and if you didn't care and got FULL, that's
diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c
index 74165f4..a41033a 100644
--- a/src/video/x11/SDL_x11opengl.c
+++ b/src/video/x11/SDL_x11opengl.c
@@ -106,6 +106,13 @@ typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy,
#endif
#endif
+#ifndef GLX_ARB_framebuffer_sRGB
+#define GLX_ARB_framebuffer_sRGB
+#ifndef GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB
+#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2
+#endif
+#endif
+
#ifndef GLX_EXT_swap_control
#define GLX_SWAP_INTERVAL_EXT 0x20F1
#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2
@@ -472,6 +479,13 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si
attribs[i++] = _this->gl_config.multisamplesamples;
}
+ if (_this->gl_config.framebuffer_srgb_capable) {
+ attribs[i++] = GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB;
+ if( for_FBConfig ) {
+ attribs[i++] = True;
+ }
+ }
+
if (_this->gl_config.accelerated >= 0 &&
_this->gl_data->HAS_GLX_EXT_visual_rating) {
attribs[i++] = GLX_VISUAL_CAVEAT_EXT;