Skip to content

Commit

Permalink
Fix transparency issues on Wayland (openscad#5677)
Browse files Browse the repository at this point in the history
  • Loading branch information
frysztak authored Feb 19, 2025
1 parent d9859a0 commit 91070a0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/glview/GLView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,24 @@ void GLView::paintGL()
}
glDisable(GL_LIGHTING);
if (showaxes) GLView::showSmallaxes(axescolor);

// Workaround for inconsistent QT behavior related to handling custom OpenGL widgets that
// leave non opaque alpha values in final output.
// On wayland that can cause window to become transparent or blurry trail effect in the
// parts that contain partially transparent objects.
//
// At the end of rendering clear alpha value, so that it doesn't matter how rest of the
// compositing stack at QT and desktop level would interpret transparent pixels.
//
// Solves https://github.com/openscad/openscad/issues/3689.
//
// Originally developed by @karliss for FreeCAD (https://github.com/FreeCAD/FreeCAD/pull/19499).
GLboolean mask[4];
glGetBooleanv(GL_COLOR_WRITEMASK, mask);
glColorMask(false, false, false, true);
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
glColorMask(mask[0], mask[1], mask[2], mask[3]);
}

#ifdef ENABLE_OPENCSG
Expand Down

0 comments on commit 91070a0

Please sign in to comment.