From 4bf14e7096d407820cee4f583570b3a7bdf35ed7 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 11 Mar 2017 23:23:55 +0100 Subject: [PATCH] Ot5OpenGL: fix phantom objects in sketcher selection mode, get texture with the exact content of the 3d viewer --- src/Gui/View3DInventorViewer.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index b64e85c971..a3268f51c7 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -1383,10 +1383,7 @@ void View3DInventorViewer::setRenderType(const RenderType type) fboFormat.setInternalTextureFormat(GL_RGBA32F_ARB); QOpenGLFramebufferObject fbo(width, height, fboFormat); - fbo.bind(); - //renderToFramebuffer(&fbo); // may give slightly different results than what is shown in the gl widget - renderScene(); - fbo.release(); + renderToFramebuffer(&fbo); glImage = fbo.toImage(false); } @@ -1422,17 +1419,23 @@ void View3DInventorViewer::renderToFramebuffer(QtGLFramebufferObject* fbo) // If on then transparent areas may shine through opaque areas //glDepthRange(0.1,1.0); - SoGLRenderAction gl(SbViewportRegion(width, height)); + SoBoxSelectionRenderAction gl(SbViewportRegion(width, height)); // When creating a new GL render action we have to copy over the cache context id // For further details see init(). uint32_t id = this->getSoRenderManager()->getGLRenderAction()->getCacheContext(); gl.setCacheContext(id); gl.setTransparencyType(SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND); + if (!this->shading) { SoLightModelElement::set(gl.getState(), selectionRoot, SoLightModelElement::BASE_COLOR); SoOverrideElement::setLightModelOverride(gl.getState(), selectionRoot, true); } + gl.apply(this->backgroundroot); + // The render action of the render manager has set the depth function to GL_LESS + // while creating a new render action has it set to GL_LEQUAL. So, in order to get + // the exact same result set it explicitly to GL_LESS. + glDepthFunc(GL_LESS); gl.apply(this->getSoRenderManager()->getSceneGraph()); gl.apply(this->foregroundroot);