Skip to content

Fix blank 3D viewport on Linux/NVIDIA (#264, #275)#351

Open
studiofuga wants to merge 2 commits into
Snapmaker:mainfrom
studiofuga:issues/264
Open

Fix blank 3D viewport on Linux/NVIDIA (#264, #275)#351
studiofuga wants to merge 2 commits into
Snapmaker:mainfrom
studiofuga:issues/264

Conversation

@studiofuga
Copy link
Copy Markdown

The 3D viewport stayed blank on Linux/NVIDIA (#264) because the GLEW loader failed to initialize the modern OpenGL context (glewInit → "Missing GL version"), preventing the render loop from ever starting: this PR migrates GL function loading from GLEW to GLAD (as upstream OrcaSlicer does), restoring native
rendering.

This PR also resolves #275: since native GL now works, the workaround that forced the zink driver on NVIDIA — the source of the "zink: could not create swapchain" error — is no longer needed and is removed (made opt-in via ZINK_FORCE_OVERRIDE=1).

studiofuga and others added 2 commits May 21, 2026 15:42
…r#264)

Problem
-------
On Linux with NVIDIA (driver 590.x) the central 3D viewport stayed blank:
the bed, grid and objects were never drawn (both the "Prepare" scene and
the G-code preview), while the WebKit/Flutter store front-page rendered
fine. The OpenGL 4.6 context, shaders and framebuffer were all healthy
(glxgears/vkcube worked), so it was not a driver problem.

Root cause: the 3D canvas render loop never ran because OpenGLManager::
init_gl() failed at glewInit() with GLEW_ERROR_NO_GL_VERSION ("Missing GL
version"). On a modern GL context glewInit() does not initialise correctly
with the GLEW build linked here, even though the context is valid and
glGetString(GL_VERSION) returns "4.6.0 NVIDIA" when queried via
glXGetProcAddress. With init_gl() failing the canvas was never marked
initialised and render() returned early, so nothing was ever cleared,
drawn or swapped.

Upstream OrcaSlicer does not hit this because it loads GL through GLAD
(glXGetProcAddress) instead of GLEW. The Snapmaker fork still used GLEW.

Fix
---
- Add the GLAD loader (src/glad, ported from OrcaSlicer) and link it into
  libslic3r_gui instead of GLEW::GLEW.
- Replace every `#include <GL/glew.h>` with `#include <glad/gl.h>`.
- OpenGLManager::init_gl(): load with gladLoaderLoadGL() and use the
  GLAD_GL_* extension macros instead of glewInit()/GLEW_*.
- OpenGLManager::init_glcontext(): create an explicit compatibility-profile
  context (the renderer relies on compatibility-profile GL).
- Convert the EXT framebuffer/renderbuffer calls (gl*FramebufferEXT,
  GL_FRAMEBUFFER_EXT, GL_MAX_SAMPLES_EXT, ...) to their core equivalents,
  which GLAD exposes (GL_EXT_framebuffer_object was promoted to core 3.0).
- GLTexture::generate_from_text(): bail out if the GL function pointers are
  not loaded yet. The bed shape (and its plate-name texture) is set during
  MainFrame construction, before the 3D canvas initialises OpenGL, so the
  GLAD pointers can still be null there; the texture is regenerated lazily
  during rendering once GL is ready.
- deps/wxWidgets: build the wxGLCanvas with the GLX backend
  (-DwxUSE_GLCANVAS_EGL=OFF), as OrcaSlicer does; the EGL canvas does not
  present/repaint reliably on NVIDIA.

Verified on NVIDIA RTX 4060 / driver 590.48.01 (Wayland session): the 3D
viewport now renders correctly both on native NVIDIA GL and via zink.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Linux launcher forced the Mesa/zink GL driver on NVIDIA + Wayland with
driver > 555 to work around the blank 3D viewport. That blank viewport was
actually caused by the GLEW loader failing to initialise the GL context;
it is fixed by the migration to GLAD. Forcing zink is counter-productive
now: on some NVIDIA setups it fails with "zink: could not create swapchain"
(no DRI3 modifiers), which is the original symptom users reported.

Make zink opt-in (export ZINK_FORCE_OVERRIDE=1) and default to the native
GL driver, which now renders correctly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slicing crashes with Zink vkMapMemory error on NVIDIA (Wayland)

1 participant