video: Only set GL_FRAMEBUFFER_SRGB state if the hint requests it.
Reference Issue #14898.
This commit is contained in:
@@ -3059,6 +3059,10 @@ extern "C" {
|
|||||||
* Note that some platforms cannot make this request at all, and on all
|
* Note that some platforms cannot make this request at all, and on all
|
||||||
* platforms this request can be denied by the operating system.
|
* platforms this request can be denied by the operating system.
|
||||||
*
|
*
|
||||||
|
* In addition to attempting to obtain the type of sRGB-capable OpenGL context
|
||||||
|
* requested by this hint, SDL will try to force the state of
|
||||||
|
* GL_FRAMEBUFFER_SRGB on the new context, if appropriate.
|
||||||
|
*
|
||||||
* The variable can be set to the following values:
|
* The variable can be set to the following values:
|
||||||
*
|
*
|
||||||
* - "0": Force a request for an OpenGL context that is _not_ sRGB-capable.
|
* - "0": Force a request for an OpenGL context that is _not_ sRGB-capable.
|
||||||
|
|||||||
@@ -5395,10 +5395,10 @@ SDL_GLContext SDL_GL_CreateContext(SDL_Window *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2)
|
#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2)
|
||||||
bool srgb_requested = (_this->gl_config.framebuffer_srgb_capable > 0);
|
int srgb_requested = -1;
|
||||||
const char *srgbhint = SDL_GetHint(SDL_HINT_OPENGL_FORCE_SRGB_CAPABLE);
|
const char *srgbhint = SDL_GetHint(SDL_HINT_OPENGL_FORCE_SRGB_CAPABLE);
|
||||||
if (srgbhint && *srgbhint) {
|
if (srgbhint && *srgbhint) {
|
||||||
srgb_requested = SDL_GetStringBoolean(srgbhint, false);
|
srgb_requested = SDL_GetStringBoolean(srgbhint, false) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -5415,20 +5415,22 @@ SDL_GLContext SDL_GL_CreateContext(SDL_Window *window)
|
|||||||
|
|
||||||
#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2)
|
#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2)
|
||||||
// try to force the window framebuffer to the requested sRGB state.
|
// try to force the window framebuffer to the requested sRGB state.
|
||||||
PFNGLENABLEPROC glToggleFunc = (PFNGLENABLEPROC) SDL_GL_GetProcAddress(srgb_requested ? "glEnable" : "glDisable");
|
if (srgb_requested != -1) {
|
||||||
PFNGLGETSTRINGPROC glGetStringFunc = (PFNGLGETSTRINGPROC)SDL_GL_GetProcAddress("glGetString");
|
PFNGLENABLEPROC glToggleFunc = (PFNGLENABLEPROC) SDL_GL_GetProcAddress(srgb_requested ? "glEnable" : "glDisable");
|
||||||
if (glToggleFunc && glGetStringFunc) {
|
PFNGLGETSTRINGPROC glGetStringFunc = (PFNGLGETSTRINGPROC)SDL_GL_GetProcAddress("glGetString");
|
||||||
bool supported = false;
|
if (glToggleFunc && glGetStringFunc) {
|
||||||
if (_this->gl_config.profile_mask & SDL_GL_CONTEXT_PROFILE_ES) {
|
bool supported = false;
|
||||||
supported = SDL_GL_ExtensionSupported("GL_EXT_sRGB_write_control"); // GL_FRAMEBUFFER_SRGB is not core in any GLES version at the moment.
|
if (_this->gl_config.profile_mask & SDL_GL_CONTEXT_PROFILE_ES) {
|
||||||
} else {
|
supported = SDL_GL_ExtensionSupported("GL_EXT_sRGB_write_control"); // GL_FRAMEBUFFER_SRGB is not core in any GLES version at the moment.
|
||||||
supported = isAtLeastGL3((const char *)glGetStringFunc(GL_VERSION)) || // no extensions needed in OpenGL 3+.
|
} else {
|
||||||
SDL_GL_ExtensionSupported("GL_EXT_framebuffer_sRGB") ||
|
supported = isAtLeastGL3((const char *)glGetStringFunc(GL_VERSION)) || // no extensions needed in OpenGL 3+.
|
||||||
SDL_GL_ExtensionSupported("GL_ARB_framebuffer_sRGB");
|
SDL_GL_ExtensionSupported("GL_EXT_framebuffer_sRGB") ||
|
||||||
}
|
SDL_GL_ExtensionSupported("GL_ARB_framebuffer_sRGB");
|
||||||
|
}
|
||||||
|
|
||||||
if (supported) {
|
if (supported) {
|
||||||
glToggleFunc(GL_FRAMEBUFFER_SRGB);
|
glToggleFunc(GL_FRAMEBUFFER_SRGB);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user