From 26395493b00b192773d2dabbee58a5548a80cb55 Mon Sep 17 00:00:00 2001 From: san Date: Fri, 3 Aug 2012 11:16:58 +0400 Subject: [PATCH] 0023363: [Regression] Lost gradient background when switching to the hollow interior style Calling glPolygonMode() to ensure filled polygon rendering when drawing the view background Revert "Calling glPolygonMode() to ensure filled polygon rendering when drawing" This reverts commit 41d41ab23cb81acb3bcf7e6ad5d10ea0097eecdd. OpenGl_Workspace::ResetAppliedAspect() method improved in order to reset GL parameters to default values specified in default aspects. This method is now called twice during scene rendering: - At the very beginning by OpenGl_Workspace::Activate() - After all structures has been drawn but before the auxiliary stuff (like trihedrons, overlayer, display callbacks) --- src/OpenGl/OpenGl_View_2.cxx | 17 ++++-------- src/OpenGl/OpenGl_Workspace.cxx | 44 +++++++++++++++++++++---------- src/OpenGl/OpenGl_Workspace_5.cxx | 16 ----------- 3 files changed, 35 insertions(+), 42 deletions(-) diff --git a/src/OpenGl/OpenGl_View_2.cxx b/src/OpenGl/OpenGl_View_2.cxx index cf9e3c5bf6..b6bc6100b3 100644 --- a/src/OpenGl/OpenGl_View_2.cxx +++ b/src/OpenGl/OpenGl_View_2.cxx @@ -960,8 +960,6 @@ D = -[Px,Py,Pz] dot |Nx| */ - glPushAttrib( GL_FOG_BIT | GL_LIGHTING_BIT | GL_ENABLE_BIT ); - // Apply Fog if ( myFog.IsOn ) { @@ -1185,8 +1183,11 @@ D = -[Px,Py,Pz] dot |Nx| } } - /* restore previous graphics context; before update lights */ - //TsmPopAttri(); + // Resetting GL parameters according to the default aspects + // in order to synchronize GL state with the graphic driver state + // before drawing auxiliary stuff (trihedrons, overlayer) + // and invoking optional callbacks + AWorkspace->ResetAppliedAspect(); // Disable current clipping planes for ( planeid = GL_CLIP_PLANE0; planeid < lastid; planeid++ ) @@ -1198,14 +1199,6 @@ D = -[Px,Py,Pz] dot |Nx| if (!myGraduatedTrihedron.IsNull()) myGraduatedTrihedron->Render(AWorkspace); - // The applied aspects should be reset to make it possible to - // update gl state and bring it into line with currently set - // aspects by reapplying them. Reset should be done, because - // the glPopAttrib() will return original gl state while the - // internal TKOpenGl state stills unchanged. - AWorkspace->ResetAppliedAspect(); - glPopAttrib(); // GL_FOG_BIT | GL_LIGHTING_BIT | GL_ENABLE_BIT - // Restore face culling if ( myBackfacing ) { diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index 8a773bb8ff..f44549ebf9 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -128,24 +128,14 @@ Standard_Boolean OpenGl_Workspace::Activate() if (!OpenGl_Window::Activate()) return Standard_False; - NamedStatus = IsTextureEnabled() ? OPENGL_NS_TEXTURE : 0; DegenerateModel = 0; SkipRatio = 0.0f; - HighlightColor = &myDefaultHighlightColor; - AspectLine_set = &myDefaultAspectLine; - AspectLine_applied = NULL; - AspectFace_set = &myDefaultAspectFace; - AspectFace_applied = NULL; - AspectMarker_set = &myDefaultAspectMarker; - AspectMarker_applied = NULL; - AspectText_set = &myDefaultAspectText; - AspectText_applied = NULL; - TextParam_set = &myDefaultTextParam; - TextParam_applied = NULL; ViewMatrix_applied = &myDefaultMatrix; StructureMatrix_applied = &myDefaultMatrix; - PolygonOffset_applied = NULL; - return Standard_True; + + ResetAppliedAspect(); + + return Standard_True; } // ======================================================================= @@ -160,3 +150,29 @@ void OpenGl_Workspace::UseTransparency (const Standard_Boolean theFlag) EraseAnimation(); } } + +//======================================================================= +//function : ResetAppliedAspect +//purpose : Sets default values of GL parameters in accordance with default aspects +//======================================================================= +void OpenGl_Workspace::ResetAppliedAspect() +{ + NamedStatus = IsTextureEnabled() ? OPENGL_NS_TEXTURE : 0; + HighlightColor = &myDefaultHighlightColor; + AspectLine_set = &myDefaultAspectLine; + AspectLine_applied = NULL; + AspectFace_set = &myDefaultAspectFace; + AspectFace_applied = NULL; + AspectMarker_set = &myDefaultAspectMarker; + AspectMarker_applied = NULL; + AspectText_set = &myDefaultAspectText; + AspectText_applied = NULL; + TextParam_set = &myDefaultTextParam; + TextParam_applied = NULL; + PolygonOffset_applied = NULL; + + AspectLine(Standard_True); + AspectFace(Standard_True); + AspectMarker(Standard_True); + AspectText(Standard_True); +} diff --git a/src/OpenGl/OpenGl_Workspace_5.cxx b/src/OpenGl/OpenGl_Workspace_5.cxx index eb42adccca..8e62005f0a 100644 --- a/src/OpenGl/OpenGl_Workspace_5.cxx +++ b/src/OpenGl/OpenGl_Workspace_5.cxx @@ -640,19 +640,3 @@ const OpenGl_AspectText * OpenGl_Workspace::AspectText(const Standard_Boolean Wi } return AspectText_set; } - -/*----------------------------------------------------------------------*/ - -//======================================================================= -//function : ResetAppliedAspect -//purpose : -//======================================================================= - -void OpenGl_Workspace::ResetAppliedAspect() -{ - AspectLine_applied = NULL; - AspectFace_applied = NULL; - AspectMarker_applied = NULL; - AspectText_applied = NULL; - TextParam_applied = NULL; -}