From c9ff080f5e37b14f426d5cd1883a391bb4cdee1f Mon Sep 17 00:00:00 2001 From: Victor Bogado da Silva Lins Date: Thu, 8 Oct 2026 17:39:11 -0400 Subject: [PATCH 1/2] Fix glew init issue when using on Wayland --- src/Processing.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Processing.cpp b/src/Processing.cpp index ab869d9..1c89d3f 100644 --- a/src/Processing.cpp +++ b/src/Processing.cpp @@ -3630,7 +3630,12 @@ void PApplet::run(){ glewExperimental = GL_TRUE; glewExperimental = GL_TRUE; GLenum glewErr = glewInit(); +#ifdef linux + if(glewErr != GLEW_OK && getenv("WAYLAND-DISPLAY") != nullptr && glewErr != GLEW_ERROR_NO_GLX_DISPLAY){ +#else if(glewErr != GLEW_OK){ +#endif + #ifdef _WIN32 char msg[256]; snprintf(msg,sizeof(msg),"glewInit() failed: %s", glewGetErrorString(glewErr)); MessageBoxA(NULL, msg, "processing-cpp Error", MB_OK|MB_ICONERROR); From 52fa7cbc4ef6de2e7e217dad04a7936e7eb0f081 Mon Sep 17 00:00:00 2001 From: pepc84 Date: Tue, 20 Oct 2026 13:16:31 -0700 Subject: [PATCH 2/2] 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 --- src/Processing.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Processing.cpp b/src/Processing.cpp index 1c89d3f..c67925d 100644 --- a/src/Processing.cpp +++ b/src/Processing.cpp @@ -3628,13 +3628,15 @@ void PApplet::run(){ }); glfwMakeContextCurrent(gWindow); glewExperimental = GL_TRUE; - glewExperimental = GL_TRUE; GLenum glewErr = glewInit(); -#ifdef linux - if(glewErr != GLEW_OK && getenv("WAYLAND-DISPLAY") != nullptr && glewErr != GLEW_ERROR_NO_GLX_DISPLAY){ -#else - if(glewErr != GLEW_OK){ + bool glewOk = (glewErr == GLEW_OK); +#if defined(__linux__) && defined(GLEW_ERROR_NO_GLX_DISPLAY) + // A GLX-built GLEW reports NO_GLX_DISPLAY under native Wayland (GLFW uses EGL there), + // but the core GL functions are already loaded by then, so it's safe to carry on. + if (!glewOk && glewErr == GLEW_ERROR_NO_GLX_DISPLAY && getenv("WAYLAND_DISPLAY") != nullptr) + glewOk = true; #endif + if(!glewOk){ #ifdef _WIN32 char msg[256]; snprintf(msg,sizeof(msg),"glewInit() failed: %s", glewGetErrorString(glewErr));