From e57e6a5cbee1543e43917ff5debde8d7732ce03d Mon Sep 17 00:00:00 2001 From: ostermine Date: Sun, 11 Oct 2026 21:36:34 +0300 Subject: [PATCH] fix modelviewer background is not transparent --- src/graphics/ui/elements/ModelViewer.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/graphics/ui/elements/ModelViewer.cpp b/src/graphics/ui/elements/ModelViewer.cpp index 435f3340d..043475d13 100644 --- a/src/graphics/ui/elements/ModelViewer.cpp +++ b/src/graphics/ui/elements/ModelViewer.cpp @@ -120,7 +120,7 @@ void ModelViewer::draw(const DrawContext& pctx, const Assets& assets) { if (size.x <= 0 || size.y <= 0) { return; } - fbo = std::make_unique(size.x, size.y); + fbo = std::make_unique(size.x, size.y, true); } fbo->resize(size.x, size.y); { @@ -130,7 +130,14 @@ void ModelViewer::draw(const DrawContext& pctx, const Assets& assets) { ctx.setViewport({size.x, size.y}); ctx.setDepthTest(true); ctx.setCullFace(true); + // transparent background, the screen clear color is restored below + GLfloat clearColor[4]; + glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); display::clear(); + glClearColor( + clearColor[0], clearColor[1], clearColor[2], clearColor[3] + ); auto& ui3dShader = assets.require("ui3d"); ui3dShader.use();