From 55d78567b1ce7fc16fe860d603ceca74e138395d Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Fri, 6 Feb 2026 13:58:55 -0500
Subject: [PATCH] video: Wrap OpenGL work in ifdefs.
Apparently the rest of SDL_GL_CreateContext compiles on platforms without
OpenGL, though! :)
(cherry picked from commit 3dc48a4890d37560e4159f50b7a6eadc9b9c1936)
---
src/video/SDL_video.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index d4508702a8a20..93c7b05fbc438 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -5410,12 +5410,15 @@ SDL_GLContext SDL_GL_CreateContext(SDL_Window *window)
return NULL;
}
+#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);
const char *srgbhint = SDL_GetHint(SDL_HINT_OPENGL_FORCE_SRGB_CAPABLE);
if (srgbhint && *srgbhint) {
srgb_requested = SDL_GetStringBoolean(srgbhint, false);
}
+#endif
+
ctx = _this->GL_CreateContext(_this, window);
// Creating a context is assumed to make it current in the SDL driver.
@@ -5426,6 +5429,7 @@ SDL_GLContext SDL_GL_CreateContext(SDL_Window *window)
SDL_SetTLS(&_this->current_glctx_tls, ctx, NULL);
}
+#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.
PFNGLENABLEPROC glToggleFunc = (PFNGLENABLEPROC) SDL_GL_GetProcAddress(srgb_requested ? "glEnable" : "glDisable");
PFNGLGETSTRINGPROC glGetStringFunc = (PFNGLGETSTRINGPROC)SDL_GL_GetProcAddress("glGetString");
@@ -5443,6 +5447,7 @@ SDL_GLContext SDL_GL_CreateContext(SDL_Window *window)
glToggleFunc(GL_FRAMEBUFFER_SRGB);
}
}
+#endif
return ctx;
}