From 21211a7aa5ce1a71cf075424c43699417612b5d0 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Wed, 1 Jan 2025 23:06:11 +0100 Subject: [PATCH 1/3] guiscreen.cpp: Ensure successful SDL_GL_CreateContext SDL_GL_CreateContext can fail due to several reasons, such as GLXBadFBConfig on unsupported OpenGL versions. --- src/libs/tgfclient/guiscreen.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/tgfclient/guiscreen.cpp b/src/libs/tgfclient/guiscreen.cpp index 4ae1a176e..09febfc99 100644 --- a/src/libs/tgfclient/guiscreen.cpp +++ b/src/libs/tgfclient/guiscreen.cpp @@ -377,7 +377,11 @@ SDL_Surface* gfScrCreateWindow(int nWinWidth, int nWinHeight, int nTotalDepth,in } #endif /* Create OpenGL context */ - GLContext = SDL_GL_CreateContext(GfuiWindow); + if (!(GLContext = SDL_GL_CreateContext(GfuiWindow))) + { + GfLogError("SDL_GL_CreateContext failed: %s\n", SDL_GetError()); + return nullptr; + } // If specified, try best possible settings. PScreenSurface = SDL_CreateRGBSurface(0, nWinWidth, nWinHeight, nTotalDepth, -- 2.39.5 From c677c8d9e230b4042667a0b86ec98dbc5adf93c0 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Thu, 2 Jan 2025 00:45:10 +0100 Subject: [PATCH 2/3] guiscreen.cpp: Reduce minimum required OpenGL version 3.3.0 was required only because one shader, namely car.frag, was arbitrarily requiring GLSL 3.3.0. However, it was already compatible with GLSL 1.1.0, [1] so the minimum required OpenGL version can be safely lowered to 2.1. [2] [1]: https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.10.pdf [2]: https://en.wikipedia.org/wiki/OpenGL#Version_history --- cmake/checks.cmake | 2 +- src/libs/tgfclient/guiscreen.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/checks.cmake b/cmake/checks.cmake index d00d760a3..f5cabaa82 100644 --- a/cmake/checks.cmake +++ b/cmake/checks.cmake @@ -184,7 +184,7 @@ MACRO(CHECK_LIBRARIES) ENDIF(ENET_FOUND) # OpenGL - Find_Package(OpenGL) + Find_Package(OpenGL 2.1.0) IF(OPENGL_FOUND) SET(HAVE_LIBGL 1) diff --git a/src/libs/tgfclient/guiscreen.cpp b/src/libs/tgfclient/guiscreen.cpp index 09febfc99..67566d079 100644 --- a/src/libs/tgfclient/guiscreen.cpp +++ b/src/libs/tgfclient/guiscreen.cpp @@ -431,8 +431,8 @@ bool GfScrInitSDL2(int nWinWidth, int nWinHeight, int nFullScreen) SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); #else // Version d'OpenGL - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); #endif -- 2.39.5 From 8f230211bb7be1c29fd8329e3727c8a22a2aefda Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Thu, 2 Jan 2025 00:45:34 +0100 Subject: [PATCH 3/3] OsgCar.cpp: Do not create SDCarShader on "none" shaders Even if "none" shaders were selected, the game would still parse car.frag and execute the shaders, which is not the expected behaviour. --- src/modules/graphic/osggraph/Car/OsgCar.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/graphic/osggraph/Car/OsgCar.cpp b/src/modules/graphic/osggraph/Car/OsgCar.cpp index 1717ddc14..38330605f 100644 --- a/src/modules/graphic/osggraph/Car/OsgCar.cpp +++ b/src/modules/graphic/osggraph/Car/OsgCar.cpp @@ -644,7 +644,8 @@ osg::ref_ptr SDCar::loadCar(tCarElt *Car, bool tracktype, bool subcat else this->reflectionMappingMethod = REFLECTIONMAPPING_OFF; - this->shader = new SDCarShader(car_shaded_body.get(), this); + if (_carShader > 0) + this->shader = new SDCarShader(car_shaded_body.get(), this); this->reflectionMapping = new SDReflectionMapping(this); this->setReflectionMap(this->reflectionMapping->getReflectionMap()); -- 2.39.5