From ebd26c24290e5c916eb86b74079ee1559124f072 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Thu, 16 Jan 2025 09:12:37 +0900 Subject: [PATCH 1/2] fix frame background if a texture is present --- .../gl/component/rendering3d/OglSceneFrame.cpp | 18 +++++++++++++----- .../gl/component/rendering3d/OglSceneFrame.h | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.cpp b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.cpp index 5e6e47ccc7a..52e20e300b6 100644 --- a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.cpp +++ b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.cpp @@ -42,6 +42,7 @@ OglSceneFrame::OglSceneFrame() , d_style(initData(&d_style, defaultStyle, "style", ("Style of the frame\n" + Style::dataDescription()).c_str())) , d_alignment(initData(&d_alignment, defaultAlignment, "alignment", ("Alignment of the frame in the view\n" + Alignment::dataDescription()).c_str())) , d_viewportSize(initData(&d_viewportSize, 150, "viewportSize", "Size of the viewport where the frame is rendered")) + , d_solidBackground(initData(&d_solidBackground, false, "solidBackground", "If true, an opaque bkacground will be rendered; otherwise the frame is rendered on top on the normal viewport.")) {} void OglSceneFrame::drawArrows(const core::visual::VisualParams* vparams) @@ -129,12 +130,19 @@ void OglSceneFrame::doDrawVisual(const core::visual::VisualParams* vparams) glScissor(0,viewport[3]-viewportSize,viewportSize,viewportSize); break; } - - + glEnable(GL_SCISSOR_TEST); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - glClearColor (1.0f, 1.0f, 1.0f, 0.0f); - + if(d_solidBackground.getValue()) + { + // reset color and depth for the mini viewport (setting a background and making render on front) + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + } + else + { + // only reset depth to appear on front + glClear(GL_DEPTH_BUFFER_BIT ); + } + glMatrixMode(GL_PROJECTION); vparams->drawTool()->pushMatrix(); glLoadIdentity(); diff --git a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.h b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.h index d834c9584d1..224b81876e8 100644 --- a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.h +++ b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.h @@ -58,6 +58,7 @@ class SOFA_GL_COMPONENT_RENDERING3D_API OglSceneFrame : public core::visual::Vis Data d_alignment; ///< Alignment of the frame in the view Data d_viewportSize; ///< Size of the viewport where the frame is rendered + Data d_solidBackground; OglSceneFrame(); From f27189d24269cd1281348a952ff70baeb0674843 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Fri, 17 Jan 2025 09:43:26 +0900 Subject: [PATCH 2/2] remove old behavior data --- .../sofa/gl/component/rendering3d/OglSceneFrame.cpp | 13 ++----------- .../sofa/gl/component/rendering3d/OglSceneFrame.h | 1 - 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.cpp b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.cpp index 52e20e300b6..52d4665c039 100644 --- a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.cpp +++ b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.cpp @@ -42,7 +42,6 @@ OglSceneFrame::OglSceneFrame() , d_style(initData(&d_style, defaultStyle, "style", ("Style of the frame\n" + Style::dataDescription()).c_str())) , d_alignment(initData(&d_alignment, defaultAlignment, "alignment", ("Alignment of the frame in the view\n" + Alignment::dataDescription()).c_str())) , d_viewportSize(initData(&d_viewportSize, 150, "viewportSize", "Size of the viewport where the frame is rendered")) - , d_solidBackground(initData(&d_solidBackground, false, "solidBackground", "If true, an opaque bkacground will be rendered; otherwise the frame is rendered on top on the normal viewport.")) {} void OglSceneFrame::drawArrows(const core::visual::VisualParams* vparams) @@ -132,16 +131,8 @@ void OglSceneFrame::doDrawVisual(const core::visual::VisualParams* vparams) } glEnable(GL_SCISSOR_TEST); - if(d_solidBackground.getValue()) - { - // reset color and depth for the mini viewport (setting a background and making render on front) - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - } - else - { - // only reset depth to appear on front - glClear(GL_DEPTH_BUFFER_BIT ); - } + // only reset depth to appear on front + glClear(GL_DEPTH_BUFFER_BIT ); glMatrixMode(GL_PROJECTION); vparams->drawTool()->pushMatrix(); diff --git a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.h b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.h index 224b81876e8..d834c9584d1 100644 --- a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.h +++ b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglSceneFrame.h @@ -58,7 +58,6 @@ class SOFA_GL_COMPONENT_RENDERING3D_API OglSceneFrame : public core::visual::Vis Data d_alignment; ///< Alignment of the frame in the view Data d_viewportSize; ///< Size of the viewport where the frame is rendered - Data d_solidBackground; OglSceneFrame();