From 3ae8e66ee7c2c488dfe3c32457a26822eba8b236 Mon Sep 17 00:00:00 2001 From: Mel Date: Wed, 17 Apr 2024 00:12:56 +0200 Subject: Hack to fix GLEW EGL/GLX confusion error --- src/Render.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Render.cpp b/src/Render.cpp index c4ed147..1089ad4 100644 --- a/src/Render.cpp +++ b/src/Render.cpp @@ -110,9 +110,17 @@ void Render::render_scene(Scene const& scene, GFX::Texture const& texture) const void Render::setup_gl() { GLenum error = glewInit(); - if (error != GLEW_OK) { - std::string error_string(reinterpret_cast(glewGetErrorString(error))); - throw std::runtime_error("Failed to load GL functions: " + error_string); + + // We get a NO_GLX_DISPLAY error on Linux/Wayland during GLEW initialization. + // Since we're not using GLX (under Wayland), it is presumably fine to ignore this error, + // and it seems to appear due to some sort of confusion in GLEW when to use GLX or EGL. + // See this GLEW issue: https://github.com/nigels-com/glew/issues/273 + if (error != GLEW_OK && error != GLEW_ERROR_NO_GLX_DISPLAY) { + Char error_code[8]; + snprintf(error_code, sizeof(error_code), "%X", error); + + std::string error_string { reinterpret_cast(glewGetErrorString(error)) }; + throw std::runtime_error("Failed to load GL functions: " + error_string + " (0x" + error_code + ")"); } } -- cgit 1.4.1