From fe35322bb0c421eda0187e054a44f46022b5f4d8 Mon Sep 17 00:00:00 2001 From: DynamoFox Date: Sun, 28 Jul 2024 12:26:08 +0200 Subject: [PATCH] Workaround GLEW error code when calling glewInit() on Wayland * Fixes OpenGL on Wayland when the GLX flavor of GLEW is linked * Only if SDL2's video driver is "wayland" we also allow the GLEW_ERROR_NO_GLX_DISPLAY error code to be accepted as if glewInit() actually succeeded * Hopefully this won't be needed anymore on future versions of GLEW when glewContextInit() is made part of the public API --- src/engine/client/backend_sdl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 0adfd82d2..8dccd39cf 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -443,7 +443,9 @@ static bool BackendInitGlew(EBackendType BackendType, int &GlewMajor, int &GlewM #ifdef CONF_GLEW_HAS_CONTEXT_INIT if(GLEW_OK != glewContextInit()) #else - if(GLEW_OK != glewInit()) + GLenum InitResult = glewInit(); + const char *pVideoDriver = SDL_GetCurrentVideoDriver(); + if(GLEW_OK != InitResult && pVideoDriver && !str_comp(pVideoDriver, "wayland") && GLEW_ERROR_NO_GLX_DISPLAY != InitResult) #endif return false;