mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0025710: Visualization - Eliminate all calls of glPushAttrib/glPopAttrib in TKOpenGl
This commit is contained in:
parent
39d24c098c
commit
b34efb623c
@ -465,7 +465,6 @@ void OpenGl_PrimitiveArray::drawEdges (const TEL_COLOUR* theEdgeCo
|
|||||||
const OpenGl_AspectLine* anAspect = theWorkspace->AspectLine (Standard_True);
|
const OpenGl_AspectLine* anAspect = theWorkspace->AspectLine (Standard_True);
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
glPushAttrib (GL_POLYGON_BIT);
|
|
||||||
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
|
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -522,9 +521,6 @@ void OpenGl_PrimitiveArray::drawEdges (const TEL_COLOUR* theEdgeCo
|
|||||||
myVboAttribs->UnbindAttribute (aGlContext, Graphic3d_TOA_POS);
|
myVboAttribs->UnbindAttribute (aGlContext, Graphic3d_TOA_POS);
|
||||||
|
|
||||||
// restore line context
|
// restore line context
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
|
||||||
glPopAttrib();
|
|
||||||
#endif
|
|
||||||
theWorkspace->SetAspectLine (anAspectLineOld);
|
theWorkspace->SetAspectLine (anAspectLineOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -789,6 +785,15 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
|||||||
|| anAspectFace->InteriorStyle() == Aspect_IS_HIDDENLINE)
|
|| anAspectFace->InteriorStyle() == Aspect_IS_HIDDENLINE)
|
||||||
{
|
{
|
||||||
drawEdges (anEdgeColor, theWorkspace);
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,6 +412,12 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
|||||||
{
|
{
|
||||||
theWorkspace->EnableTexture (aPrevTexture);
|
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;
|
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);
|
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;
|
return aFont;
|
||||||
}
|
}
|
||||||
@ -705,8 +704,6 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
|
|||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
|
|
||||||
// push enabled flags to the stack
|
|
||||||
glPushAttrib (GL_ENABLE_BIT);
|
|
||||||
glDisable (GL_LIGHTING);
|
glDisable (GL_LIGHTING);
|
||||||
|
|
||||||
// setup depth test
|
// setup depth test
|
||||||
@ -818,15 +815,15 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
|
|||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glStencilFunc (GL_ALWAYS, 0, 0xFF);
|
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);
|
glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// revert OpenGL state
|
// reset OpenGL state
|
||||||
glPopAttrib(); // enable bit
|
glDisable (GL_BLEND);
|
||||||
|
glDisable (GL_ALPHA_TEST);
|
||||||
|
glDisable (GL_STENCIL_TEST);
|
||||||
|
glDisable (GL_COLOR_LOGIC_OP);
|
||||||
|
|
||||||
// model view matrix was modified
|
// model view matrix was modified
|
||||||
theCtx->WorldViewState.Pop();
|
theCtx->WorldViewState.Pop();
|
||||||
|
@ -241,7 +241,7 @@ void OpenGl_View::DrawBackground (const Handle(OpenGl_Workspace)& theWorkspace)
|
|||||||
aCtx->ProjectionState.Pop();
|
aCtx->ProjectionState.Pop();
|
||||||
aCtx->ApplyProjectionMatrix();
|
aCtx->ApplyProjectionMatrix();
|
||||||
|
|
||||||
if (theWorkspace->UseZBuffer())
|
if (theWorkspace->UseZBuffer() && theWorkspace->ToRedrawGL())
|
||||||
{
|
{
|
||||||
aCtx->core11fwd->glEnable (GL_DEPTH_TEST);
|
aCtx->core11fwd->glEnable (GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
@ -586,26 +586,18 @@ void OpenGl_View::InvalidateBVHData (const Graphic3d_ZLayerId theLayerId)
|
|||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
|
|
||||||
//ExecuteViewDisplay
|
//ExecuteViewDisplay
|
||||||
void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace)& AWorkspace,
|
void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||||
const Standard_Boolean theToDrawImmediate)
|
const Standard_Boolean theToDrawImmediate)
|
||||||
{
|
{
|
||||||
if ( myZLayers.NbStructures() <= 0 )
|
if ( myZLayers.NbStructures() <= 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Handle(OpenGl_Context)& aCtx = AWorkspace->GetGlContext();
|
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
|
||||||
if (aCtx->core11 != NULL)
|
|
||||||
{
|
|
||||||
aCtx->core11->glPushAttrib (GL_DEPTH_BUFFER_BIT);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//TsmPushAttri(); /* save previous graphics context */
|
if ( (theWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED) == 0 )
|
||||||
|
|
||||||
if ( (AWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED) == 0 )
|
|
||||||
{
|
{
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
const int antiAliasingMode = AWorkspace->AntiAliasingMode();
|
const int anAntiAliasingMode = theWorkspace->AntiAliasingMode();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( !myAntiAliasing )
|
if ( !myAntiAliasing )
|
||||||
@ -616,7 +608,7 @@ void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace)& AWorkspace,
|
|||||||
glDisable (GL_POINT_SMOOTH);
|
glDisable (GL_POINT_SMOOTH);
|
||||||
}
|
}
|
||||||
glDisable(GL_LINE_SMOOTH);
|
glDisable(GL_LINE_SMOOTH);
|
||||||
if( antiAliasingMode & 2 ) glDisable(GL_POLYGON_SMOOTH);
|
if( anAntiAliasingMode & 2 ) glDisable(GL_POLYGON_SMOOTH);
|
||||||
#endif
|
#endif
|
||||||
glBlendFunc (GL_ONE, GL_ZERO);
|
glBlendFunc (GL_ONE, GL_ZERO);
|
||||||
glDisable (GL_BLEND);
|
glDisable (GL_BLEND);
|
||||||
@ -629,21 +621,14 @@ void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace)& AWorkspace,
|
|||||||
glEnable(GL_POINT_SMOOTH);
|
glEnable(GL_POINT_SMOOTH);
|
||||||
}
|
}
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
if( antiAliasingMode & 2 ) glEnable(GL_POLYGON_SMOOTH);
|
if( anAntiAliasingMode & 2 ) glEnable(GL_POLYGON_SMOOTH);
|
||||||
#endif
|
#endif
|
||||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable (GL_BLEND);
|
glEnable (GL_BLEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
myZLayers.Render (AWorkspace, theToDrawImmediate);
|
myZLayers.Render (theWorkspace, theToDrawImmediate);
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
|
||||||
if (aCtx->core11 != NULL)
|
|
||||||
{
|
|
||||||
aCtx->core11->glPopAttrib();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user