Added SDL_GL_FRAMEBUFFER_SRGB_CAPABLE (thanks, David!).

Fixes Bugzilla #1985.
This commit is contained in:
Ryan C. Gordon 2013-10-20 21:18:05 -04:00
parent d1bde399af
commit 0e699eb5bb
5 changed files with 36 additions and 2 deletions

View File

@ -187,7 +187,8 @@ typedef enum
SDL_GL_CONTEXT_EGL, SDL_GL_CONTEXT_EGL,
SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FLAGS,
SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_MASK,
SDL_GL_SHARE_WITH_CURRENT_CONTEXT SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
SDL_GL_FRAMEBUFFER_SRGB_CAPABLE
} SDL_GLattr; } SDL_GLattr;
typedef enum typedef enum

View File

@ -293,6 +293,7 @@ struct SDL_VideoDevice
int flags; int flags;
int profile_mask; int profile_mask;
int share_with_current_context; int share_with_current_context;
int framebuffer_srgb_capable;
int retained_backing; int retained_backing;
int driver_loaded; int driver_loaded;
char driver_path[256]; char driver_path[256];

View File

@ -2570,7 +2570,10 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value)
break; break;
case SDL_GL_SHARE_WITH_CURRENT_CONTEXT: case SDL_GL_SHARE_WITH_CURRENT_CONTEXT:
_this->gl_config.share_with_current_context = value; _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: default:
retval = SDL_SetError("Unknown OpenGL attribute"); retval = SDL_SetError("Unknown OpenGL attribute");
break; break;
@ -2741,6 +2744,11 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
*value = _this->gl_config.share_with_current_context; *value = _this->gl_config.share_with_current_context;
return 0; return 0;
} }
case SDL_GL_FRAMEBUFFER_SRGB_CAPABLE:
{
*value = _this->gl_config.framebuffer_srgb_capable;
return 0;
}
default: default:
return SDL_SetError("Unknown OpenGL attribute"); return SDL_SetError("Unknown OpenGL attribute");
} }

View File

@ -67,6 +67,11 @@
#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 #define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004
#endif #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, typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC,
HGLRC HGLRC
hShareContext, hShareContext,
@ -495,6 +500,11 @@ WIN_GL_SetupWindowInternal(_THIS, SDL_Window * window)
*iAttr++ = _this->gl_config.multisamplesamples; *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 /* 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 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 probably what they wanted (and if you didn't care and got FULL, that's

View File

@ -106,6 +106,13 @@ typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy,
#endif #endif
#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 #ifndef GLX_EXT_swap_control
#define GLX_SWAP_INTERVAL_EXT 0x20F1 #define GLX_SWAP_INTERVAL_EXT 0x20F1
#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 #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; 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 && if (_this->gl_config.accelerated >= 0 &&
_this->gl_data->HAS_GLX_EXT_visual_rating) { _this->gl_data->HAS_GLX_EXT_visual_rating) {
attribs[i++] = GLX_VISUAL_CAVEAT_EXT; attribs[i++] = GLX_VISUAL_CAVEAT_EXT;