Skip to content

Commit 52fa7cb

Browse files
committed
Wayland GLEW fix: use __linux__ and WAYLAND_DISPLAY, keep X11 errors
- #ifdef linux isn't defined under -std=c++2c/c++23, which CppMode builds with - the env var is WAYLAND_DISPLAY (underscore) - only NO_GLX_DISPLAY on Wayland is ignored; every other glewInit error is still reported - drop the duplicated glewExperimental line
1 parent c9ff080 commit 52fa7cb

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎src/Processing.cpp‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3628,13 +3628,15 @@ void PApplet::run(){
36283628
});
36293629
glfwMakeContextCurrent(gWindow);
36303630
glewExperimental = GL_TRUE;
3631-
glewExperimental = GL_TRUE;
36323631
GLenum glewErr = glewInit();
3633-
#ifdef linux
3634-
if(glewErr != GLEW_OK && getenv("WAYLAND-DISPLAY") != nullptr && glewErr != GLEW_ERROR_NO_GLX_DISPLAY){
3635-
#else
3636-
if(glewErr != GLEW_OK){
3632+
bool glewOk = (glewErr == GLEW_OK);
3633+
#if defined(__linux__) && defined(GLEW_ERROR_NO_GLX_DISPLAY)
3634+
// A GLX-built GLEW reports NO_GLX_DISPLAY under native Wayland (GLFW uses EGL there),
3635+
// but the core GL functions are already loaded by then, so it's safe to carry on.
3636+
if (!glewOk && glewErr == GLEW_ERROR_NO_GLX_DISPLAY && getenv("WAYLAND_DISPLAY") != nullptr)
3637+
glewOk = true;
36373638
#endif
3639+
if(!glewOk){
36383640

36393641
#ifdef _WIN32
36403642
char msg[256]; snprintf(msg,sizeof(msg),"glewInit() failed: %s", glewGetErrorString(glewErr));

0 commit comments

Comments
 (0)