From afb57c786deef7bf6152ccd35e32a759bbdccd2a Mon Sep 17 00:00:00 2001 From: fp64 <106717720+fp64@users.noreply.github.com> Date: Fri, 22 Aug 2025 17:36:58 +0300 Subject: [PATCH] Update SDLGLGraphicsContext.cpp --- SDL/SDLGLGraphicsContext.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/SDL/SDLGLGraphicsContext.cpp b/SDL/SDLGLGraphicsContext.cpp index db53a72507..977c6fbacb 100644 --- a/SDL/SDLGLGraphicsContext.cpp +++ b/SDL/SDLGLGraphicsContext.cpp @@ -307,7 +307,7 @@ bool SDLGLGraphicsContext::InitFromRenderThread(std::string *errorMessage) { } // Returns 0 on success. -int SDLGLGraphicsContext::Init(SDL_Window *&window, int x, int y, int w, int h, int mode, std::string *error_message) { +int SDLGLGraphicsContext::Init(SDL_Window *&window, int x, int y, int w, int h, int mode, std::string *error_message, int force_gl_version) { struct GLVersionPair { int major; int minor; @@ -328,6 +328,12 @@ int SDLGLGraphicsContext::Init(SDL_Window *&window, int x, int y, int w, int h, SDL_GLContext glContext = nullptr; for (size_t i = 0; i < ARRAY_SIZE(attemptVersions); ++i) { const auto &ver = attemptVersions[i]; + // If we force a specific OpenGL version, skip the ones + // that do not match, which may be all of them - e.g. + // requesting nonsensical "--graphics=opengl0" reliably + // skips straight to fallback code below. + if(force_gl_version >= 0 && 10*ver.major + ver.minor != force_gl_version) + continue; // Make sure to request a somewhat modern GL context at least - the // latest supported by MacOS X (really, really sad...) SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, ver.major);