mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-18 14:27:39 +03:00
0027670: Visualization - avoid duplication of structures defining primitive array presentation aspects
Quantity_ColorRGBA has been introduced as convenient structure holding Vec4 for OpenGL. Graphic3d_PolygonOffset has been added as replacement for TEL_POFFSET_PARAM. Duplicating definition of Hatch Styles TEL_HS_*** has been removed; Aspect_HatchStyle enum now follows values of TEL_HS_*** for compatibility. TelCullMode enum has been removed. Aspect_AspectLine has been merged into Graphic3d_AspectLine3d. Aspect_AspectMarker has been merged into Graphic3d_AspectMarker3d. Aspect_AspectFillArea has been merged into Graphic3d_AspectFillArea3d. Graphic3d_CAspectFillArea have been removed. OpenGl_AspectLine now stores Graphic3d_AspectLine3d as class field. OpenGl_AspectMarker now stores Graphic3d_AspectMarker3d as class field. OpenGl_AspectText now stores Graphic3d_AspectText3d as class field. OpenGl_AspectFace now stores Graphic3d_AspectFillArea3d as class field. Graphic3d_AspectFillArea3d - back face culling is now enabled by default. TKOpenGl now relies on Graphic3d_Group::IsClosed() flag to disable face culling. StdPrs_ShadedShape now does not modify aspect for different culling modes. Headers InterfaceGraphic_Graphic3d.hxx, InterfaceGraphic_telem.hxx, InterfaceGraphic_tgl_all.hxx defining obsolete structures CALL_DEF_COLOR, CALL_DEF_POINT, CALL_DEF_MATERIAL, CALL_DEF_TRANSFORM_PERSISTENCE, TEL_POINT, TEL_COLOUR have been removed. Useless and broken test case bugs/vis/buc60821 has been removed. OpenGl_Workspace::myAspectFaceApplied and myAspectMarkerApplied have been replaced from OpenGl_AspectFace*/OpenGl_AspectMarker* to Handle(Graphic3d_AspectFillArea3d)/Handle(Graphic3d_AspectMarker3d). This eliminates reading from freed memory (e.g. when OpenGl_AspectFace is allocated on stack like in OpenGl_Trihedron). OpenGl_PrimitiveArray::drawEdges() - fix drawing non-indexed array from VBO (access violation due to NULL handle). AIS_Dimension::DrawArrow() - added missing initialization of 3D arrow aspect. AIS_Manipulator::Compute() now creates dedicated Face Aspect for each axis. V3d_CircularGrid, V3d_RectangularGrid now create dedicated line aspects with different color. AIS_InteractiveObject::SetMaterial() - do not modify global ShadingAspect.
This commit is contained in:
@@ -144,6 +144,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
|
||||
myPointSpriteOrig (0),
|
||||
myRenderMode (0),
|
||||
#endif
|
||||
myToCullBackFaces (false),
|
||||
myReadBuffer (0),
|
||||
myDrawBuffer (0),
|
||||
myDefaultVao (0),
|
||||
@@ -339,6 +340,29 @@ void OpenGl_Context::SetDrawBuffer (const Standard_Integer theDrawBuffer)
|
||||
#endif
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCullBackFaces
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Context::SetCullBackFaces (bool theToEnable)
|
||||
{
|
||||
if (myToCullBackFaces == theToEnable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myToCullBackFaces = theToEnable;
|
||||
if (theToEnable)
|
||||
{
|
||||
//glCullFace (GL_BACK); GL_BACK by default
|
||||
core11fwd->glEnable (GL_CULL_FACE);
|
||||
}
|
||||
else
|
||||
{
|
||||
core11fwd->glDisable (GL_CULL_FACE);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FetchState
|
||||
// purpose :
|
||||
@@ -2523,10 +2547,10 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect,
|
||||
{
|
||||
myActiveProgram->SetUniform (this,
|
||||
myActiveProgram->GetStateLocation (OpenGl_OCCT_TEXTURE_ENABLE),
|
||||
theAspect->DoTextureMap());
|
||||
theAspect->Aspect()->ToMapTexture() ? 1 : 0);
|
||||
myActiveProgram->SetUniform (this,
|
||||
myActiveProgram->GetStateLocation (OpenGl_OCCT_DISTINGUISH_MODE),
|
||||
theAspect->DistinguishingMode());
|
||||
theAspect->Aspect()->Distinguish() ? 1 : 0);
|
||||
|
||||
OpenGl_Material aParams;
|
||||
for (Standard_Integer anIndex = 0; anIndex < 2; ++anIndex)
|
||||
@@ -2539,12 +2563,20 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect,
|
||||
continue;
|
||||
}
|
||||
|
||||
const OPENGL_SURF_PROP& aProp = anIndex == 0 || theAspect->DistinguishingMode() != TOn
|
||||
? theAspect->IntFront()
|
||||
: theAspect->IntBack();
|
||||
aParams.Init (aProp);
|
||||
aParams.Diffuse.a() = aProp.trans;
|
||||
|
||||
if (anIndex == 0 || !theAspect->Aspect()->Distinguish())
|
||||
{
|
||||
const Graphic3d_MaterialAspect& aSrcMat = theAspect->Aspect()->FrontMaterial();
|
||||
const Quantity_Color& aSrcIntColor = theAspect->Aspect()->InteriorColor();
|
||||
aParams.Init (aSrcMat, aSrcIntColor);
|
||||
aParams.Diffuse.a() = 1.0f - (float )aSrcMat.Transparency();
|
||||
}
|
||||
else
|
||||
{
|
||||
const Graphic3d_MaterialAspect& aSrcMat = theAspect->Aspect()->BackMaterial();
|
||||
const Quantity_Color& aSrcIntColor = theAspect->Aspect()->BackInteriorColor();
|
||||
aParams.Init (aSrcMat, aSrcIntColor);
|
||||
aParams.Diffuse.a() = 1.0f - (float )aSrcMat.Transparency();
|
||||
}
|
||||
if (theHighlightColor != NULL)
|
||||
{
|
||||
aParams.SetColor (*theHighlightColor);
|
||||
|
Reference in New Issue
Block a user