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
This commit is contained in:
DynamoFox 2024-07-28 12:26:08 +02:00
parent 41cd82c2d3
commit fe35322bb0

View file

@ -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;