From a4c269cd103c34e77c71c23e1522d2537c5a1cb3 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 15 Nov 2025 07:32:49 -0800
Subject: [PATCH] Fixed handling framebuffer_srgb_capable for EGL and iOS
---
src/video/SDL_egl.c | 6 +++---
src/video/uikit/SDL_uikitopenglview.h | 2 +-
src/video/uikit/SDL_uikitopenglview.m | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index 23cc00ba20f55..1c6a46384d757 100644
--- a/src/video/SDL_egl.c
+++ b/src/video/SDL_egl.c
@@ -1268,14 +1268,14 @@ EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Nat
ANativeWindow_setBuffersGeometry(nw, 0, 0, format_wanted);
#endif
- if (_this->gl_config.framebuffer_srgb_capable) {
+ if (_this->gl_config.framebuffer_srgb_capable >= 0) {
#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;
+ attribs[attr++] = _this->gl_config.framebuffer_srgb_capable ? EGL_GL_COLORSPACE_SRGB_KHR : EGL_GL_COLORSPACE_LINEAR_KHR;
} else
#endif
- {
+ if (_this->gl_config.framebuffer_srgb_capable > 0) {
SDL_SetError("EGL implementation does not support sRGB system framebuffers");
return EGL_NO_SURFACE;
}
diff --git a/src/video/uikit/SDL_uikitopenglview.h b/src/video/uikit/SDL_uikitopenglview.h
index 3286a16a02d04..d4c6c58d93458 100644
--- a/src/video/uikit/SDL_uikitopenglview.h
+++ b/src/video/uikit/SDL_uikitopenglview.h
@@ -39,7 +39,7 @@
aBits:(int)aBits
depthBits:(int)depthBits
stencilBits:(int)stencilBits
- sRGB:(BOOL)sRGB
+ sRGB:(int)sRGB
multisamples:(int)multisamples
context:(EAGLContext *)glcontext;
diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m
index 71d167fc4d3e7..3ee0bb8f1ef2c 100644
--- a/src/video/uikit/SDL_uikitopenglview.m
+++ b/src/video/uikit/SDL_uikitopenglview.m
@@ -67,7 +67,7 @@ - (instancetype)initWithFrame:(CGRect)frame
aBits:(int)aBits
depthBits:(int)depthBits
stencilBits:(int)stencilBits
- sRGB:(BOOL)sRGB
+ sRGB:(int)sRGB
multisamples:(int)multisamples
context:(EAGLContext *)glcontext
{
@@ -93,7 +93,7 @@ - (instancetype)initWithFrame:(CGRect)frame
samples = SDL_min(samples, maxsamples);
}
- if (sRGB) {
+ if (sRGB > 0) {
colorFormat = kEAGLColorFormatSRGBA8;
colorBufferFormat = GL_SRGB8_ALPHA8;
} else if (rBits >= 8 || gBits >= 8 || bBits >= 8 || aBits > 0) {