diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index 8269297008..e685425f9b 100755 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -465,7 +465,6 @@ void OpenGl_PrimitiveArray::drawEdges (const TEL_COLOUR* theEdgeCo const OpenGl_AspectLine* anAspect = theWorkspace->AspectLine (Standard_True); #if !defined(GL_ES_VERSION_2_0) - glPushAttrib (GL_POLYGON_BIT); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); #endif @@ -522,9 +521,6 @@ void OpenGl_PrimitiveArray::drawEdges (const TEL_COLOUR* theEdgeCo myVboAttribs->UnbindAttribute (aGlContext, Graphic3d_TOA_POS); // restore line context -#if !defined(GL_ES_VERSION_2_0) - glPopAttrib(); -#endif theWorkspace->SetAspectLine (anAspectLineOld); } @@ -789,6 +785,15 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace || anAspectFace->InteriorStyle() == Aspect_IS_HIDDENLINE) { drawEdges (anEdgeColor, theWorkspace); + + #if !defined(GL_ES_VERSION_2_0) + // restore OpenGL polygon mode if needed + if (anAspectFace->InteriorStyle() >= Aspect_IS_HATCH) + { + glPolygonMode (GL_FRONT_AND_BACK, + anAspectFace->InteriorStyle() == Aspect_IS_POINT ? GL_POINT : GL_FILL); + } + #endif } } diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index 8f3f8a40da..15bf41c7fd 100755 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -412,6 +412,12 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const { theWorkspace->EnableTexture (aPrevTexture); } + + // restore Z buffer settings + if (theWorkspace->UseZBuffer() && theWorkspace->UseDepthTest()) + { + glEnable (GL_DEPTH_TEST); + } } // ======================================================================= @@ -581,21 +587,14 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, return aFont; } - Handle(OpenGl_Context) aCtx = theCtx; - #if !defined(GL_ES_VERSION_2_0) - glPushAttrib (GL_TEXTURE_BIT); - #endif aFont = new OpenGl_Font (aFontFt, theKey); - if (!aFont->Init (aCtx)) - { - //glPopAttrib(); - //return aFont; // out of resources? - } - #if !defined(GL_ES_VERSION_2_0) - glPopAttrib(); // texture bit - #endif - aCtx->ShareResource (theKey, aFont); + if (!aFont->Init (theCtx)) + { + // out of resources? + } + + theCtx->ShareResource (theKey, aFont); } return aFont; } @@ -705,8 +704,6 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, #if !defined(GL_ES_VERSION_2_0) - // push enabled flags to the stack - glPushAttrib (GL_ENABLE_BIT); glDisable (GL_LIGHTING); // setup depth test @@ -818,15 +815,15 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, glEnd(); glStencilFunc (GL_ALWAYS, 0, 0xFF); - // glPopAttrib() will reset state for us - //glDisable (GL_STENCIL_TEST); - //if (!myIs2d) glEnable (GL_DEPTH_TEST); glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } - // revert OpenGL state - glPopAttrib(); // enable bit + // reset OpenGL state + glDisable (GL_BLEND); + glDisable (GL_ALPHA_TEST); + glDisable (GL_STENCIL_TEST); + glDisable (GL_COLOR_LOGIC_OP); // model view matrix was modified theCtx->WorldViewState.Pop(); diff --git a/src/OpenGl/OpenGl_View_2.cxx b/src/OpenGl/OpenGl_View_2.cxx index 9cad122f50..eb479e775d 100644 --- a/src/OpenGl/OpenGl_View_2.cxx +++ b/src/OpenGl/OpenGl_View_2.cxx @@ -241,7 +241,7 @@ void OpenGl_View::DrawBackground (const Handle(OpenGl_Workspace)& theWorkspace) aCtx->ProjectionState.Pop(); aCtx->ApplyProjectionMatrix(); - if (theWorkspace->UseZBuffer()) + if (theWorkspace->UseZBuffer() && theWorkspace->ToRedrawGL()) { aCtx->core11fwd->glEnable (GL_DEPTH_TEST); } @@ -586,26 +586,18 @@ void OpenGl_View::InvalidateBVHData (const Graphic3d_ZLayerId theLayerId) /*----------------------------------------------------------------------*/ //ExecuteViewDisplay -void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace)& AWorkspace, +void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace)& theWorkspace, const Standard_Boolean theToDrawImmediate) { if ( myZLayers.NbStructures() <= 0 ) return; - const Handle(OpenGl_Context)& aCtx = AWorkspace->GetGlContext(); -#if !defined(GL_ES_VERSION_2_0) - if (aCtx->core11 != NULL) - { - aCtx->core11->glPushAttrib (GL_DEPTH_BUFFER_BIT); - } -#endif + const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext(); - //TsmPushAttri(); /* save previous graphics context */ - - if ( (AWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED) == 0 ) + if ( (theWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED) == 0 ) { #if !defined(GL_ES_VERSION_2_0) - const int antiAliasingMode = AWorkspace->AntiAliasingMode(); + const int anAntiAliasingMode = theWorkspace->AntiAliasingMode(); #endif if ( !myAntiAliasing ) @@ -616,7 +608,7 @@ void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace)& AWorkspace, glDisable (GL_POINT_SMOOTH); } glDisable(GL_LINE_SMOOTH); - if( antiAliasingMode & 2 ) glDisable(GL_POLYGON_SMOOTH); + if( anAntiAliasingMode & 2 ) glDisable(GL_POLYGON_SMOOTH); #endif glBlendFunc (GL_ONE, GL_ZERO); glDisable (GL_BLEND); @@ -629,21 +621,14 @@ void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace)& AWorkspace, glEnable(GL_POINT_SMOOTH); } glEnable(GL_LINE_SMOOTH); - if( antiAliasingMode & 2 ) glEnable(GL_POLYGON_SMOOTH); + if( anAntiAliasingMode & 2 ) glEnable(GL_POLYGON_SMOOTH); #endif glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable (GL_BLEND); } } - myZLayers.Render (AWorkspace, theToDrawImmediate); - -#if !defined(GL_ES_VERSION_2_0) - if (aCtx->core11 != NULL) - { - aCtx->core11->glPopAttrib(); - } -#endif + myZLayers.Render (theWorkspace, theToDrawImmediate); } /*----------------------------------------------------------------------*/