diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 5ed5b6b146..695b546cd0 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -2102,6 +2102,7 @@ void View3DInventorViewer::renderScene() SoGLWidgetElement::set(state, qobject_cast(this->getGLWidget())); SoGLRenderActionElement::set(state, glra); SoGLVBOActivatedElement::set(state, this->vboEnabled); + drawSingleBackground(col); glra->apply(this->backgroundroot); navigation->updateAnimation(); @@ -3310,6 +3311,39 @@ void View3DInventorViewer::drawArrow() glEnd(); } +void View3DInventorViewer::drawSingleBackground(const QColor& col) +{ + // Note: After changing the NaviCube code the content of an image plane may appear black. + // A workaround is this function. + // See also: https://github.com/FreeCAD/FreeCAD/pull/9356#issuecomment-1529521654 + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(-1, 1, -1, 1, -1, 1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glPushAttrib(GL_ENABLE_BIT); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); + glBegin(GL_TRIANGLE_STRIP); + glColor3f(col.redF(), col.greenF(), col.blueF()); + glVertex2f(-1, 1); + glColor3f(col.redF(), col.greenF(), col.blueF()); + glVertex2f(-1, -1); + glColor3f(col.redF(), col.greenF(), col.blueF()); + glVertex2f(1, 1); + glColor3f(col.redF(), col.greenF(), col.blueF()); + glVertex2f(1, -1); + glEnd(); + glPopAttrib(); + glPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); +} + // ************************************************************************ // Set cursor graphics according to mode. diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index 1eda1bce60..856a778252 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -467,6 +467,7 @@ private: void initialize(); void drawAxisCross(); static void drawArrow(); + void drawSingleBackground(const QColor&); void setCursorRepresentation(int mode); void aboutToDestroyGLContext() override; void createStandardCursors(double);