refactor(gui): migrate GLEW→GLAD for Linux/NVIDIA viewport (#351) - #8
Merged
Merged
Conversation
Add the GLAD OpenGL loader from Snapmaker#351 (ported from OrcaSlicer) and link it into libslic3r_gui instead of GLEW::GLEW. Keep GLEW discovery for sandboxes/OpenCSG. Build wxGLCanvas with the GLX backend (wxUSE_GLCANVAS_EGL=OFF) so NVIDIA Linux presents reliably. Co-authored-by: aceRage <aceRage@users.noreply.github.com>
Load GL via gladLoaderLoadGL() instead of glewInit(), which fails with "Missing GL version" on modern NVIDIA contexts. Request an explicit compatibility-profile wxGLContext, falling back to the default context. Preserve Ultra's OpenGLManager::s_active hook. Co-authored-by: aceRage <aceRage@users.noreply.github.com>
Replace every GL/glew.h include with glad/gl.h, GLEW_* extension macros with GLAD_GL_*, and EXT framebuffer/renderbuffer entry points with their core equivalents. Guard GLTexture::generate_from_text() when GLAD pointers are still null during MainFrame construction. Ultra-specific rebase care: FacetPicker, 3DScene outline depth FBO (paint/camera path), and GLCanvas3D thumbnail/picking FBOs sit next to Stream/paint-depth changes and needed the same EXT→core conversion. Co-authored-by: aceRage <aceRage@users.noreply.github.com>
The AppImage launcher forced Mesa/Zink on NVIDIA + Wayland (driver >555) to work around a blank 3D viewport. That blank viewport was GLEW failing to initialise; GLAD restores native GL. Forcing Zink can fail with "zink: could not create swapchain", so enable it only when ZINK_FORCE_OVERRIDE=1 is set. Co-authored-by: aceRage <aceRage@users.noreply.github.com>
…napmaker#713) Prefer opt-in Zink (ZINK_FORCE_OVERRIDE=1) now that native NVIDIA GL works via GLAD. Keep Snapmaker#713 auto-Zink only as a temporary fallback behind ZINK_AUTO_NVIDIA=1 on NVIDIA Wayland (driver major >555). ZINK_DISABLE_OVERRIDE=1 still skips Zink. Retain WebKit DMA-BUF disable for all NVIDIA Flatpak sessions. Ultra exec path stays /app/bin/snapmaker-orca. Co-authored-by: aceRage <aceRage@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Hard upstream port of Snapmaker/OrcaSlicer#351 (OPEN, blocked): migrate OpenGL function loading from GLEW to GLAD so native Linux/NVIDIA OpenGL works, and make Zink opt-in.
This is a separate PR from #7 (Easy port of Snapmaker#713). #7 auto-enables Zink on Flatpak NVIDIA Wayland as a GLEW-era workaround. Once GLAD lands, native NVIDIA GL works and that auto-Zink path should not stay on by default.
Fixes (upstream): Snapmaker#264 (blank 3D viewport on Linux/NVIDIA —
glewInit→ "Missing GL version"), Snapmaker#275 (forced Zink "could not create swapchain").Commit series
build: vendor glad and CMake wiring (#351)— addsrc/glad/(gl.c/gl.h/khrplatform.h), linkgladinstead ofGLEW::GLEWinlibslic3r_gui,wxUSE_GLCANVAS_EGL=OFF(GLX backend; also mirrored in the Flatpak wxWidgets recipe).refactor(gui): OpenGLManager glewInit → gladLoadGL (#351)—gladLoaderLoadGL(), compatibility-profilewxGLContext, keep UltraOpenGLManager::s_active.refactor(gui): replace GLEW includes/macros across GUI (#351)—#include <glad/gl.h>,GLAD_GL_*macros, EXT framebuffer/renderbuffer → core;GLTexture::generate_from_text()null-loader guard.fix(linux): make AppImage Zink opt-in (#351)— enable Mesa/Zink only whenZINK_FORCE_OVERRIDE=1.chore(flatpak): align entrypoint Zink policy with GLAD (#351/#713)— prefer opt-in; keep Fix blank Flatpak canvas on NVIDIA Wayland Snapmaker/OrcaSlicer#713 auto-Zink only as a temporary fallback behindZINK_AUTO_NVIDIA=1.Zink policy (after this PR)
ZINK_FORCE_OVERRIDE=1ZINK_DISABLE_OVERRIDE=1ZINK_AUTO_NVIDIA=1WebKit DMA-BUF remains disabled for all NVIDIA Flatpak sessions. Ultra binary path stays
/app/bin/snapmaker-orca.Rebase risk areas (Ultra-specific)
Expect conflicts if #7 or later Stream/camera/paint-depth work lands first:
OpenGLManager.cpp— Ultra still hadglewInit()at ~247 pluss_active; this PR keepss_activeand switches the loader.GLCanvas3D.cpp/.hpp— thumbnail + rectangular-picking offscreen FBOs sit next to Stream/camera work; EXT entry points converted to core.3DScene.cpp— Ultra outline/depth FBO path (paint/camera) usedgl*FramebufferEXT; converted to core.Gizmos/FacetPicker.cpp,GLGizmoPainterBase.*— paint-depth gizmos; include-only here, but high rebase care.Camera.cpp,StreamPanel.*— Camera include swapped; StreamPanel had no GLEW include and was left untouched.scripts/flatpak/entrypoint— will conflict with fix(flatpak): NVIDIA Wayland Zink override in entrypoint (#713) #7; this PR is the post-GLAD policy. Prefer merging this after or instead of auto-Zink-on-by-default.No unrelated GUI refactors. GLEW remains in
deps// sandboxes/OpenCSG only.Screenshots/Recordings/Graphs
N/A in cloud — no NVIDIA Wayland session. Hardware verification is required on Linux/NVIDIA (Prepare + G-code preview).
Tests
Cloud smoke completed (no NVIDIA Wayland / no full slicer build):
gcc -c src/glad/src/gl.c -I src/glad/include— glad object compiles.glew.h/GLEW_*/glewInit(comment inOpenGLManageronly).gladLoaderLoadGL(),s_active, and compatibility-profile context are present.GLAD_GL_ARB_framebuffer_object,GLAD_GL_EXT_framebuffer_object,GLAD_GL_EXT_texture_compression_s3tc,GLAD_GL_EXT_texture_filter_anisotropic.-s sh) onscripts/flatpak/entrypoint: clean.sh -nclean.-s bash) andbash -nclean; Zink only whenZINK_FORCE_OVERRIDE=1.610/555/470; default NVIDIA Wayland = no Zink + WebKit DMA-BUF still disabled; Intel unchanged;ZINK_FORCE_OVERRIDE=1enables;ZINK_DISABLE_OVERRIDE=1wins;ZINK_AUTO_NVIDIA=1only on Wayland with major >555; Ultraexec /app/bin/snapmaker-orcapreserved.Cloud cannot smoke NVIDIA Wayland. This environment has no NVIDIA driver, Wayland compositor, Flatpak runtime, or full slicer/deps build. Hardware checks remain:
ZINK_FORCE_OVERRIDE=1still routes through Mesa/Zink if needed.ZINK_AUTO_NVIDIA=1restores Fix blank Flatpak canvas on NVIDIA Wayland Snapmaker/OrcaSlicer#713 auto-Zink;ZINK_DISABLE_OVERRIDE=1skips it.new wxGLContext). Not verified in this cloud environment — no Windows/macOS toolchain here.Breaking / dependency notes
GLEW::GLEW; it links the vendoredgladstatic library.-DwxUSE_GLCANVAS_EGL=OFF(rebuild deps on Linux if the wxGLCanvas backend was previously EGL).ZINK_FORCE_OVERRIDE=1(or FlatpakZINK_AUTO_NVIDIA=1).