mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0029076: Visualization - implement element shrinking Shader
Aspect_IS_HOLLOW now an alias to Aspect_IS_EMPTY and Aspect_IS_HIDDENLINE does not implicitly enables mesh edges, so that Graphic3d_AspectFillArea3d::SetDrawEdges() should be set independently. OpenGl_ShaderManager now provides built-in GLSL programs for drawing mesh edges in single pass (and on OpenGL ES which does not provide glPolygonMode()). Graphic3d_RenderingParams::ToEnableAlphaToCoverage is now enabled by default and properly handled at TKOpenGl level - enables coverage for Graphic3d_AlphaMode_Mask primitives. OpenGl_PrimitiveArray now uses GLSL programs instead of glPolygonMode() by default, which can be managed by OpenGl_Caps::usePolygonMode flag (desktop OpenGL only). glPolygonMode() is also used as fallback regardless OpenGl_Caps::usePolygonMode flag when GLSL programs are not supported (Geometry Shaders are required) or stipple line style is required (not implemented within Face GLSL). vaspects command has been extended by -setInterior -setDrawEdges -setEdgeColor -setEdgeType -setEdgeWidth arguments replacing vsetinteriorstyle/vsetedgetype/vunsetedgetype commands. vaspects now accepts arguments without "set" prefix. ViewerTest::ParseColor() now parses RGBA color. Redundant command BUC60738 has been removed. AIS_ColorScale - fixed usage of uninitialized FillArea aspects.
This commit is contained in:
parent
4efe27fc4e
commit
2a33274558
@ -1678,3 +1678,10 @@ Standard_Boolean meshing_new()
|
||||
Some public methods of the class BRepFilletAPI_MakeChamfer are released from excess arguments:
|
||||
- method Add for symmetric chamfer now takes only 2 arguments: distance and edge;
|
||||
- method GetDistAngle now takes only 3 arguments: index of contour, distance and angle.
|
||||
|
||||
@subsection upgrade_740_interiorstyles Interior styles
|
||||
|
||||
* *Aspect_IS_HOLLOW* is now an alias to *Aspect_IS_EMPTY* and does not implicitly enables drawing mesh edges anymore.
|
||||
Specify Graphic3d_AspectFillArea3d::SetDrawEdges(true) with Graphic3d_AspectFillArea3d::SetInteriorStyle(Aspect_IS_EMPTY) to get previous behavior of Aspect_IS_HOLLOW style.
|
||||
* *Aspect_IS_HIDDENLINE* does not implicitly enables drawing mesh edges anymore.
|
||||
Specify Graphic3d_AspectFillArea3d::SetDrawEdges(true) with Graphic3d_AspectFillArea3d::SetInteriorStyle(Aspect_IS_HIDDENLINE) to get previous behavior of Aspect_IS_HIDDENLINE style.
|
||||
|
@ -1793,12 +1793,11 @@ Create facet attributes.
|
||||
Handle(Graphic3d_AspectFillArea3d) aFaceAspect = new Graphic3d_AspectFillArea3d();
|
||||
Graphic3d_MaterialAspect aBrassMaterial (Graphic3d_NOM_BRASS);
|
||||
Graphic3d_MaterialAspect aGoldMaterial (Graphic3d_NOM_GOLD);
|
||||
aFaceAspect->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
aFaceAspect->SetInteriorStyle (Aspect_IS_SOLID_WIREFRAME);
|
||||
aFaceAspect->SetInteriorColor (aMyColor);
|
||||
aFaceAspect->SetDistinguishOn ();
|
||||
aFaceAspect->SetFrontMaterial (aGoldMaterial);
|
||||
aFaceAspect->SetBackMaterial (aBrassMaterial);
|
||||
aFaceAspect->SetEdgeOn();
|
||||
~~~~~
|
||||
|
||||
Create text attributes.
|
||||
|
@ -107,6 +107,10 @@ AIS_ColorScale::AIS_ColorScale()
|
||||
myTextHeight (20)
|
||||
{
|
||||
SetDisplayMode (0);
|
||||
myDrawer->SetupOwnShadingAspect();
|
||||
myDrawer->ShadingAspect()->Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (Quantity_NOC_WHITE);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -458,15 +462,6 @@ void AIS_ColorScale::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
|
||||
const Standard_Integer aBarTop = myYPos + myHeight - aTitleOffset - aBarYOffset;
|
||||
const Standard_Integer aBarHeight = aBarTop - aBarBottom;
|
||||
|
||||
// draw title
|
||||
if (!myTitle.IsEmpty())
|
||||
{
|
||||
drawText (Prs3d_Root::CurrentGroup (thePrs), myTitle,
|
||||
myXPos + mySpacing,
|
||||
aBarTop + aBarYOffset,
|
||||
Graphic3d_VTA_BOTTOM);
|
||||
}
|
||||
|
||||
TColStd_SequenceOfExtendedString aLabels;
|
||||
if (myLabelType == Aspect_TOCSD_USER)
|
||||
{
|
||||
@ -496,11 +491,27 @@ void AIS_ColorScale::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
|
||||
aColorBreadth += aTextWidth;
|
||||
}
|
||||
|
||||
// draw title
|
||||
Handle(Graphic3d_Group) aLabelsGroup;
|
||||
if (!myTitle.IsEmpty()
|
||||
|| !aLabels.IsEmpty())
|
||||
{
|
||||
aLabelsGroup = thePrs->NewGroup();
|
||||
aLabelsGroup->SetGroupPrimitivesAspect (myDrawer->TextAspect()->Aspect());
|
||||
}
|
||||
if (!myTitle.IsEmpty())
|
||||
{
|
||||
drawText (aLabelsGroup, myTitle,
|
||||
myXPos + mySpacing,
|
||||
aBarTop + aBarYOffset,
|
||||
Graphic3d_VTA_BOTTOM);
|
||||
}
|
||||
|
||||
// draw colors
|
||||
drawColorBar (thePrs, aBarBottom, aBarHeight, aTextWidth, aColorBreadth);
|
||||
|
||||
// draw Labels
|
||||
drawLabels (thePrs, aLabels, aBarBottom, aBarHeight, aTextWidth, aColorBreadth);
|
||||
drawLabels (aLabelsGroup, aLabels, aBarBottom, aBarHeight, aTextWidth, aColorBreadth);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -627,7 +638,8 @@ void AIS_ColorScale::drawColorBar (const Handle(Prs3d_Presentation)& thePrs,
|
||||
}
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePrs);
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
|
||||
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (aTriangles);
|
||||
|
||||
const Quantity_Color aFgColor (hasOwnColor ? myDrawer->Color() : Quantity_NOC_WHITE);
|
||||
@ -642,7 +654,7 @@ void AIS_ColorScale::drawColorBar (const Handle(Prs3d_Presentation)& thePrs,
|
||||
//function : drawLabels
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ColorScale::drawLabels (const Handle(Prs3d_Presentation)& thePrs,
|
||||
void AIS_ColorScale::drawLabels (const Handle(Graphic3d_Group)& theGroup,
|
||||
const TColStd_SequenceOfExtendedString& theLabels,
|
||||
const Standard_Integer theBarBottom,
|
||||
const Standard_Integer theBarHeight,
|
||||
@ -716,14 +728,14 @@ void AIS_ColorScale::drawLabels (const Handle(Prs3d_Presentation)& thePrs,
|
||||
Standard_Integer aPos2 = aNbLabels - 1 - i2;
|
||||
if (aFilter && !(aPos1 % aFilter))
|
||||
{
|
||||
drawText (Prs3d_Root::CurrentGroup (thePrs), theLabels.Value (i1 + 1),
|
||||
drawText (theGroup, theLabels.Value (i1 + 1),
|
||||
anXLeft, anYBottom + Standard_Integer(i1 * aStepY + anAscent),
|
||||
Graphic3d_VTA_CENTER);
|
||||
aLast1 = i1;
|
||||
}
|
||||
if (aFilter && !(aPos2 % aFilter))
|
||||
{
|
||||
drawText (Prs3d_Root::CurrentGroup (thePrs), theLabels.Value (i2 + 1),
|
||||
drawText (theGroup, theLabels.Value (i2 + 1),
|
||||
anXLeft, anYBottom + Standard_Integer(i2 * aStepY + anAscent),
|
||||
Graphic3d_VTA_CENTER);
|
||||
aLast2 = i2;
|
||||
@ -746,7 +758,7 @@ void AIS_ColorScale::drawLabels (const Handle(Prs3d_Presentation)& thePrs,
|
||||
|
||||
if (i0 != -1)
|
||||
{
|
||||
drawText (Prs3d_Root::CurrentGroup (thePrs), theLabels.Value (i0 + 1),
|
||||
drawText (theGroup, theLabels.Value (i0 + 1),
|
||||
anXLeft, anYBottom + Standard_Integer(i0 * aStepY + anAscent),
|
||||
Graphic3d_VTA_CENTER);
|
||||
}
|
||||
@ -769,8 +781,8 @@ void AIS_ColorScale::drawFrame (const Handle(Prs3d_Presentation)& thePrs,
|
||||
aPrim->AddVertex (theX, theY, 0.0);
|
||||
|
||||
Handle(Graphic3d_AspectLine3d) anAspect = new Graphic3d_AspectLine3d (theColor, Aspect_TOL_SOLID, 1.0);
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePrs);
|
||||
aGroup->SetPrimitivesAspect (anAspect);
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
|
||||
aGroup->SetGroupPrimitivesAspect (anAspect);
|
||||
aGroup->AddPrimitiveArray (aPrim);
|
||||
}
|
||||
|
||||
@ -784,7 +796,6 @@ void AIS_ColorScale::drawText (const Handle(Graphic3d_Group)& theGroup,
|
||||
const Graphic3d_VerticalTextAlignment theVertAlignment)
|
||||
{
|
||||
const Handle(Prs3d_TextAspect)& anAspect = myDrawer->TextAspect();
|
||||
theGroup->SetPrimitivesAspect (anAspect->Aspect());
|
||||
theGroup->Text (theText,
|
||||
gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()),
|
||||
anAspect->Height(),
|
||||
|
@ -406,7 +406,7 @@ private:
|
||||
Standard_Integer computeMaxLabelWidth (const TColStd_SequenceOfExtendedString& theLabels) const;
|
||||
|
||||
//! Draw labels.
|
||||
void drawLabels (const Handle(Prs3d_Presentation)& thePrs,
|
||||
void drawLabels (const Handle(Graphic3d_Group)& theGroup,
|
||||
const TColStd_SequenceOfExtendedString& theLabels,
|
||||
const Standard_Integer theBarBottom,
|
||||
const Standard_Integer theBarHeight,
|
||||
|
@ -350,77 +350,12 @@ bool AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Quantity_Color& theColor) const
|
||||
{
|
||||
bool toRecompute = false;
|
||||
if (!theDrawer->HasOwnShadingAspect())
|
||||
toRecompute = theDrawer->SetupOwnShadingAspect() || toRecompute;
|
||||
toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
|
||||
|
||||
if (theDrawer->SetupOwnPointAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnLineAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnWireAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnPointAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_BLACK, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnFreeBoundaryAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnUnFreeBoundaryAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnSeenLineAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnFaceBoundaryAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetFaceBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->FaceBoundaryAspect()->Aspect() = *theDrawer->Link()->FaceBoundaryAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
|
||||
// override color
|
||||
@ -614,61 +549,7 @@ void AIS_Shape::UnsetColor()
|
||||
bool AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Real theLineWidth) const
|
||||
{
|
||||
bool toRecompute = false;
|
||||
if (!theDrawer->HasOwnLineAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnWireAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnFreeBoundaryAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnUnFreeBoundaryAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnSeenLineAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnFaceBoundaryAspect())
|
||||
{
|
||||
toRecompute = true;
|
||||
theDrawer->SetFaceBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->FaceBoundaryAspect()->Aspect() = *theDrawer->Link()->FaceBoundaryAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
bool toRecompute = theDrawer->SetOwnLineAspects();
|
||||
|
||||
// override width
|
||||
theDrawer->LineAspect()->SetWidth (theLineWidth);
|
||||
@ -758,14 +639,7 @@ void AIS_Shape::setMaterial (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
{
|
||||
const Quantity_Color aColor = theDrawer->ShadingAspect()->Material (myCurrentFacingModel).Color();
|
||||
const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
|
||||
if (!theDrawer->HasOwnShadingAspect())
|
||||
{
|
||||
theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
theDrawer->SetupOwnShadingAspect();
|
||||
theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
|
||||
|
||||
if (theToKeepColor)
|
||||
@ -889,15 +763,7 @@ void AIS_Shape::UnsetMaterial()
|
||||
void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Real theValue) const
|
||||
{
|
||||
if (!theDrawer->HasOwnShadingAspect())
|
||||
{
|
||||
theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
|
||||
theDrawer->SetupOwnShadingAspect();
|
||||
// override transparency
|
||||
theDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@
|
||||
//! To generate texture coordinates, appropriate shading attribute should be set before computing presentation in AIS_Shaded display mode:
|
||||
//! @code
|
||||
//! Handle(AIS_Shape) aPrs = new AIS_Shape();
|
||||
//! aPrs->Attributes()->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
//! aPrs->Attributes()->SetupOwnShadingAspect();
|
||||
//! aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn();
|
||||
//! aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMap (new Graphic3d_Texture2Dmanual (Graphic3d_NOT_2D_ALUMINUM));
|
||||
//! @endcode
|
||||
|
@ -16,23 +16,17 @@
|
||||
#ifndef _Aspect_InteriorStyle_HeaderFile
|
||||
#define _Aspect_InteriorStyle_HeaderFile
|
||||
|
||||
//! Definition of interior types for primitive
|
||||
//! faces.
|
||||
//!
|
||||
//! IS_EMPTY no interior.
|
||||
//! IS_HOLLOW display the boundaries of the surface.
|
||||
//! IS_HATCH display hatched with a hatch style.
|
||||
//! IS_SOLID display the interior entirely filled.
|
||||
//! IS_HIDDENLINE display in hidden lines removed.
|
||||
//! IS_POINT display only vertices.
|
||||
//! Interior types for primitive faces.
|
||||
enum Aspect_InteriorStyle
|
||||
{
|
||||
Aspect_IS_EMPTY,
|
||||
Aspect_IS_HOLLOW,
|
||||
Aspect_IS_HATCH,
|
||||
Aspect_IS_SOLID,
|
||||
Aspect_IS_HIDDENLINE,
|
||||
Aspect_IS_POINT
|
||||
Aspect_IS_EMPTY = -1, //!< no interior
|
||||
Aspect_IS_SOLID = 0, //!< normally filled surface interior
|
||||
Aspect_IS_HATCH, //!< hatched surface interior
|
||||
Aspect_IS_HIDDENLINE, //!< interior is filled with viewer background color
|
||||
Aspect_IS_POINT, //!< display only vertices of surface (obsolete)
|
||||
|
||||
// obsolete aliases
|
||||
Aspect_IS_HOLLOW = Aspect_IS_EMPTY, //!< transparent surface interior
|
||||
};
|
||||
|
||||
#endif // _Aspect_InteriorStyle_HeaderFile
|
||||
|
@ -32,6 +32,7 @@ Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d()
|
||||
myEdgeType (Aspect_TOL_SOLID),
|
||||
myEdgeWidth (1.0f),
|
||||
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
|
||||
myToSkipFirstEdge (false),
|
||||
myToDistinguishMaterials (false),
|
||||
myToDrawEdges (false),
|
||||
myToSuppressBackFaces (true),
|
||||
@ -63,6 +64,7 @@ Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (const Aspect_InteriorSty
|
||||
myEdgeType (theEdgeLineType),
|
||||
myEdgeWidth ((float )theEdgeLineWidth),
|
||||
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
|
||||
myToSkipFirstEdge (false),
|
||||
myToDistinguishMaterials (false),
|
||||
myToDrawEdges (false),
|
||||
myToSuppressBackFaces (true),
|
||||
|
@ -255,19 +255,26 @@ public:
|
||||
public:
|
||||
|
||||
//! Returns true if edges should be drawn (false by default).
|
||||
bool ToDrawEdges() const { return myToDrawEdges; }
|
||||
bool ToDrawEdges() const { return myToDrawEdges && myEdgeType != Aspect_TOL_EMPTY; }
|
||||
|
||||
//! Set if edges should be drawn or not.
|
||||
void SetDrawEdges (bool theToDraw) { myToDrawEdges = theToDraw; }
|
||||
void SetDrawEdges (bool theToDraw)
|
||||
{
|
||||
myToDrawEdges = theToDraw;
|
||||
if (myEdgeType == Aspect_TOL_EMPTY)
|
||||
{
|
||||
myEdgeType = Aspect_TOL_SOLID;
|
||||
}
|
||||
}
|
||||
|
||||
//! Returns true if edges should be drawn.
|
||||
bool Edge() const { return myToDrawEdges; }
|
||||
bool Edge() const { return ToDrawEdges(); }
|
||||
|
||||
//! The edges of FillAreas are drawn.
|
||||
void SetEdgeOn() { myToDrawEdges = true; }
|
||||
void SetEdgeOn() { SetDrawEdges (true); }
|
||||
|
||||
//! The edges of FillAreas are not drawn.
|
||||
void SetEdgeOff() { myToDrawEdges = false; }
|
||||
void SetEdgeOff() { SetDrawEdges (false); }
|
||||
|
||||
//! Return color of edges.
|
||||
const Quantity_Color& EdgeColor() const { return myEdgeColor.GetRGB(); }
|
||||
@ -278,6 +285,9 @@ public:
|
||||
//! Modifies the color of the edge of the face
|
||||
void SetEdgeColor (const Quantity_Color& theColor) { myEdgeColor.SetRGB (theColor); }
|
||||
|
||||
//! Modifies the color of the edge of the face
|
||||
void SetEdgeColor (const Quantity_ColorRGBA& theColor) { myEdgeColor = theColor; }
|
||||
|
||||
//! Return edges line type.
|
||||
Aspect_TypeOfLine EdgeLineType() const { return myEdgeType; }
|
||||
|
||||
@ -298,6 +308,18 @@ public:
|
||||
myEdgeWidth = (float )theWidth;
|
||||
}
|
||||
|
||||
//! Returns TRUE if drawing element edges should discard first edge in triangle; FALSE by default.
|
||||
//! Graphics hardware works mostly with triangles, so that wireframe presentation will draw triangle edges by default.
|
||||
//! This flag allows rendering wireframe presentation of quad-only array split into triangles.
|
||||
//! For this, quads should be split in specific order, so that the quad diagonal (to be NOT rendered) goes first:
|
||||
//! 1------2
|
||||
//! / / Triangle #1: 2-0-1; Triangle #2: 0-2-3
|
||||
//! 0------3
|
||||
bool ToSkipFirstEdge() const { return myToSkipFirstEdge; }
|
||||
|
||||
//! Set skip first triangle edge flag for drawing wireframe presentation of quads array split into triangles.
|
||||
void SetSkipFirstEdge (bool theToSkipFirstEdge) { myToSkipFirstEdge = theToSkipFirstEdge; }
|
||||
|
||||
public:
|
||||
|
||||
//! Returns the hatch type used when InteriorStyle is IS_HATCH
|
||||
@ -370,6 +392,7 @@ protected:
|
||||
Handle(Graphic3d_HatchStyle) myHatchStyle;
|
||||
|
||||
Graphic3d_PolygonOffset myPolygonOffset;
|
||||
bool myToSkipFirstEdge;
|
||||
bool myToDistinguishMaterials;
|
||||
bool myToDrawEdges;
|
||||
bool myToSuppressBackFaces;
|
||||
|
@ -94,11 +94,12 @@ public:
|
||||
Graphic3d_RenderingParams()
|
||||
: Method (Graphic3d_RM_RASTERIZATION),
|
||||
TransparencyMethod (Graphic3d_RTM_BLEND_UNORDERED),
|
||||
LineFeather (1.0f),
|
||||
OitDepthFactor (0.0f),
|
||||
NbMsaaSamples (0),
|
||||
RenderResolutionScale (1.0f),
|
||||
ToEnableDepthPrepass (Standard_False),
|
||||
ToEnableAlphaToCoverage (Standard_False),
|
||||
ToEnableAlphaToCoverage (Standard_True),
|
||||
// ray tracing parameters
|
||||
IsGlobalIlluminationEnabled (Standard_False),
|
||||
RaytracingDepth (THE_DEFAULT_DEPTH),
|
||||
@ -168,12 +169,14 @@ public:
|
||||
|
||||
Graphic3d_RenderingMode Method; //!< specifies rendering mode, Graphic3d_RM_RASTERIZATION by default
|
||||
Graphic3d_RenderTransparentMethod TransparencyMethod; //!< specifies rendering method for transparent graphics
|
||||
Standard_ShortReal LineFeather; //!< line feater width in pixels (> 0.0), 1.0 by default;
|
||||
//! high values produce blurred results, small values produce sharp (aliased) edges
|
||||
Standard_ShortReal OitDepthFactor; //!< scalar factor [0-1] controlling influence of depth of a fragment to its final coverage
|
||||
Standard_Integer NbMsaaSamples; //!< number of MSAA samples (should be within 0..GL_MAX_SAMPLES, power-of-two number), 0 by default
|
||||
Standard_ShortReal RenderResolutionScale; //!< rendering resolution scale factor, 1 by default;
|
||||
//! incompatible with MSAA (e.g. NbMsaaSamples should be set to 0)
|
||||
Standard_Boolean ToEnableDepthPrepass; //!< enables/disables depth pre-pass, False by default
|
||||
Standard_Boolean ToEnableAlphaToCoverage; //!< enables/disables alpha to coverage, False by default
|
||||
Standard_Boolean ToEnableAlphaToCoverage; //!< enables/disables alpha to coverage, True by default
|
||||
|
||||
Standard_Boolean IsGlobalIlluminationEnabled; //!< enables/disables global illumination effects (path tracing)
|
||||
Standard_Integer SamplesPerPixel; //!< number of samples per pixel (SPP)
|
||||
|
@ -32,6 +32,7 @@ enum Graphic3d_TypeOfLimit
|
||||
Graphic3d_TypeOfLimit_HasBlendedOit, //!< indicates whether necessary GL extensions for Weighted, Blended OIT available (without MSAA).
|
||||
Graphic3d_TypeOfLimit_HasBlendedOitMsaa, //!< indicates whether necessary GL extensions for Weighted, Blended OIT available (with MSAA).
|
||||
Graphic3d_TypeOfLimit_HasFlatShading, //!< indicates whether Flat shading (Graphic3d_TOSM_FACET) is supported
|
||||
Graphic3d_TypeOfLimit_HasMeshEdges, //!< indicates whether advanced mesh edges presentation is supported
|
||||
Graphic3d_TypeOfLimit_IsWorkaroundFBO, //!< indicates whether workaround for Intel driver problem with empty FBO for images with big width is applyed.
|
||||
Graphic3d_TypeOfLimit_NB //!< number of elements in this enumeration
|
||||
};
|
||||
|
@ -28,11 +28,11 @@ OpenGl_Caps::OpenGl_Caps()
|
||||
: vboDisable (Standard_False),
|
||||
pntSpritesDisable (Standard_False),
|
||||
keepArrayData (Standard_False),
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
ffpEnable (Standard_False),
|
||||
usePolygonMode (Standard_False),
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
useSystemBuffer (Standard_False),
|
||||
#else
|
||||
ffpEnable (Standard_False),
|
||||
useSystemBuffer (Standard_True),
|
||||
#endif
|
||||
swapInterval (1),
|
||||
|
@ -30,7 +30,8 @@ public: //! @name flags to disable particular functionality, should be used only
|
||||
Standard_Boolean vboDisable; //!< flag permits VBO usage, will significantly affect performance (OFF by default)
|
||||
Standard_Boolean pntSpritesDisable; //!< flag permits Point Sprites usage, will significantly affect performance (OFF by default)
|
||||
Standard_Boolean keepArrayData; //!< Disables freeing CPU memory after building VBOs (OFF by default)
|
||||
Standard_Boolean ffpEnable; //!< Enables FFP (fixed-function pipeline), do not use built-in GLSL programs (ON by default on desktop OpenGL and OFF on OpenGL ES)
|
||||
Standard_Boolean ffpEnable; //!< Enables FFP (fixed-function pipeline), do not use built-in GLSL programs (OFF by default)
|
||||
Standard_Boolean usePolygonMode; //!< Enables Polygon Mode instead of built-in GLSL programs (OFF by default; unsupported on OpenGL ES)
|
||||
Standard_Boolean useSystemBuffer; //!< Enables usage of system backbuffer for blitting (OFF by default on desktop OpenGL and ON on OpenGL ES for testing)
|
||||
Standard_Integer swapInterval; //!< controls swap interval - 0 for VSync off and 1 for VSync on, 1 by default
|
||||
|
||||
|
@ -125,6 +125,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
|
||||
hasFloatBuffer (OpenGl_FeatureNotAvailable),
|
||||
hasHalfFloatBuffer (OpenGl_FeatureNotAvailable),
|
||||
hasSampleVariables (OpenGl_FeatureNotAvailable),
|
||||
hasGeometryStage (OpenGl_FeatureNotAvailable),
|
||||
arbDrawBuffers (Standard_False),
|
||||
arbNPTW (Standard_False),
|
||||
arbTexRG (Standard_False),
|
||||
@ -193,6 +194,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
|
||||
myResolution (Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION),
|
||||
myResolutionRatio (1.0f),
|
||||
myLineWidthScale (1.0f),
|
||||
myLineFeather (1.0f),
|
||||
myRenderScale (1.0f),
|
||||
myRenderScaleInv (1.0f)
|
||||
{
|
||||
@ -1422,6 +1424,12 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|
||||
// dFdx/dFdy are completely broken on tested Adreno devices with versions below OpenGl ES 3.1
|
||||
hasFlatShading = OpenGl_FeatureNotAvailable;
|
||||
}
|
||||
|
||||
hasGeometryStage = IsGlGreaterEqual (3, 2)
|
||||
? OpenGl_FeatureInCore
|
||||
: (CheckExtension ("GL_EXT_geometry_shader") && CheckExtension ("GL_EXT_shader_io_blocks")
|
||||
? OpenGl_FeatureInExtensions
|
||||
: OpenGl_FeatureNotAvailable);
|
||||
#else
|
||||
|
||||
myTexClamp = IsGlGreaterEqual (1, 2) ? GL_CLAMP_TO_EDGE : GL_CLAMP;
|
||||
@ -1446,6 +1454,10 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|
||||
CheckExtension ("GL_ARB_color_buffer_float") ? OpenGl_FeatureInExtensions
|
||||
: OpenGl_FeatureNotAvailable;
|
||||
|
||||
hasGeometryStage = IsGlGreaterEqual (3, 2)
|
||||
? OpenGl_FeatureInCore
|
||||
: OpenGl_FeatureNotAvailable;
|
||||
|
||||
hasSampleVariables = IsGlGreaterEqual (4, 0) ? OpenGl_FeatureInCore :
|
||||
arbSampleShading ? OpenGl_FeatureInExtensions
|
||||
: OpenGl_FeatureNotAvailable;
|
||||
@ -3213,9 +3225,18 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect,
|
||||
// do not update material properties in case of zero reflection mode,
|
||||
// because GL lighting will be disabled by OpenGl_PrimitiveArray::DrawArray() anyway.
|
||||
const OpenGl_MaterialState& aMatState = myShaderManager->MaterialState();
|
||||
const float anAlphaCutoff = anAspect->AlphaMode() == Graphic3d_AlphaMode_Mask
|
||||
? anAspect->AlphaCutoff()
|
||||
: ShortRealLast();
|
||||
float anAlphaCutoff = anAspect->AlphaMode() == Graphic3d_AlphaMode_Mask
|
||||
? anAspect->AlphaCutoff()
|
||||
: ShortRealLast();
|
||||
if (anAspect->ToDrawEdges())
|
||||
{
|
||||
if (anAspect->InteriorStyle() == Aspect_IS_EMPTY
|
||||
|| (anAspect->InteriorStyle() == Aspect_IS_SOLID
|
||||
&& anAspect->EdgeColorRGBA().Alpha() < 1.0f))
|
||||
{
|
||||
anAlphaCutoff = 0.285f;
|
||||
}
|
||||
}
|
||||
if (theAspect->ShadingModel() == Graphic3d_TOSM_UNLIT)
|
||||
{
|
||||
if (anAlphaCutoff == aMatState.AlphaCutoff())
|
||||
@ -3772,14 +3793,15 @@ bool OpenGl_Context::SetColorMask (bool theToWriteColor)
|
||||
// =======================================================================
|
||||
bool OpenGl_Context::SetSampleAlphaToCoverage (bool theToEnable)
|
||||
{
|
||||
if (myAlphaToCoverage == theToEnable)
|
||||
bool toEnable = myAllowAlphaToCov && theToEnable;
|
||||
if (myAlphaToCoverage == toEnable)
|
||||
{
|
||||
return myAlphaToCoverage;
|
||||
}
|
||||
|
||||
if (core15fwd != NULL)
|
||||
{
|
||||
if (theToEnable)
|
||||
if (toEnable)
|
||||
{
|
||||
//core15fwd->core15fwd->glSampleCoverage (1.0f, GL_FALSE);
|
||||
core15fwd->glEnable (GL_SAMPLE_ALPHA_TO_COVERAGE);
|
||||
@ -3791,6 +3813,6 @@ bool OpenGl_Context::SetSampleAlphaToCoverage (bool theToEnable)
|
||||
}
|
||||
|
||||
const bool anOldValue = myAlphaToCoverage;
|
||||
myAlphaToCoverage = theToEnable;
|
||||
myAlphaToCoverage = toEnable;
|
||||
return anOldValue;
|
||||
}
|
||||
|
@ -662,6 +662,12 @@ public: //! @name methods to alter or retrieve current state
|
||||
//! Enable/disable writing into color buffer (wrapper for glColorMask).
|
||||
Standard_EXPORT bool SetColorMask (bool theToWriteColor);
|
||||
|
||||
//! Return TRUE if GL_SAMPLE_ALPHA_TO_COVERAGE usage is allowed.
|
||||
bool AllowSampleAlphaToCoverage() const { return myAllowAlphaToCov; }
|
||||
|
||||
//! Allow GL_SAMPLE_ALPHA_TO_COVERAGE usage.
|
||||
void SetAllowSampleAlphaToCoverage (bool theToEnable) { myAllowAlphaToCov = theToEnable; }
|
||||
|
||||
//! Return GL_SAMPLE_ALPHA_TO_COVERAGE state.
|
||||
bool SampleAlphaToCoverage() const { return myAlphaToCoverage; }
|
||||
|
||||
@ -777,6 +783,9 @@ public: //! @name methods to alter or retrieve current state
|
||||
//! Rendering scale factor (inverted value).
|
||||
Standard_ShortReal RenderScaleInv() const { return myRenderScaleInv; }
|
||||
|
||||
//! Return scale factor for line width.
|
||||
Standard_ShortReal LineWidthScale() const { return myLineWidthScale; }
|
||||
|
||||
//! Set resolution ratio.
|
||||
//! Note that this method rounds @theRatio to nearest integer.
|
||||
void SetResolution (unsigned int theResolution,
|
||||
@ -797,6 +806,12 @@ public: //! @name methods to alter or retrieve current state
|
||||
myLineWidthScale = Max (1.0f, std::floor (theRatio + 0.5f));
|
||||
}
|
||||
|
||||
//! Return line feater width in pixels.
|
||||
Standard_ShortReal LineFeather() const { return myLineFeather; }
|
||||
|
||||
//! Set line feater width.
|
||||
void SetLineFeather(Standard_ShortReal theValue) { myLineFeather = theValue; }
|
||||
|
||||
//! Return Graphics Driver's vendor.
|
||||
const TCollection_AsciiString& Vendor() const { return myVendor; }
|
||||
|
||||
@ -848,6 +863,7 @@ public: //! @name extensions
|
||||
OpenGl_FeatureFlag hasFloatBuffer; //!< Complex flag indicating support of float color buffer format (desktop OpenGL 3.0, GL_ARB_color_buffer_float, GL_EXT_color_buffer_float)
|
||||
OpenGl_FeatureFlag hasHalfFloatBuffer; //!< Complex flag indicating support of half-float color buffer format (desktop OpenGL 3.0, GL_ARB_color_buffer_float, GL_EXT_color_buffer_half_float)
|
||||
OpenGl_FeatureFlag hasSampleVariables; //!< Complex flag indicating support of MSAA variables in GLSL shader (desktop OpenGL 4.0, GL_ARB_sample_shading)
|
||||
OpenGl_FeatureFlag hasGeometryStage; //!< Complex flag indicating support of Geometry shader (desktop OpenGL 3.2, OpenGL ES 3.2, GL_EXT_geometry_shader)
|
||||
Standard_Boolean arbDrawBuffers; //!< GL_ARB_draw_buffers
|
||||
Standard_Boolean arbNPTW; //!< GL_ARB_texture_non_power_of_two
|
||||
Standard_Boolean arbTexRG; //!< GL_ARB_texture_rg
|
||||
@ -958,6 +974,7 @@ private: //! @name fields tracking current state
|
||||
myDrawBuffers; //!< current draw buffers
|
||||
unsigned int myDefaultVao; //!< default Vertex Array Object
|
||||
Standard_Boolean myColorMask; //!< flag indicating writing into color buffer is enabled or disabled (glColorMask)
|
||||
Standard_Boolean myAllowAlphaToCov; //!< flag allowing GL_SAMPLE_ALPHA_TO_COVERAGE usage
|
||||
Standard_Boolean myAlphaToCoverage; //!< flag indicating GL_SAMPLE_ALPHA_TO_COVERAGE state
|
||||
Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state
|
||||
TCollection_AsciiString myVendor; //!< Graphics Driver's vendor
|
||||
@ -966,6 +983,7 @@ private: //! @name fields tracking current state
|
||||
Standard_ShortReal myResolutionRatio; //!< scaling factor for parameters like text size
|
||||
//! to be properly displayed on device (screen / printer)
|
||||
Standard_ShortReal myLineWidthScale; //!< scaling factor for line width
|
||||
Standard_ShortReal myLineFeather; //!< line feater width in pixels
|
||||
Standard_ShortReal myRenderScale; //!< scaling factor for rendering resolution
|
||||
Standard_ShortReal myRenderScaleInv; //!< scaling factor for rendering resolution (inverted value)
|
||||
OpenGl_Material myMatFront; //!< current front material state (cached to reduce GL context updates)
|
||||
|
@ -465,6 +465,8 @@ Standard_Integer OpenGl_GraphicDriver::InquireLimit (const Graphic3d_TypeOfLimit
|
||||
return !aCtx.IsNull() && aCtx->hasFlatShading != OpenGl_FeatureNotAvailable ? 1 : 0;
|
||||
case Graphic3d_TypeOfLimit_IsWorkaroundFBO:
|
||||
return !aCtx.IsNull() && aCtx->MaxTextureSize() != aCtx->MaxDumpSizeX() ? 1 : 0;
|
||||
case Graphic3d_TypeOfLimit_HasMeshEdges:
|
||||
return !aCtx.IsNull() && aCtx->hasGeometryStage != OpenGl_FeatureNotAvailable ? 1 : 0;
|
||||
case Graphic3d_TypeOfLimit_NB:
|
||||
return 0;
|
||||
}
|
||||
|
@ -109,7 +109,11 @@ int OpenGl_LineAttributes::SetTypeOfHatch (const OpenGl_Context* t
|
||||
}
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (theStyle->HatchType() != 0)
|
||||
if (theGlCtx->core11 == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (theStyle->HatchType() != 0)
|
||||
{
|
||||
theGlCtx->core11->glCallList ((GLuint)aGpuListId);
|
||||
|
||||
@ -146,7 +150,11 @@ bool OpenGl_LineAttributes::SetEnabled (const OpenGl_Context* theGlCtx,
|
||||
const bool anOldIsEnabled = myIsEnabled;
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (theToEnable)
|
||||
if (theGlCtx->core11 == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (theToEnable)
|
||||
{
|
||||
if (myTypeOfHatch != 0)
|
||||
{
|
||||
|
@ -50,6 +50,9 @@ public:
|
||||
//! Alpha cutoff value.
|
||||
float AlphaCutoff() const { return myAlphaCutoff; }
|
||||
|
||||
//! Return TRUE if alpha test should be enabled.
|
||||
bool HasAlphaCutoff() const { return myAlphaCutoff <= 1.0f; }
|
||||
|
||||
//! Distinguish front/back flag.
|
||||
bool ToDistinguish() const { return myToDistinguish; }
|
||||
|
||||
|
@ -504,9 +504,8 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeCo
|
||||
|
||||
const OpenGl_AspectLine* anAspectLineOld = theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge());
|
||||
const OpenGl_AspectLine* anAspect = theWorkspace->ApplyAspectLine();
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
|
||||
const Standard_Integer aPolyModeOld = aGlContext->SetPolygonMode (GL_LINE);
|
||||
#endif
|
||||
|
||||
if (aGlContext->core20fwd != NULL)
|
||||
@ -580,6 +579,9 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeCo
|
||||
|
||||
// restore line context
|
||||
theWorkspace->SetAspectLine (anAspectLineOld);
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
aGlContext->SetPolygonMode (aPolyModeOld);
|
||||
#endif
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -801,9 +803,34 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
// Temporarily disable environment mapping
|
||||
Handle(OpenGl_TextureSet) aTextureBack;
|
||||
bool toDrawArray = true;
|
||||
int toDrawInteriorEdges = 0; // 0 - no edges, 1 - glsl edges, 2 - polygonMode
|
||||
if (myDrawMode > GL_LINE_STRIP)
|
||||
{
|
||||
toDrawArray = anAspectFace->Aspect()->InteriorStyle() != Aspect_IS_EMPTY;
|
||||
if (anAspectFace->Aspect()->ToDrawEdges())
|
||||
{
|
||||
toDrawInteriorEdges = 1;
|
||||
toDrawArray = true;
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (anAspectFace->Aspect()->EdgeLineType() != Aspect_TOL_SOLID
|
||||
|| aCtx->hasGeometryStage == OpenGl_FeatureNotAvailable
|
||||
|| aCtx->caps->usePolygonMode)
|
||||
{
|
||||
toDrawInteriorEdges = 2;
|
||||
if (anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_EMPTY)
|
||||
{
|
||||
if (anAspectFace->Aspect()->EdgeLineType() != Aspect_TOL_SOLID)
|
||||
{
|
||||
toDrawArray = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
aCtx->SetPolygonMode (GL_LINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (myDrawMode <= GL_LINE_STRIP)
|
||||
{
|
||||
@ -867,10 +894,16 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
const Standard_Boolean toEnableEnvMap = (!aTextures.IsNull() && (aTextures == theWorkspace->EnvironmentTexture()));
|
||||
aCtx->ShaderManager()->BindFaceProgram (aTextures,
|
||||
aShadingModel,
|
||||
anAspectFace->Aspect()->AlphaMode(),
|
||||
aCtx->ShaderManager()->MaterialState().HasAlphaCutoff() ? Graphic3d_AlphaMode_Mask : Graphic3d_AlphaMode_Opaque,
|
||||
toDrawInteriorEdges == 1 ? anAspectFace->Aspect()->InteriorStyle() : Aspect_IS_SOLID,
|
||||
hasVertColor,
|
||||
toEnableEnvMap,
|
||||
toDrawInteriorEdges == 1,
|
||||
anAspectFace->ShaderProgramRes (aCtx));
|
||||
if (toDrawInteriorEdges == 1)
|
||||
{
|
||||
aCtx->ShaderManager()->PushInteriorState (aCtx->ActiveProgram(), anAspectFace->Aspect());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -926,24 +959,21 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
{
|
||||
aCtx->BindTextures (aTextureBack);
|
||||
}
|
||||
else
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
else if (toDrawInteriorEdges == 2)
|
||||
{
|
||||
if (anAspectFace->Aspect()->ToDrawEdges()
|
||||
|| anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_HIDDENLINE)
|
||||
if (anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_HOLLOW
|
||||
&& anAspectFace->Aspect()->EdgeLineType() == Aspect_TOL_SOLID)
|
||||
{
|
||||
aCtx->SetPolygonMode (GL_FILL);
|
||||
}
|
||||
else
|
||||
{
|
||||
const OpenGl_Vec4& anEdgeColor = theWorkspace->EdgeColor();
|
||||
drawEdges (anEdgeColor, theWorkspace);
|
||||
|
||||
// restore OpenGL polygon mode if needed
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (anAspectFace->Aspect()->InteriorStyle() >= Aspect_IS_HATCH)
|
||||
{
|
||||
glPolygonMode (GL_FRONT_AND_BACK,
|
||||
anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_POINT ? GL_POINT : GL_FILL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@ -23,20 +23,22 @@
|
||||
//! Standard GLSL program combination bits.
|
||||
enum OpenGl_ProgramOptions
|
||||
{
|
||||
OpenGl_PO_Point = 0x001, //!< point marker
|
||||
OpenGl_PO_VertColor = 0x002, //!< per-vertex color
|
||||
OpenGl_PO_TextureRGB = 0x004, //!< handle RGB texturing
|
||||
OpenGl_PO_TextureA = 0x008, //!< handle Alpha texturing
|
||||
OpenGl_PO_TextureEnv = 0x010, //!< handle environment map
|
||||
OpenGl_PO_StippleLine = 0x020, //!< stipple line
|
||||
OpenGl_PO_ClipPlanes1 = 0x040, //!< handle 1 clipping plane
|
||||
OpenGl_PO_ClipPlanes2 = 0x080, //!< handle 2 clipping planes
|
||||
//OpenGl_PO_ClipPlanes3 = OpenGl_PO_ClipPlanes1|OpenGl_PO_ClipPlanes2, //!< handle 3 clipping planes - not implemented
|
||||
OpenGl_PO_ClipPlanesN = 0x100, //!< handle N clipping planes
|
||||
OpenGl_PO_ClipChains = 0x200, //!< handle chains of clipping planes
|
||||
OpenGl_PO_AlphaTest = 0x400, //!< discard fragment by alpha test (defined by cutoff value)
|
||||
OpenGl_PO_WriteOit = 0x800, //!< write coverage buffer for Blended Order-Independent Transparency
|
||||
OpenGl_PO_NB = 0x1000 //!< overall number of combinations
|
||||
OpenGl_PO_Point = 0x0001, //!< point marker
|
||||
OpenGl_PO_VertColor = 0x0002, //!< per-vertex color
|
||||
OpenGl_PO_TextureRGB = 0x0004, //!< handle RGB texturing
|
||||
OpenGl_PO_TextureA = 0x0008, //!< handle Alpha texturing
|
||||
OpenGl_PO_TextureEnv = 0x0010, //!< handle environment map
|
||||
OpenGl_PO_StippleLine = 0x0020, //!< stipple line
|
||||
OpenGl_PO_ClipPlanes1 = 0x0040, //!< handle 1 clipping plane
|
||||
OpenGl_PO_ClipPlanes2 = 0x0080, //!< handle 2 clipping planes
|
||||
OpenGl_PO_ClipPlanesN = OpenGl_PO_ClipPlanes1|OpenGl_PO_ClipPlanes2, //!< handle N clipping planes
|
||||
OpenGl_PO_ClipChains = 0x0100, //!< handle chains of clipping planes
|
||||
OpenGl_PO_MeshEdges = 0x0200, //!< draw mesh edges (wireframe)
|
||||
OpenGl_PO_AlphaTest = 0x0400, //!< discard fragment by alpha test (defined by cutoff value)
|
||||
OpenGl_PO_WriteOit = 0x0800, //!< write coverage buffer for Blended Order-Independent Transparency
|
||||
//
|
||||
OpenGl_PO_NB = 0x1000, //!< overall number of combinations
|
||||
OpenGl_PO_NeedsGeomShader = OpenGl_PO_MeshEdges,
|
||||
};
|
||||
|
||||
//! Alias to programs array of predefined length
|
||||
|
@ -281,6 +281,19 @@ EOL" {"
|
||||
EOL" discard;"
|
||||
EOL" }";
|
||||
|
||||
//! Modify color for Wireframe presentation.
|
||||
const char THE_FRAG_WIREFRAME_COLOR[] =
|
||||
EOL"vec4 getFinalColor(void)"
|
||||
EOL"{"
|
||||
EOL" float aDistance = min (min (EdgeDistance[0], EdgeDistance[1]), EdgeDistance[2]);"
|
||||
EOL" bool isHollow = occWireframeColor.a < 0.0;"
|
||||
EOL" float aMixVal = smoothstep (occLineWidth - occLineFeather * 0.5, occLineWidth + occLineFeather * 0.5, aDistance);"
|
||||
EOL" vec4 aMixColor = isHollow"
|
||||
EOL" ? vec4 (getColor().rgb, 1.0 - aMixVal)" // edges only (of interior color)
|
||||
EOL" : mix (occWireframeColor, getColor(), aMixVal);" // interior + edges
|
||||
EOL" return aMixColor;"
|
||||
EOL"}";
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
|
||||
static const GLfloat THE_DEFAULT_AMBIENT[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
@ -1130,6 +1143,7 @@ void OpenGl_ShaderManager::PushMaterialState (const Handle(OpenGl_ShaderProgram)
|
||||
return;
|
||||
}
|
||||
|
||||
myContext->SetSampleAlphaToCoverage (false);
|
||||
if (myMaterialState.AlphaCutoff() < ShortRealLast())
|
||||
{
|
||||
glAlphaFunc (GL_GEQUAL, myMaterialState.AlphaCutoff());
|
||||
@ -1158,6 +1172,7 @@ void OpenGl_ShaderManager::PushMaterialState (const Handle(OpenGl_ShaderProgram)
|
||||
return;
|
||||
}
|
||||
|
||||
myContext->SetSampleAlphaToCoverage (myMaterialState.HasAlphaCutoff());
|
||||
theProgram->SetUniform (myContext,
|
||||
theProgram->GetStateLocation (OpenGl_OCCT_ALPHA_CUTOFF),
|
||||
myMaterialState.AlphaCutoff());
|
||||
@ -1168,15 +1183,12 @@ void OpenGl_ShaderManager::PushMaterialState (const Handle(OpenGl_ShaderProgram)
|
||||
theProgram->GetStateLocation (OpenGl_OCCT_DISTINGUISH_MODE),
|
||||
myMaterialState.ToDistinguish() ? 1 : 0);
|
||||
|
||||
const GLint aLocFront = theProgram->GetStateLocation (OpenGl_OCCT_FRONT_MATERIAL);
|
||||
if (aLocFront != OpenGl_ShaderProgram::INVALID_LOCATION)
|
||||
if (const OpenGl_ShaderUniformLocation aLocFront = theProgram->GetStateLocation (OpenGl_OCCT_FRONT_MATERIAL))
|
||||
{
|
||||
theProgram->SetUniform (myContext, aLocFront, OpenGl_Material::NbOfVec4(),
|
||||
aFrontMat.Packed());
|
||||
}
|
||||
|
||||
const GLint aLocBack = theProgram->GetStateLocation (OpenGl_OCCT_BACK_MATERIAL);
|
||||
if (aLocBack != OpenGl_ShaderProgram::INVALID_LOCATION)
|
||||
if (const OpenGl_ShaderUniformLocation aLocBack = theProgram->GetStateLocation (OpenGl_OCCT_BACK_MATERIAL))
|
||||
{
|
||||
theProgram->SetUniform (myContext, aLocBack, OpenGl_Material::NbOfVec4(),
|
||||
aBackMat.Packed());
|
||||
@ -1212,6 +1224,45 @@ void OpenGl_ShaderManager::PushOitState (const Handle(OpenGl_ShaderProgram)& the
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : PushInteriorState
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_ShaderManager::PushInteriorState (const Handle(OpenGl_ShaderProgram)& theProgram,
|
||||
const Handle(Graphic3d_AspectFillArea3d)& theAspect) const
|
||||
{
|
||||
if (theProgram.IsNull()
|
||||
|| !theProgram->IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (const OpenGl_ShaderUniformLocation aLocViewPort = theProgram->GetStateLocation (OpenGl_OCCT_VIEWPORT))
|
||||
{
|
||||
theProgram->SetUniform (myContext, aLocViewPort, OpenGl_Vec4 ((float )myContext->Viewport()[0], (float )myContext->Viewport()[1], (float )myContext->Viewport()[2], (float )myContext->Viewport()[3]));
|
||||
}
|
||||
if (const OpenGl_ShaderUniformLocation aLocLineWidth = theProgram->GetStateLocation (OpenGl_OCCT_LINE_WIDTH))
|
||||
{
|
||||
theProgram->SetUniform (myContext, aLocLineWidth, theAspect->EdgeWidth() * myContext->LineWidthScale());
|
||||
theProgram->SetUniform (myContext, theProgram->GetStateLocation (OpenGl_OCCT_LINE_FEATHER), myContext->LineFeather() * myContext->LineWidthScale());
|
||||
}
|
||||
if (const OpenGl_ShaderUniformLocation aLocWireframeColor = theProgram->GetStateLocation (OpenGl_OCCT_WIREFRAME_COLOR))
|
||||
{
|
||||
if (theAspect->InteriorStyle() == Aspect_IS_HOLLOW)
|
||||
{
|
||||
theProgram->SetUniform (myContext, aLocWireframeColor, OpenGl_Vec4 (-1.0f, -1.0f, -1.0f, -1.0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
theProgram->SetUniform (myContext, aLocWireframeColor, theAspect->EdgeColorRGBA());
|
||||
}
|
||||
}
|
||||
if (const OpenGl_ShaderUniformLocation aLocQuadModeState = theProgram->GetStateLocation (OpenGl_OCCT_QUAD_MODE_STATE))
|
||||
{
|
||||
theProgram->SetUniform (myContext, aLocQuadModeState, theAspect->ToSkipFirstEdge() ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : PushState
|
||||
// purpose : Pushes state of OCCT graphics parameters to the program
|
||||
@ -1264,19 +1315,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFont()
|
||||
EOL"}";
|
||||
|
||||
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (myContext->core32 != NULL)
|
||||
{
|
||||
aProgramSrc->SetHeader ("#version 150");
|
||||
}
|
||||
#else
|
||||
if (myContext->IsGlGreaterEqual (3, 1))
|
||||
{
|
||||
// prefer "100 es" on OpenGL ES 3.0 devices
|
||||
// and "300 es" on newer devices (3.1+)
|
||||
aProgramSrc->SetHeader ("#version 300 es");
|
||||
}
|
||||
#endif
|
||||
defaultGlslVersion (aProgramSrc, 0);
|
||||
aProgramSrc->SetNbLightsMax (0);
|
||||
aProgramSrc->SetNbClipPlanesMax (0);
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
||||
@ -1482,6 +1521,164 @@ namespace
|
||||
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : defaultGlslVersion
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
int OpenGl_ShaderManager::defaultGlslVersion (const Handle(Graphic3d_ShaderProgram)& theProgram,
|
||||
int theBits,
|
||||
bool theUsesDerivates) const
|
||||
{
|
||||
int aBits = theBits;
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (myContext->core32 != NULL)
|
||||
{
|
||||
theProgram->SetHeader ("#version 150");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((theBits & OpenGl_PO_StippleLine) != 0)
|
||||
{
|
||||
if (myContext->IsGlGreaterEqual (3, 0))
|
||||
{
|
||||
theProgram->SetHeader ("#version 130");
|
||||
}
|
||||
else if (myContext->CheckExtension ("GL_EXT_gpu_shader4"))
|
||||
{
|
||||
theProgram->SetHeader ("#extension GL_EXT_gpu_shader4 : enable");
|
||||
}
|
||||
else
|
||||
{
|
||||
aBits = aBits & ~OpenGl_PO_StippleLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
(void )theUsesDerivates;
|
||||
#else
|
||||
// prefer "100 es" on OpenGL ES 3.0- devices (save the features unavailable before "300 es")
|
||||
// and "300 es" on OpenGL ES 3.1+ devices
|
||||
if (myContext->IsGlGreaterEqual (3, 1))
|
||||
{
|
||||
if ((theBits & OpenGl_PO_NeedsGeomShader) != 0)
|
||||
{
|
||||
theProgram->SetHeader (myContext->hasGeometryStage != OpenGl_FeatureInExtensions ? "#version 320 es" : "#version 310 es");
|
||||
}
|
||||
else
|
||||
{
|
||||
theProgram->SetHeader ("#version 300 es");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((theBits & OpenGl_PO_WriteOit) != 0
|
||||
|| (theBits & OpenGl_PO_StippleLine) != 0)
|
||||
{
|
||||
if (myContext->IsGlGreaterEqual (3, 0))
|
||||
{
|
||||
theProgram->SetHeader ("#version 300 es");
|
||||
}
|
||||
else
|
||||
{
|
||||
aBits = aBits & ~OpenGl_PO_WriteOit;
|
||||
aBits = aBits & ~OpenGl_PO_StippleLine;
|
||||
}
|
||||
}
|
||||
if (theUsesDerivates)
|
||||
{
|
||||
if (myContext->IsGlGreaterEqual (3, 0))
|
||||
{
|
||||
theProgram->SetHeader ("#version 300 es");
|
||||
}
|
||||
else if (myContext->oesStdDerivatives)
|
||||
{
|
||||
theProgram->SetHeader ("#extension GL_OES_standard_derivatives : enable");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return aBits;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : prepareGeomMainSrc
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString OpenGl_ShaderManager::prepareGeomMainSrc (OpenGl_ShaderObject::ShaderVariableList& theUnifoms,
|
||||
OpenGl_ShaderObject::ShaderVariableList& theStageInOuts,
|
||||
Standard_Integer theBits)
|
||||
{
|
||||
if ((theBits & OpenGl_PO_NeedsGeomShader) == 0)
|
||||
{
|
||||
return TCollection_AsciiString();
|
||||
}
|
||||
|
||||
TCollection_AsciiString aSrcMainGeom =
|
||||
EOL"void main()"
|
||||
EOL"{";
|
||||
|
||||
if ((theBits & OpenGl_PO_MeshEdges) != 0)
|
||||
{
|
||||
theUnifoms.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 occViewport", Graphic3d_TOS_GEOMETRY));
|
||||
theUnifoms.Append (OpenGl_ShaderObject::ShaderVariable ("bool occIsQuadMode", Graphic3d_TOS_GEOMETRY));
|
||||
theUnifoms.Append (OpenGl_ShaderObject::ShaderVariable ("float occLineWidth", Graphic3d_TOS_GEOMETRY));
|
||||
theUnifoms.Append (OpenGl_ShaderObject::ShaderVariable ("float occLineWidth", Graphic3d_TOS_FRAGMENT));
|
||||
theUnifoms.Append (OpenGl_ShaderObject::ShaderVariable ("float occLineFeather", Graphic3d_TOS_FRAGMENT));
|
||||
theUnifoms.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 occWireframeColor", Graphic3d_TOS_FRAGMENT));
|
||||
theStageInOuts.Append(OpenGl_ShaderObject::ShaderVariable ("vec3 EdgeDistance", Graphic3d_TOS_GEOMETRY | Graphic3d_TOS_FRAGMENT));
|
||||
|
||||
aSrcMainGeom = TCollection_AsciiString()
|
||||
+ EOL"vec3 ViewPortTransform (vec4 theVec)"
|
||||
EOL"{"
|
||||
EOL" vec3 aWinCoord = theVec.xyz / theVec.w;"
|
||||
EOL" aWinCoord = aWinCoord * 0.5 + 0.5;"
|
||||
EOL" aWinCoord.xy = aWinCoord.xy * occViewport.zw + occViewport.xy;"
|
||||
EOL" return aWinCoord;"
|
||||
EOL"}"
|
||||
+ aSrcMainGeom
|
||||
+ EOL" vec3 aSideA = ViewPortTransform (gl_in[2].gl_Position) - ViewPortTransform (gl_in[1].gl_Position);"
|
||||
EOL" vec3 aSideB = ViewPortTransform (gl_in[2].gl_Position) - ViewPortTransform (gl_in[0].gl_Position);"
|
||||
EOL" vec3 aSideC = ViewPortTransform (gl_in[1].gl_Position) - ViewPortTransform (gl_in[0].gl_Position);"
|
||||
EOL" float aQuadArea = abs (aSideB.x * aSideC.y - aSideB.y * aSideC.x);"
|
||||
EOL" vec3 aLenABC = vec3 (length (aSideA), length (aSideB), length (aSideC));"
|
||||
EOL" vec3 aHeightABC = vec3 (aQuadArea) / aLenABC;"
|
||||
EOL" aHeightABC = max (aHeightABC, vec3 (10.0 * occLineWidth));" // avoid shrunk presentation disappearing at distance
|
||||
EOL" float aQuadModeHeightC = occIsQuadMode ? occLineWidth + 1.0 : 0.0;";
|
||||
}
|
||||
|
||||
for (Standard_Integer aVertIter = 0; aVertIter < 3; ++aVertIter)
|
||||
{
|
||||
const TCollection_AsciiString aVertIndex (aVertIter);
|
||||
// pass variables from Vertex shader to Fragment shader through Geometry shader
|
||||
for (OpenGl_ShaderObject::ShaderVariableList::Iterator aVarListIter (theStageInOuts); aVarListIter.More(); aVarListIter.Next())
|
||||
{
|
||||
if (aVarListIter.Value().Stages == (Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT))
|
||||
{
|
||||
const TCollection_AsciiString aVarName = aVarListIter.Value().Name.Token (" ", 2);
|
||||
aSrcMainGeom += TCollection_AsciiString()
|
||||
+ EOL" geomOut." + aVarName + " = geomIn[" + aVertIndex + "]." + aVarName + ";";
|
||||
}
|
||||
}
|
||||
|
||||
if ((theBits & OpenGl_PO_MeshEdges) != 0)
|
||||
{
|
||||
switch (aVertIter)
|
||||
{
|
||||
case 0: aSrcMainGeom += EOL" EdgeDistance = vec3 (aHeightABC[0], 0.0, aQuadModeHeightC);"; break;
|
||||
case 1: aSrcMainGeom += EOL" EdgeDistance = vec3 (0.0, aHeightABC[1], aQuadModeHeightC);"; break;
|
||||
case 2: aSrcMainGeom += EOL" EdgeDistance = vec3 (0.0, 0.0, aHeightABC[2]);"; break;
|
||||
}
|
||||
}
|
||||
aSrcMainGeom += TCollection_AsciiString()
|
||||
+ EOL" gl_Position = gl_in[" + aVertIndex + "].gl_Position;"
|
||||
EOL" EmitVertex();";
|
||||
}
|
||||
aSrcMainGeom +=
|
||||
EOL" EndPrimitive();"
|
||||
EOL"}";
|
||||
|
||||
return aSrcMainGeom;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : prepareStdProgramUnlit
|
||||
// purpose :
|
||||
@ -1490,11 +1687,12 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
|
||||
const Standard_Integer theBits)
|
||||
{
|
||||
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
||||
TCollection_AsciiString aSrcVert, aSrcVertExtraMain, aSrcVertExtraFunc, aSrcGetAlpha;
|
||||
TCollection_AsciiString aSrcFrag, aSrcFragExtraMain, aSrcFragWriteOit;
|
||||
TCollection_AsciiString aSrcVert, aSrcVertExtraMain, aSrcVertExtraFunc, aSrcGetAlpha, aSrcVertEndMain;
|
||||
TCollection_AsciiString aSrcFrag, aSrcFragExtraMain;
|
||||
TCollection_AsciiString aSrcFragGetColor = EOL"vec4 getColor(void) { return occColor; }";
|
||||
TCollection_AsciiString aSrcFragMainGetColor = EOL" occSetFragColor (getColor());";
|
||||
TCollection_AsciiString aSrcFragMainGetColor = EOL" occSetFragColor (getFinalColor());";
|
||||
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
|
||||
|
||||
if ((theBits & OpenGl_PO_Point) != 0)
|
||||
{
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
@ -1578,7 +1776,14 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
|
||||
EOL" PositionWorld = occModelWorldMatrix * occVertex;"
|
||||
EOL" Position = occWorldViewMatrix * PositionWorld;";
|
||||
|
||||
if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
|
||||
if ((theBits & OpenGl_PO_ClipPlanesN) == OpenGl_PO_ClipPlanesN)
|
||||
{
|
||||
aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
|
||||
aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
|
||||
? THE_FRAG_CLIP_CHAINS_N
|
||||
: THE_FRAG_CLIP_PLANES_N;
|
||||
}
|
||||
else if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
|
||||
{
|
||||
aNbClipPlanes = 1;
|
||||
aSrcFragExtraMain += THE_FRAG_CLIP_PLANES_1;
|
||||
@ -1590,50 +1795,17 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
|
||||
? THE_FRAG_CLIP_CHAINS_2
|
||||
: THE_FRAG_CLIP_PLANES_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
|
||||
aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
|
||||
? THE_FRAG_CLIP_CHAINS_N
|
||||
: THE_FRAG_CLIP_PLANES_N;
|
||||
}
|
||||
}
|
||||
if ((theBits & OpenGl_PO_WriteOit) != 0)
|
||||
{
|
||||
aProgramSrc->SetNbFragmentOutputs (2);
|
||||
aProgramSrc->SetWeightOitOutput (true);
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
if (myContext->IsGlGreaterEqual (3, 0))
|
||||
{
|
||||
aProgramSrc->SetHeader ("#version 300 es");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TCollection_AsciiString aSrcVertEndMain;
|
||||
if ((theBits & OpenGl_PO_StippleLine) != 0)
|
||||
{
|
||||
bool hasGlslBitOps = false;
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
if (myContext->IsGlGreaterEqual (3, 0))
|
||||
{
|
||||
aProgramSrc->SetHeader ("#version 300 es");
|
||||
hasGlslBitOps = true;
|
||||
}
|
||||
#else
|
||||
if (myContext->IsGlGreaterEqual (3, 0))
|
||||
{
|
||||
aProgramSrc->SetHeader ("#version 130");
|
||||
hasGlslBitOps = true;
|
||||
}
|
||||
else if(myContext->CheckExtension("GL_EXT_gpu_shader4"))
|
||||
{
|
||||
aProgramSrc->SetHeader ("#extension GL_EXT_gpu_shader4 : enable");
|
||||
hasGlslBitOps = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (hasGlslBitOps)
|
||||
const Standard_Integer aBits = defaultGlslVersion (aProgramSrc, theBits);
|
||||
if ((aBits & OpenGl_PO_StippleLine) != 0)
|
||||
{
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("int uPattern", Graphic3d_TOS_FRAGMENT));
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("float uFactor", Graphic3d_TOS_FRAGMENT));
|
||||
@ -1645,7 +1817,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
|
||||
EOL" float aRotatePoint = gl_FragCoord.x * sin (anAngle) + gl_FragCoord.y * cos (anAngle);"
|
||||
EOL" uint aBit = uint (floor (aRotatePoint / uFactor + 0.5)) & 15U;"
|
||||
EOL" if ((uint (uPattern) & (1U << aBit)) == 0U) discard;"
|
||||
EOL" vec4 aColor = getColor();"
|
||||
EOL" vec4 aColor = getFinalColor();"
|
||||
EOL" if (aColor.a <= 0.1) discard;"
|
||||
EOL" occSetFragColor (aColor);";
|
||||
}
|
||||
@ -1664,6 +1836,11 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
|
||||
+ aSrcVertEndMain
|
||||
+ EOL"}";
|
||||
|
||||
TCollection_AsciiString aSrcGeom = prepareGeomMainSrc (aUniforms, aStageInOuts, theBits);
|
||||
aSrcFragGetColor += (theBits & OpenGl_PO_MeshEdges) != 0
|
||||
? THE_FRAG_WIREFRAME_COLOR
|
||||
: EOL"#define getFinalColor getColor";
|
||||
|
||||
aSrcFrag =
|
||||
aSrcFragGetColor
|
||||
+ aSrcGetAlpha
|
||||
@ -1671,28 +1848,16 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
|
||||
EOL"{"
|
||||
+ aSrcFragExtraMain
|
||||
+ aSrcFragMainGetColor
|
||||
+ aSrcFragWriteOit
|
||||
+ EOL"}";
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (myContext->core32 != NULL)
|
||||
{
|
||||
aProgramSrc->SetHeader ("#version 150");
|
||||
}
|
||||
#else
|
||||
if (myContext->IsGlGreaterEqual (3, 1))
|
||||
{
|
||||
// prefer "100 es" on OpenGL ES 3.0 devices
|
||||
// and "300 es" on newer devices (3.1+)
|
||||
aProgramSrc->SetHeader ("#version 300 es");
|
||||
}
|
||||
#endif
|
||||
defaultGlslVersion (aProgramSrc, theBits);
|
||||
aProgramSrc->SetNbLightsMax (0);
|
||||
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
|
||||
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
|
||||
|
||||
const Standard_Integer aNbGeomInputVerts = !aSrcGeom.IsEmpty() ? 3 : 0;
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcGeom, Graphic3d_TOS_GEOMETRY, aUniforms, aStageInOuts, "geomIn", "geomOut", aNbGeomInputVerts));
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
|
||||
TCollection_AsciiString aKey;
|
||||
if (!Create (aProgramSrc, aKey, theProgram))
|
||||
{
|
||||
@ -1881,7 +2046,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
|
||||
{
|
||||
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
||||
TCollection_AsciiString aSrcVert, aSrcVertColor, aSrcVertExtraMain;
|
||||
TCollection_AsciiString aSrcFrag, aSrcFragExtraMain, aSrcFragWriteOit;
|
||||
TCollection_AsciiString aSrcFrag, aSrcFragExtraMain;
|
||||
TCollection_AsciiString aSrcFragGetColor = EOL"vec4 getColor(void) { return gl_FrontFacing ? FrontColor : BackColor; }";
|
||||
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
|
||||
|
||||
@ -1934,7 +2099,14 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
|
||||
EOL" PositionWorld = aPositionWorld;"
|
||||
EOL" Position = aPosition;";
|
||||
|
||||
if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
|
||||
if ((theBits & OpenGl_PO_ClipPlanesN) == OpenGl_PO_ClipPlanesN)
|
||||
{
|
||||
aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
|
||||
aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
|
||||
? THE_FRAG_CLIP_CHAINS_N
|
||||
: THE_FRAG_CLIP_PLANES_N;
|
||||
}
|
||||
else if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
|
||||
{
|
||||
aNbClipPlanes = 1;
|
||||
aSrcFragExtraMain += THE_FRAG_CLIP_PLANES_1;
|
||||
@ -1946,24 +2118,11 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
|
||||
? THE_FRAG_CLIP_CHAINS_2
|
||||
: THE_FRAG_CLIP_PLANES_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
|
||||
aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
|
||||
? THE_FRAG_CLIP_CHAINS_N
|
||||
: THE_FRAG_CLIP_PLANES_N;
|
||||
}
|
||||
}
|
||||
if ((theBits & OpenGl_PO_WriteOit) != 0)
|
||||
{
|
||||
aProgramSrc->SetNbFragmentOutputs (2);
|
||||
aProgramSrc->SetWeightOitOutput (true);
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
if (myContext->IsGlGreaterEqual (3, 0))
|
||||
{
|
||||
aProgramSrc->SetHeader ("#version 300 es");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 FrontColor", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
|
||||
@ -1988,33 +2147,27 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
|
||||
+ EOL" gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex;"
|
||||
EOL"}";
|
||||
|
||||
TCollection_AsciiString aSrcGeom = prepareGeomMainSrc (aUniforms, aStageInOuts, theBits);
|
||||
aSrcFragGetColor += (theBits & OpenGl_PO_MeshEdges) != 0
|
||||
? THE_FRAG_WIREFRAME_COLOR
|
||||
: EOL"#define getFinalColor getColor";
|
||||
|
||||
aSrcFrag = TCollection_AsciiString()
|
||||
+ aSrcFragGetColor
|
||||
+ EOL"void main()"
|
||||
EOL"{"
|
||||
+ aSrcFragExtraMain
|
||||
+ EOL" occSetFragColor (getColor());"
|
||||
+ aSrcFragWriteOit
|
||||
+ EOL" occSetFragColor (getFinalColor());"
|
||||
+ EOL"}";
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (myContext->core32 != NULL)
|
||||
{
|
||||
aProgramSrc->SetHeader ("#version 150");
|
||||
}
|
||||
#else
|
||||
if (myContext->IsGlGreaterEqual (3, 1))
|
||||
{
|
||||
// prefer "100 es" on OpenGL ES 3.0 devices
|
||||
// and "300 es" on newer devices (3.1+)
|
||||
aProgramSrc->SetHeader ("#version 300 es");
|
||||
}
|
||||
#endif
|
||||
defaultGlslVersion (aProgramSrc, theBits);
|
||||
aProgramSrc->SetNbLightsMax (aNbLights);
|
||||
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
|
||||
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
|
||||
const Standard_Integer aNbGeomInputVerts = !aSrcGeom.IsEmpty() ? 3 : 0;
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcGeom, Graphic3d_TOS_GEOMETRY, aUniforms, aStageInOuts, "geomIn", "geomOut", aNbGeomInputVerts));
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
|
||||
TCollection_AsciiString aKey;
|
||||
if (!Create (aProgramSrc, aKey, theProgram))
|
||||
{
|
||||
@ -2052,10 +2205,9 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
|
||||
"Warning: applied workaround for flat shading normal computation using dFdx/dFdy on Adreno");
|
||||
}
|
||||
#endif
|
||||
|
||||
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
||||
TCollection_AsciiString aSrcVert, aSrcVertExtraFunc, aSrcVertExtraMain;
|
||||
TCollection_AsciiString aSrcFrag, aSrcFragExtraOut, aSrcFragGetVertColor, aSrcFragExtraMain, aSrcFragWriteOit;
|
||||
TCollection_AsciiString aSrcFrag, aSrcFragExtraOut, aSrcFragGetVertColor, aSrcFragExtraMain;
|
||||
TCollection_AsciiString aSrcFragGetColor = EOL"vec4 getColor(void) { return " thePhongCompLight "; }";
|
||||
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
|
||||
if ((theBits & OpenGl_PO_Point) != 0)
|
||||
@ -2103,7 +2255,14 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
|
||||
int aNbClipPlanes = 0;
|
||||
if ((theBits & OpenGl_PO_ClipPlanesN) != 0)
|
||||
{
|
||||
if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
|
||||
if ((theBits & OpenGl_PO_ClipPlanesN) == OpenGl_PO_ClipPlanesN)
|
||||
{
|
||||
aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
|
||||
aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
|
||||
? THE_FRAG_CLIP_CHAINS_N
|
||||
: THE_FRAG_CLIP_PLANES_N;
|
||||
}
|
||||
else if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
|
||||
{
|
||||
aNbClipPlanes = 1;
|
||||
aSrcFragExtraMain += THE_FRAG_CLIP_PLANES_1;
|
||||
@ -2115,13 +2274,6 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
|
||||
? THE_FRAG_CLIP_CHAINS_2
|
||||
: THE_FRAG_CLIP_PLANES_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
|
||||
aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
|
||||
? THE_FRAG_CLIP_CHAINS_N
|
||||
: THE_FRAG_CLIP_PLANES_N;
|
||||
}
|
||||
}
|
||||
if ((theBits & OpenGl_PO_WriteOit) != 0)
|
||||
{
|
||||
@ -2158,6 +2310,11 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
|
||||
+ EOL" gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex;"
|
||||
EOL"}";
|
||||
|
||||
TCollection_AsciiString aSrcGeom = prepareGeomMainSrc (aUniforms, aStageInOuts, theBits);
|
||||
aSrcFragGetColor += (theBits & OpenGl_PO_MeshEdges) != 0
|
||||
? THE_FRAG_WIREFRAME_COLOR
|
||||
: EOL"#define getFinalColor getColor";
|
||||
|
||||
Standard_Integer aNbLights = 0;
|
||||
const TCollection_AsciiString aLights = stdComputeLighting (aNbLights, (theBits & OpenGl_PO_VertColor) != 0);
|
||||
aSrcFrag = TCollection_AsciiString()
|
||||
@ -2170,39 +2327,17 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
|
||||
EOL"void main()"
|
||||
EOL"{"
|
||||
+ aSrcFragExtraMain
|
||||
+ EOL" occSetFragColor (getColor());"
|
||||
+ aSrcFragWriteOit
|
||||
+ EOL" occSetFragColor (getFinalColor());"
|
||||
+ EOL"}";
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (myContext->core32 != NULL)
|
||||
{
|
||||
aProgramSrc->SetHeader ("#version 150");
|
||||
}
|
||||
#else
|
||||
if (myContext->IsGlGreaterEqual (3, 1))
|
||||
{
|
||||
// prefer "100 es" on OpenGL ES 3.0 devices
|
||||
// and "300 es" on newer devices (3.1+)
|
||||
aProgramSrc->SetHeader ("#version 300 es");
|
||||
}
|
||||
else if (isFlatNormal)
|
||||
{
|
||||
if (myContext->IsGlGreaterEqual (3, 0))
|
||||
{
|
||||
aProgramSrc->SetHeader ("#version 300 es");
|
||||
}
|
||||
else if (myContext->oesStdDerivatives)
|
||||
{
|
||||
aProgramSrc->SetHeader ("#extension GL_OES_standard_derivatives : enable");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
defaultGlslVersion (aProgramSrc, theBits, isFlatNormal);
|
||||
aProgramSrc->SetNbLightsMax (aNbLights);
|
||||
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
|
||||
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
|
||||
const Standard_Integer aNbGeomInputVerts = !aSrcGeom.IsEmpty() ? 3 : 0;
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcGeom, Graphic3d_TOS_GEOMETRY, aUniforms, aStageInOuts, "geomIn", "geomOut", aNbGeomInputVerts));
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
|
||||
TCollection_AsciiString aKey;
|
||||
if (!Create (aProgramSrc, aKey, theProgram))
|
||||
{
|
||||
@ -2379,20 +2514,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramStereo (Handle(OpenGl_Sh
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (myContext->core32 != NULL)
|
||||
{
|
||||
aProgramSrc->SetHeader ("#version 150");
|
||||
}
|
||||
#else
|
||||
if (myContext->IsGlGreaterEqual (3, 1))
|
||||
{
|
||||
// prefer "100 es" on OpenGL ES 3.0 devices
|
||||
// and "300 es" on newer devices (3.1+)
|
||||
aProgramSrc->SetHeader ("#version 300 es");
|
||||
}
|
||||
#endif
|
||||
|
||||
defaultGlslVersion (aProgramSrc, 0);
|
||||
aProgramSrc->SetNbLightsMax (0);
|
||||
aProgramSrc->SetNbClipPlanesMax (0);
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
||||
@ -2437,20 +2559,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramBoundBox()
|
||||
EOL" occSetFragColor (occColor);"
|
||||
EOL"}";
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (myContext->core32 != NULL)
|
||||
{
|
||||
aProgramSrc->SetHeader ("#version 150");
|
||||
}
|
||||
#else
|
||||
if (myContext->IsGlGreaterEqual (3, 1))
|
||||
{
|
||||
// prefer "100 es" on OpenGL ES 3.0 devices
|
||||
// and "300 es" on newer devices (3.1+)
|
||||
aProgramSrc->SetHeader ("#version 300 es");
|
||||
}
|
||||
#endif
|
||||
|
||||
defaultGlslVersion (aProgramSrc, 0);
|
||||
aProgramSrc->SetNbLightsMax (0);
|
||||
aProgramSrc->SetNbClipPlanesMax (0);
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
||||
|
@ -84,10 +84,23 @@ public:
|
||||
|
||||
//! Bind program for filled primitives rendering
|
||||
Standard_Boolean BindFaceProgram (const Handle(OpenGl_TextureSet)& theTextures,
|
||||
const Graphic3d_TypeOfShadingModel theShadingModel,
|
||||
const Graphic3d_AlphaMode theAlphaMode,
|
||||
const Standard_Boolean theHasVertColor,
|
||||
const Standard_Boolean theEnableEnvMap,
|
||||
Graphic3d_TypeOfShadingModel theShadingModel,
|
||||
Graphic3d_AlphaMode theAlphaMode,
|
||||
Standard_Boolean theHasVertColor,
|
||||
Standard_Boolean theEnableEnvMap,
|
||||
const Handle(OpenGl_ShaderProgram)& theCustomProgram)
|
||||
{
|
||||
return BindFaceProgram (theTextures, theShadingModel, theAlphaMode, Aspect_IS_SOLID, theHasVertColor, theEnableEnvMap, false, theCustomProgram);
|
||||
}
|
||||
|
||||
//! Bind program for filled primitives rendering
|
||||
Standard_Boolean BindFaceProgram (const Handle(OpenGl_TextureSet)& theTextures,
|
||||
Graphic3d_TypeOfShadingModel theShadingModel,
|
||||
Graphic3d_AlphaMode theAlphaMode,
|
||||
Aspect_InteriorStyle theInteriorStyle,
|
||||
Standard_Boolean theHasVertColor,
|
||||
Standard_Boolean theEnableEnvMap,
|
||||
Standard_Boolean theEnableMeshEdges,
|
||||
const Handle(OpenGl_ShaderProgram)& theCustomProgram)
|
||||
{
|
||||
if (!theCustomProgram.IsNull()
|
||||
@ -100,7 +113,7 @@ public:
|
||||
&& (theTextures.IsNull() || theTextures->IsModulate())
|
||||
? theShadingModel
|
||||
: Graphic3d_TOSM_UNLIT;
|
||||
const Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, theHasVertColor, theEnableEnvMap);
|
||||
const Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, theInteriorStyle, theHasVertColor, theEnableEnvMap, theEnableMeshEdges);
|
||||
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (aShadeModelOnFace, aBits);
|
||||
return bindProgramWithState (aProgram);
|
||||
}
|
||||
@ -119,7 +132,7 @@ public:
|
||||
return bindProgramWithState (theCustomProgram);
|
||||
}
|
||||
|
||||
Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, theHasVertColor, false);
|
||||
Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, Aspect_IS_SOLID, theHasVertColor, false, false);
|
||||
if (theLineType != Aspect_TOL_SOLID)
|
||||
{
|
||||
aBits |= OpenGl_PO_StippleLine;
|
||||
@ -142,7 +155,7 @@ public:
|
||||
return bindProgramWithState (theCustomProgram);
|
||||
}
|
||||
|
||||
const Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, theHasVertColor, false) | OpenGl_PO_Point;
|
||||
const Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, Aspect_IS_SOLID, theHasVertColor, false, false) | OpenGl_PO_Point;
|
||||
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theShadingModel, aBits);
|
||||
return bindProgramWithState (aProgram);
|
||||
}
|
||||
@ -301,6 +314,12 @@ public:
|
||||
//! Pushes current state of material to specified program.
|
||||
void PushMaterialState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
|
||||
|
||||
public:
|
||||
|
||||
//! Setup interior style line edges variables.
|
||||
Standard_EXPORT void PushInteriorState (const Handle(OpenGl_ShaderProgram)& theProgram,
|
||||
const Handle(Graphic3d_AspectFillArea3d)& theAspect) const;
|
||||
|
||||
public:
|
||||
|
||||
//! Returns state of OIT uniforms.
|
||||
@ -411,12 +430,43 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
//! Define clipping planes program bits.
|
||||
Standard_Integer getClipPlaneBits() const
|
||||
{
|
||||
const Standard_Integer aNbPlanes = myContext->Clipping().NbClippingOrCappingOn();
|
||||
if (aNbPlanes <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Standard_Integer aBits = 0;
|
||||
if (myContext->Clipping().HasClippingChains())
|
||||
{
|
||||
aBits |= OpenGl_PO_ClipChains;
|
||||
}
|
||||
|
||||
if (aNbPlanes == 1)
|
||||
{
|
||||
aBits |= OpenGl_PO_ClipPlanes1;
|
||||
}
|
||||
else if (aNbPlanes == 2)
|
||||
{
|
||||
aBits |= OpenGl_PO_ClipPlanes2;
|
||||
}
|
||||
else
|
||||
{
|
||||
aBits |= OpenGl_PO_ClipPlanesN;
|
||||
}
|
||||
return aBits;
|
||||
}
|
||||
|
||||
//! Define program bits.
|
||||
Standard_Integer getProgramBits (const Handle(OpenGl_TextureSet)& theTextures,
|
||||
Graphic3d_AlphaMode theAlphaMode,
|
||||
Aspect_InteriorStyle theInteriorStyle,
|
||||
Standard_Boolean theHasVertColor,
|
||||
Standard_Boolean theEnableEnvMap)
|
||||
|
||||
Standard_Boolean theEnableEnvMap,
|
||||
Standard_Boolean theEnableMeshEdges) const
|
||||
{
|
||||
Standard_Integer aBits = 0;
|
||||
if (theAlphaMode == Graphic3d_AlphaMode_Mask)
|
||||
@ -424,22 +474,14 @@ protected:
|
||||
aBits |= OpenGl_PO_AlphaTest;
|
||||
}
|
||||
|
||||
const Standard_Integer aNbPlanes = myContext->Clipping().NbClippingOrCappingOn();
|
||||
if (aNbPlanes > 0)
|
||||
aBits |= getClipPlaneBits();
|
||||
if (theEnableMeshEdges
|
||||
&& myContext->hasGeometryStage != OpenGl_FeatureNotAvailable)
|
||||
{
|
||||
aBits |= OpenGl_PO_ClipPlanesN;
|
||||
if (myContext->Clipping().HasClippingChains())
|
||||
aBits |= OpenGl_PO_MeshEdges;
|
||||
if (theInteriorStyle == Aspect_IS_HOLLOW)
|
||||
{
|
||||
aBits |= OpenGl_PO_ClipChains;
|
||||
}
|
||||
|
||||
if (aNbPlanes == 1)
|
||||
{
|
||||
aBits |= OpenGl_PO_ClipPlanes1;
|
||||
}
|
||||
else if (aNbPlanes == 2)
|
||||
{
|
||||
aBits |= OpenGl_PO_ClipPlanes2;
|
||||
aBits |= OpenGl_PO_AlphaTest;
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,7 +496,8 @@ protected:
|
||||
{
|
||||
aBits |= theTextures->First()->IsAlpha() ? OpenGl_PO_TextureA : OpenGl_PO_TextureRGB;
|
||||
}
|
||||
if (theHasVertColor)
|
||||
if (theHasVertColor
|
||||
&& theInteriorStyle != Aspect_IS_HIDDENLINE)
|
||||
{
|
||||
aBits |= OpenGl_PO_VertColor;
|
||||
}
|
||||
@ -555,6 +598,16 @@ protected:
|
||||
//! Prepare standard GLSL program for bounding box.
|
||||
Standard_EXPORT Standard_Boolean prepareStdProgramBoundBox();
|
||||
|
||||
//! Prepare GLSL version header.
|
||||
Standard_EXPORT Standard_Integer defaultGlslVersion (const Handle(Graphic3d_ShaderProgram)& theProgram,
|
||||
Standard_Integer theBits,
|
||||
bool theUsesDerivates = false) const;
|
||||
|
||||
//! Prepare GLSL source for geometry shader according to parameters.
|
||||
Standard_EXPORT TCollection_AsciiString prepareGeomMainSrc (OpenGl_ShaderObject::ShaderVariableList& theUnifoms,
|
||||
OpenGl_ShaderObject::ShaderVariableList& theStageInOuts,
|
||||
Standard_Integer theBits);
|
||||
|
||||
protected:
|
||||
|
||||
//! Packed properties of light source
|
||||
|
@ -58,6 +58,11 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
|
||||
const TCollection_AsciiString& theOutName,
|
||||
Standard_Integer theNbGeomInputVerts)
|
||||
{
|
||||
if (theSource.IsEmpty())
|
||||
{
|
||||
return Handle(Graphic3d_ShaderObject)();
|
||||
}
|
||||
|
||||
TCollection_AsciiString aSrcUniforms, aSrcInOuts, aSrcInStructs, aSrcOutStructs;
|
||||
for (ShaderVariableList::Iterator anUniformIter (theUniforms); anUniformIter.More(); anUniformIter.Next())
|
||||
{
|
||||
@ -90,12 +95,15 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
|
||||
const Standard_Boolean hasGeomStage = theNbGeomInputVerts > 0
|
||||
&& aStageLower < Graphic3d_TOS_GEOMETRY
|
||||
&& aStageUpper >= Graphic3d_TOS_GEOMETRY;
|
||||
const Standard_Boolean isAllStagesVar = aStageLower == Graphic3d_TOS_VERTEX
|
||||
&& aStageUpper == Graphic3d_TOS_FRAGMENT;
|
||||
if (hasGeomStage
|
||||
|| !theInName.IsEmpty()
|
||||
|| !theOutName.IsEmpty())
|
||||
{
|
||||
if (aSrcInStructs.IsEmpty()
|
||||
&& aSrcOutStructs.IsEmpty())
|
||||
&& aSrcOutStructs.IsEmpty()
|
||||
&& isAllStagesVar)
|
||||
{
|
||||
if (theType == aStageLower)
|
||||
{
|
||||
@ -113,8 +121,9 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
|
||||
}
|
||||
}
|
||||
|
||||
if (!aSrcInStructs.IsEmpty()
|
||||
|| !aSrcOutStructs.IsEmpty())
|
||||
if (isAllStagesVar
|
||||
&& (!aSrcInStructs.IsEmpty()
|
||||
|| !aSrcOutStructs.IsEmpty()))
|
||||
{
|
||||
if (!aSrcInStructs.IsEmpty())
|
||||
{
|
||||
@ -138,6 +147,12 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
|
||||
}
|
||||
}
|
||||
|
||||
if (theType == Graphic3d_TOS_GEOMETRY)
|
||||
{
|
||||
aSrcUniforms.Prepend (TCollection_AsciiString()
|
||||
+ "\nlayout (triangles) in;"
|
||||
"\nlayout (triangle_strip, max_vertices = " + theNbGeomInputVerts + ") out;");
|
||||
}
|
||||
if (!aSrcInStructs.IsEmpty()
|
||||
&& theType == Graphic3d_TOS_GEOMETRY)
|
||||
{
|
||||
@ -153,10 +168,10 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
|
||||
}
|
||||
aSrcInStructs += ";";
|
||||
}
|
||||
else if (!aSrcOutStructs.IsEmpty())
|
||||
if (!aSrcOutStructs.IsEmpty())
|
||||
{
|
||||
aSrcOutStructs += "\n}";
|
||||
if (!theInName.IsEmpty())
|
||||
if (!theOutName.IsEmpty())
|
||||
{
|
||||
aSrcOutStructs += " ";
|
||||
aSrcOutStructs += theOutName;
|
||||
|
@ -75,7 +75,13 @@ Standard_CString OpenGl_ShaderProgram::PredefinedKeywords[] =
|
||||
"occOitDepthFactor", // OpenGl_OCCT_OIT_DEPTH_FACTOR
|
||||
|
||||
"occTexTrsf2d", // OpenGl_OCCT_TEXTURE_TRSF2D
|
||||
"occPointSize" // OpenGl_OCCT_POINT_SIZE
|
||||
"occPointSize", // OpenGl_OCCT_POINT_SIZE
|
||||
|
||||
"occViewport", // OpenGl_OCCT_VIEWPORT
|
||||
"occLineWidth", // OpenGl_OCCT_LINE_WIDTH
|
||||
"occLineFeather", // OpenGl_OCCT_LINE_FEATHER
|
||||
"occWireframeColor", // OpenGl_OCCT_WIREFRAME_COLOR
|
||||
"occIsQuadMode", // OpenGl_OCCT_QUAD_MODE_STATE
|
||||
};
|
||||
|
||||
namespace
|
||||
@ -159,10 +165,6 @@ OpenGl_ShaderProgram::OpenGl_ShaderProgram (const Handle(Graphic3d_ShaderProgram
|
||||
myHasTessShader (false)
|
||||
{
|
||||
memset (myCurrentState, 0, sizeof (myCurrentState));
|
||||
for (GLint aVar = 0; aVar < OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES; ++aVar)
|
||||
{
|
||||
myStateLocations[aVar] = INVALID_LOCATION;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -191,13 +193,12 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
||||
|
||||
// detect the minimum GLSL version required for defined Shader Objects
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
if (myHasTessShader
|
||||
|| (aShaderMask & Graphic3d_TOS_GEOMETRY) != 0)
|
||||
if (myHasTessShader)
|
||||
{
|
||||
if (!theCtx->IsGlGreaterEqual (3, 2))
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Error! Geometry and Tessellation shaders require OpenGL ES 3.2+");
|
||||
"Error! Tessellation shader requires OpenGL ES 3.2+");
|
||||
return false;
|
||||
}
|
||||
else if (aHeaderVer.IsEmpty())
|
||||
@ -205,6 +206,34 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
||||
aHeaderVer = "#version 320 es";
|
||||
}
|
||||
}
|
||||
else if ((aShaderMask & Graphic3d_TOS_GEOMETRY) != 0)
|
||||
{
|
||||
switch (theCtx->hasGeometryStage)
|
||||
{
|
||||
case OpenGl_FeatureNotAvailable:
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Error! Geometry shader requires OpenGL ES 3.2+ or GL_EXT_geometry_shader");
|
||||
return false;
|
||||
}
|
||||
case OpenGl_FeatureInExtensions:
|
||||
{
|
||||
if (aHeaderVer.IsEmpty())
|
||||
{
|
||||
aHeaderVer = "#version 310 es";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OpenGl_FeatureInCore:
|
||||
{
|
||||
if (aHeaderVer.IsEmpty())
|
||||
{
|
||||
aHeaderVer = "#version 320 es";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((aShaderMask & Graphic3d_TOS_COMPUTE) != 0)
|
||||
{
|
||||
if (!theCtx->IsGlGreaterEqual (3, 1))
|
||||
@ -331,6 +360,13 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
if (theCtx->hasGeometryStage == OpenGl_FeatureInExtensions)
|
||||
{
|
||||
anExtensions += "#extension GL_EXT_geometry_shader : enable\n"
|
||||
"#extension GL_EXT_shader_io_blocks : enable\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
TCollection_AsciiString aPrecisionHeader;
|
||||
if (anIter.Value()->Type() == Graphic3d_TOS_FRAGMENT)
|
||||
@ -434,19 +470,13 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
||||
// set uniform defaults
|
||||
const Handle(OpenGl_ShaderProgram)& anOldProgram = theCtx->ActiveProgram();
|
||||
theCtx->core20fwd->glUseProgram (myProgramID);
|
||||
if (const OpenGl_ShaderUniformLocation aLocTexEnable = GetStateLocation (OpenGl_OCCT_TEXTURE_ENABLE))
|
||||
{
|
||||
const GLint aLocTexEnable = GetStateLocation (OpenGl_OCCT_TEXTURE_ENABLE);
|
||||
if (aLocTexEnable != INVALID_LOCATION)
|
||||
{
|
||||
SetUniform (theCtx, aLocTexEnable, 0); // Off
|
||||
}
|
||||
SetUniform (theCtx, aLocTexEnable, 0); // Off
|
||||
}
|
||||
if (const OpenGl_ShaderUniformLocation aLocSampler = GetUniformLocation (theCtx, "occActiveSampler"))
|
||||
{
|
||||
const GLint aLocSampler = GetUniformLocation (theCtx, "occActiveSampler");
|
||||
if (aLocSampler != INVALID_LOCATION)
|
||||
{
|
||||
SetUniform (theCtx, aLocSampler, GLint(Graphic3d_TextureUnit_0));
|
||||
}
|
||||
SetUniform (theCtx, aLocSampler, GLint(Graphic3d_TextureUnit_0));
|
||||
}
|
||||
|
||||
const TCollection_AsciiString aSamplerNamePrefix ("occSampler");
|
||||
@ -454,8 +484,7 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
||||
for (GLint aUnitIter = 0; aUnitIter < aNbUnitsMax; ++aUnitIter)
|
||||
{
|
||||
const TCollection_AsciiString aName = aSamplerNamePrefix + aUnitIter;
|
||||
const GLint aLocSampler = GetUniformLocation (theCtx, aName.ToCString());
|
||||
if (aLocSampler != INVALID_LOCATION)
|
||||
if (const OpenGl_ShaderUniformLocation aLocSampler = GetUniformLocation (theCtx, aName.ToCString()))
|
||||
{
|
||||
SetUniform (theCtx, aLocSampler, aUnitIter);
|
||||
}
|
||||
@ -645,12 +674,12 @@ Standard_Boolean OpenGl_ShaderProgram::ApplyVariables(const Handle(OpenGl_Contex
|
||||
// function : GetUniformLocation
|
||||
// purpose : Returns location (index) of the specific uniform variable
|
||||
// =======================================================================
|
||||
GLint OpenGl_ShaderProgram::GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLchar* theName) const
|
||||
OpenGl_ShaderUniformLocation OpenGl_ShaderProgram::GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLchar* theName) const
|
||||
{
|
||||
return myProgramID != NO_PROGRAM
|
||||
? theCtx->core20fwd->glGetUniformLocation (myProgramID, theName)
|
||||
: INVALID_LOCATION;
|
||||
return OpenGl_ShaderUniformLocation (myProgramID != NO_PROGRAM
|
||||
? theCtx->core20fwd->glGetUniformLocation (myProgramID, theName)
|
||||
: INVALID_LOCATION);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -665,19 +694,6 @@ GLint OpenGl_ShaderProgram::GetAttributeLocation (const Handle(OpenGl_Context)&
|
||||
: INVALID_LOCATION;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetStateLocation
|
||||
// purpose : Returns location of the OCCT state uniform variable
|
||||
// =======================================================================
|
||||
GLint OpenGl_ShaderProgram::GetStateLocation (const GLuint theVariable) const
|
||||
{
|
||||
if (theVariable < OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES)
|
||||
{
|
||||
return myStateLocations[theVariable];
|
||||
}
|
||||
return INVALID_LOCATION;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetUniform
|
||||
// purpose : Returns the value of the integer uniform variable
|
||||
|
@ -75,6 +75,13 @@ enum OpenGl_StateVariable
|
||||
OpenGl_OCCT_TEXTURE_TRSF2D,
|
||||
OpenGl_OCCT_POINT_SIZE,
|
||||
|
||||
// Wireframe state
|
||||
OpenGl_OCCT_VIEWPORT,
|
||||
OpenGl_OCCT_LINE_WIDTH,
|
||||
OpenGl_OCCT_LINE_FEATHER,
|
||||
OpenGl_OCCT_WIREFRAME_COLOR,
|
||||
OpenGl_OCCT_QUAD_MODE_STATE,
|
||||
|
||||
// DON'T MODIFY THIS ITEM (insert new items before it)
|
||||
OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES
|
||||
};
|
||||
@ -133,6 +140,34 @@ enum OpenGl_UniformStateType
|
||||
OpenGl_UniformStateType_NB
|
||||
};
|
||||
|
||||
//! Simple class represents GLSL program variable location.
|
||||
class OpenGl_ShaderUniformLocation
|
||||
{
|
||||
public:
|
||||
//! Invalid location of uniform/attribute variable.
|
||||
static const GLint INVALID_LOCATION = -1;
|
||||
public:
|
||||
|
||||
//! Construct an invalid location.
|
||||
OpenGl_ShaderUniformLocation() : myLocation (INVALID_LOCATION) {}
|
||||
|
||||
//! Constructor with initialization.
|
||||
explicit OpenGl_ShaderUniformLocation (GLint theLocation) : myLocation (theLocation) {}
|
||||
|
||||
//! Note you may safely put invalid location in functions like glUniform* - the data passed in will be silently ignored.
|
||||
//! @return true if location is not equal to -1.
|
||||
bool IsValid() const { return myLocation != INVALID_LOCATION; }
|
||||
|
||||
//! Return TRUE for non-invalid location.
|
||||
operator bool() const { return myLocation != INVALID_LOCATION; }
|
||||
|
||||
//! Convert operators help silently put object to GL functions like glUniform*.
|
||||
operator GLint() const { return myLocation; }
|
||||
|
||||
private:
|
||||
GLint myLocation;
|
||||
};
|
||||
|
||||
//! Wrapper for OpenGL program object.
|
||||
class OpenGl_ShaderProgram : public OpenGl_NamedResource
|
||||
{
|
||||
@ -270,15 +305,15 @@ private:
|
||||
public:
|
||||
|
||||
//! Returns location of the specific uniform variable.
|
||||
Standard_EXPORT GLint GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLchar* theName) const;
|
||||
Standard_EXPORT OpenGl_ShaderUniformLocation GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLchar* theName) const;
|
||||
|
||||
//! Returns index of the generic vertex attribute by variable name.
|
||||
Standard_EXPORT GLint GetAttributeLocation (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLchar* theName) const;
|
||||
|
||||
//! Returns location of the OCCT state uniform variable.
|
||||
Standard_EXPORT GLint GetStateLocation (const GLuint theVariable) const;
|
||||
const OpenGl_ShaderUniformLocation& GetStateLocation (OpenGl_StateVariable theVariable) const { return myStateLocations[theVariable]; }
|
||||
|
||||
public:
|
||||
|
||||
@ -603,7 +638,7 @@ protected:
|
||||
Standard_Size myCurrentState[OpenGl_UniformStateType_NB]; //!< defines last modification for variables of each state type
|
||||
|
||||
//! Stores locations of OCCT state uniform variables.
|
||||
GLint myStateLocations[OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES];
|
||||
OpenGl_ShaderUniformLocation myStateLocations[OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES];
|
||||
|
||||
};
|
||||
|
||||
|
@ -393,10 +393,22 @@ void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
|
||||
const OpenGl_AspectText& theTextAspect,
|
||||
const unsigned int theResolution) const
|
||||
{
|
||||
const bool anAlphaToCoverageOld = theCtx->SetSampleAlphaToCoverage (false);
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
const Standard_Integer aPrevPolygonMode = theCtx->SetPolygonMode (GL_FILL);
|
||||
const bool aPrevHatchingMode = theCtx->SetPolygonHatchEnabled (false);
|
||||
#endif
|
||||
|
||||
render (theCtx, theTextAspect,
|
||||
theTextAspect.Aspect()->ColorRGBA(),
|
||||
theTextAspect.Aspect()->ColorSubTitleRGBA(),
|
||||
theResolution);
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
theCtx->SetPolygonMode (aPrevPolygonMode);
|
||||
theCtx->SetPolygonHatchEnabled (aPrevHatchingMode);
|
||||
#endif
|
||||
theCtx->SetSampleAlphaToCoverage (anAlphaToCoverageOld);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -771,9 +783,6 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
{
|
||||
glDisable (GL_LIGHTING);
|
||||
}
|
||||
|
||||
const Standard_Integer aPrevPolygonMode = theCtx->SetPolygonMode (GL_FILL);
|
||||
const bool aPrevHatchingMode = theCtx->SetPolygonHatchEnabled (false);
|
||||
#endif
|
||||
|
||||
// setup depth test
|
||||
@ -806,7 +815,6 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
// setup blending
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
const bool anAlphaToCoverageOld = theCtx->SetSampleAlphaToCoverage (false);
|
||||
|
||||
// extra drawings
|
||||
switch (theTextAspect.Aspect()->DisplayType())
|
||||
@ -904,11 +912,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
glDisable (GL_STENCIL_TEST);
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
glDisable (GL_COLOR_LOGIC_OP);
|
||||
|
||||
theCtx->SetPolygonMode (aPrevPolygonMode);
|
||||
theCtx->SetPolygonHatchEnabled (aPrevHatchingMode);
|
||||
#endif
|
||||
theCtx->SetSampleAlphaToCoverage (anAlphaToCoverageOld);
|
||||
|
||||
// model view matrix was modified
|
||||
theCtx->WorldViewState.Pop();
|
||||
|
@ -167,6 +167,7 @@ void OpenGl_View::Redraw()
|
||||
Graphic3d_Camera::Projection aProjectType = myCamera->ProjectionType();
|
||||
Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext();
|
||||
aCtx->FrameStats()->FrameStart (myWorkspace->View(), false);
|
||||
aCtx->SetLineFeather (myRenderParams.LineFeather);
|
||||
|
||||
// release pending GL resources
|
||||
aCtx->ReleaseDelayed();
|
||||
@ -878,7 +879,9 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
|
||||
// ==================================
|
||||
|
||||
const Handle(OpenGl_Context)& aContext = myWorkspace->GetGlContext();
|
||||
aContext->SetSampleAlphaToCoverage (myRenderParams.ToEnableAlphaToCoverage);
|
||||
aContext->SetAllowSampleAlphaToCoverage (myRenderParams.ToEnableAlphaToCoverage
|
||||
&& theOutputFBO != NULL
|
||||
&& theOutputFBO->NbSamples() != 0);
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
// Disable current clipping planes
|
||||
@ -1043,6 +1046,7 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
|
||||
}
|
||||
|
||||
myWorkspace->ResetAppliedAspect();
|
||||
aContext->SetAllowSampleAlphaToCoverage (false);
|
||||
aContext->SetSampleAlphaToCoverage (false);
|
||||
|
||||
// reset FFP state for safety
|
||||
|
@ -155,7 +155,7 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
|
||||
#endif
|
||||
}
|
||||
|
||||
myFontFaceAspect.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Mask, 0.285f);
|
||||
myFontFaceAspect.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend, 0.285f);
|
||||
myFontFaceAspect.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
||||
|
||||
myNoneCulling .Aspect()->SetSuppressBackFaces (false);
|
||||
@ -193,6 +193,14 @@ Standard_Boolean OpenGl_Workspace::Activate()
|
||||
{
|
||||
myGlContext->ShaderManager()->PushState (Handle(OpenGl_ShaderProgram)());
|
||||
}
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
// font GLSL program has embedded discard, while FFP needs alpha test
|
||||
myFontFaceAspect.Aspect()->SetAlphaMode ((!myGlContext->caps->ffpEnable && myGlContext->core11 != NULL)
|
||||
? Graphic3d_AlphaMode_Blend
|
||||
: Graphic3d_AlphaMode_Mask,
|
||||
0.285f);
|
||||
#endif
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@ -316,60 +324,38 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
|
||||
}
|
||||
myAspectFaceAppliedWithHL = myHighlightStyle;
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
const Aspect_InteriorStyle anIntstyle = myAspectFaceSet->Aspect()->InteriorStyle();
|
||||
if (myAspectFaceApplied.IsNull()
|
||||
|| myAspectFaceApplied->InteriorStyle() != anIntstyle)
|
||||
{
|
||||
switch (anIntstyle)
|
||||
{
|
||||
case Aspect_IS_EMPTY:
|
||||
case Aspect_IS_HOLLOW:
|
||||
{
|
||||
myGlContext->SetPolygonMode (GL_LINE);
|
||||
break;
|
||||
}
|
||||
case Aspect_IS_HATCH:
|
||||
{
|
||||
myGlContext->SetPolygonMode (GL_FILL);
|
||||
myGlContext->SetPolygonHatchEnabled (true);
|
||||
break;
|
||||
}
|
||||
case Aspect_IS_SOLID:
|
||||
case Aspect_IS_HIDDENLINE:
|
||||
{
|
||||
myGlContext->SetPolygonMode (GL_FILL);
|
||||
myGlContext->SetPolygonHatchEnabled (false);
|
||||
break;
|
||||
}
|
||||
case Aspect_IS_POINT:
|
||||
{
|
||||
myGlContext->SetPolygonMode (GL_POINT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (anIntstyle == Aspect_IS_HATCH)
|
||||
{
|
||||
myGlContext->SetPolygonHatchStyle (myAspectFaceSet->Aspect()->HatchStyle());
|
||||
}
|
||||
#endif
|
||||
|
||||
// Aspect_POM_None means: do not change current settings
|
||||
if ((myAspectFaceSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None)
|
||||
{
|
||||
myGlContext->SetPolygonOffset (myAspectFaceSet->Aspect()->PolygonOffset());
|
||||
}
|
||||
|
||||
const Aspect_InteriorStyle anIntstyle = myAspectFaceSet->Aspect()->InteriorStyle();
|
||||
if (myAspectFaceApplied.IsNull()
|
||||
|| myAspectFaceApplied->InteriorStyle() != anIntstyle)
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
myGlContext->SetPolygonMode (anIntstyle == Aspect_IS_POINT ? GL_POINT : GL_FILL);
|
||||
myGlContext->SetPolygonHatchEnabled (anIntstyle == Aspect_IS_HATCH);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (anIntstyle == Aspect_IS_HATCH)
|
||||
{
|
||||
myGlContext->SetPolygonHatchStyle (myAspectFaceSet->Aspect()->HatchStyle());
|
||||
}
|
||||
#endif
|
||||
|
||||
// Case of hidden line
|
||||
if (myAspectFaceSet->Aspect()->InteriorStyle() == Aspect_IS_HIDDENLINE)
|
||||
if (anIntstyle == Aspect_IS_HIDDENLINE)
|
||||
{
|
||||
// copy all values including line edge aspect
|
||||
*myAspectFaceHl.Aspect() = *myAspectFaceSet->Aspect();
|
||||
myAspectFaceHl.SetAspectEdge (myAspectFaceSet->AspectEdge());
|
||||
myAspectFaceHl.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
||||
myAspectFaceHl.Aspect()->SetInteriorColor (myView->BackgroundColor().GetRGB());
|
||||
myAspectFaceHl.Aspect()->SetDistinguish (false);
|
||||
myAspectFaceHl.SetNoLighting();
|
||||
myAspectFaceSet = &myAspectFaceHl;
|
||||
}
|
||||
|
@ -29,6 +29,19 @@
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Drawer, Graphic3d_PresentationAttributes)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const Quantity_NameOfColor THE_DEF_COLOR_FreeBoundary = Quantity_NOC_GREEN;
|
||||
static const Quantity_NameOfColor THE_DEF_COLOR_UnFreeBoundary = Quantity_NOC_YELLOW;
|
||||
static const Quantity_NameOfColor THE_DEF_COLOR_FaceBoundary = Quantity_NOC_BLACK;
|
||||
static const Quantity_NameOfColor THE_DEF_COLOR_Wire = Quantity_NOC_RED;
|
||||
static const Quantity_NameOfColor THE_DEF_COLOR_Line = Quantity_NOC_YELLOW;
|
||||
static const Quantity_NameOfColor THE_DEF_COLOR_SeenLine = Quantity_NOC_YELLOW;
|
||||
static const Quantity_NameOfColor THE_DEF_COLOR_HiddenLine = Quantity_NOC_YELLOW;
|
||||
static const Quantity_NameOfColor THE_DEF_COLOR_Vector = Quantity_NOC_SKYBLUE;
|
||||
static const Quantity_NameOfColor THE_DEF_COLOR_Section = Quantity_NOC_ORANGE;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Prs3d_Drawer
|
||||
// purpose :
|
||||
@ -270,7 +283,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FreeBoundaryAspect()
|
||||
}
|
||||
if (myFreeBoundaryAspect.IsNull())
|
||||
{
|
||||
myFreeBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1.0);
|
||||
myFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FreeBoundary, Aspect_TOL_SOLID, 1.0);
|
||||
}
|
||||
}
|
||||
return myFreeBoundaryAspect;
|
||||
@ -313,7 +326,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::UnFreeBoundaryAspect()
|
||||
}
|
||||
if (myUnFreeBoundaryAspect.IsNull())
|
||||
{
|
||||
myUnFreeBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
|
||||
myUnFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_UnFreeBoundary, Aspect_TOL_SOLID, 1.0);
|
||||
}
|
||||
}
|
||||
return myUnFreeBoundaryAspect;
|
||||
@ -356,7 +369,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FaceBoundaryAspect()
|
||||
}
|
||||
if (myFaceBoundaryAspect.IsNull())
|
||||
{
|
||||
myFaceBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0);
|
||||
myFaceBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FaceBoundary, Aspect_TOL_SOLID, 1.0);
|
||||
}
|
||||
}
|
||||
return myFaceBoundaryAspect;
|
||||
@ -539,7 +552,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::WireAspect()
|
||||
}
|
||||
if (myWireAspect.IsNull())
|
||||
{
|
||||
myWireAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
|
||||
myWireAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Wire, Aspect_TOL_SOLID, 1.0);
|
||||
}
|
||||
}
|
||||
return myWireAspect;
|
||||
@ -588,6 +601,30 @@ const Handle(Prs3d_PointAspect)& Prs3d_Drawer::PointAspect()
|
||||
return myPointAspect;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetupOwnPointAspect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Prs3d_Drawer::SetupOwnPointAspect (const Handle(Prs3d_Drawer)& theDefaults)
|
||||
{
|
||||
if (myHasOwnPointAspect)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
|
||||
if (!theDefaults.IsNull() && theDefaults != this)
|
||||
{
|
||||
*myPointAspect->Aspect() = *theDefaults->PointAspect()->Aspect();
|
||||
}
|
||||
else if (!myLink.IsNull())
|
||||
{
|
||||
*myPointAspect->Aspect() = *myLink->PointAspect()->Aspect();
|
||||
}
|
||||
myHasOwnPointAspect = Standard_True;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetPointAspect
|
||||
// purpose :
|
||||
@ -614,7 +651,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::LineAspect()
|
||||
}
|
||||
if (myLineAspect.IsNull())
|
||||
{
|
||||
myLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
|
||||
myLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Line, Aspect_TOL_SOLID, 1.0);
|
||||
}
|
||||
}
|
||||
return myLineAspect;
|
||||
@ -684,6 +721,30 @@ const Handle(Prs3d_ShadingAspect)& Prs3d_Drawer::ShadingAspect()
|
||||
return myShadingAspect;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetupOwnShadingAspect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Prs3d_Drawer::SetupOwnShadingAspect (const Handle(Prs3d_Drawer)& theDefaults)
|
||||
{
|
||||
if (myHasOwnShadingAspect)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myShadingAspect = new Prs3d_ShadingAspect();
|
||||
if (!theDefaults.IsNull() && theDefaults != this)
|
||||
{
|
||||
*myShadingAspect->Aspect() = *theDefaults->ShadingAspect()->Aspect();
|
||||
}
|
||||
else if (!myLink.IsNull())
|
||||
{
|
||||
*myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
|
||||
}
|
||||
myHasOwnShadingAspect = Standard_True;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetShadingAspect
|
||||
// purpose :
|
||||
@ -742,7 +803,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SeenLineAspect()
|
||||
}
|
||||
if (mySeenLineAspect.IsNull())
|
||||
{
|
||||
mySeenLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
|
||||
mySeenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_SeenLine, Aspect_TOL_SOLID, 1.0);
|
||||
}
|
||||
}
|
||||
return mySeenLineAspect;
|
||||
@ -817,7 +878,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::HiddenLineAspect()
|
||||
}
|
||||
if (myHiddenLineAspect.IsNull())
|
||||
{
|
||||
myHiddenLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_DASH, 1.0);
|
||||
myHiddenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_HiddenLine, Aspect_TOL_DASH, 1.0);
|
||||
}
|
||||
}
|
||||
return myHiddenLineAspect;
|
||||
@ -871,7 +932,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::VectorAspect()
|
||||
}
|
||||
if (myVectorAspect.IsNull())
|
||||
{
|
||||
myVectorAspect = new Prs3d_LineAspect (Quantity_NOC_SKYBLUE, Aspect_TOL_SOLID, 1.0);
|
||||
myVectorAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Vector, Aspect_TOL_SOLID, 1.0);
|
||||
}
|
||||
}
|
||||
return myVectorAspect;
|
||||
@ -966,7 +1027,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SectionAspect()
|
||||
}
|
||||
if (mySectionAspect.IsNull())
|
||||
{
|
||||
mySectionAspect = new Prs3d_LineAspect (Quantity_NOC_ORANGE, Aspect_TOL_SOLID, 1.0);
|
||||
mySectionAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Section, Aspect_TOL_SOLID, 1.0);
|
||||
}
|
||||
}
|
||||
return mySectionAspect;
|
||||
@ -1059,17 +1120,156 @@ void Prs3d_Drawer::ClearLocalAttributes()
|
||||
myTypeOfHLR = Prs3d_TOH_NotSet;
|
||||
}
|
||||
|
||||
//! Copy line aspect defaults from the Link.
|
||||
inline void copyLineAspect (const Handle(Prs3d_Drawer)& theLink,
|
||||
Handle(Prs3d_LineAspect)& theAspect,
|
||||
const Handle(Prs3d_LineAspect)& theBaseAspect)
|
||||
// =======================================================================
|
||||
// function : SetOwnLineAspects
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Prs3d_Drawer::SetOwnLineAspects (const Handle(Prs3d_Drawer)& theDefaults)
|
||||
{
|
||||
Handle(Prs3d_LineAspect) aBaseAspect = theBaseAspect;
|
||||
if (!theLink.IsNull())
|
||||
bool isUpdateNeeded = false;
|
||||
const Handle(Prs3d_Drawer)& aLink = (!theDefaults.IsNull() && theDefaults != this) ? theDefaults : myLink;
|
||||
if (!myHasOwnUIsoAspect)
|
||||
{
|
||||
theAspect = new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0);
|
||||
*theAspect->Aspect() = *aBaseAspect->Aspect();
|
||||
isUpdateNeeded = true;
|
||||
myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
|
||||
if (!aLink.IsNull())
|
||||
{
|
||||
*myUIsoAspect->Aspect() = *aLink->UIsoAspect()->Aspect();
|
||||
myUIsoAspect->SetNumber (aLink->UIsoAspect()->Number());
|
||||
}
|
||||
myHasOwnUIsoAspect = true;
|
||||
}
|
||||
if (!myHasOwnVIsoAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
|
||||
if (!aLink.IsNull())
|
||||
{
|
||||
*myVIsoAspect->Aspect() = *aLink->VIsoAspect()->Aspect();
|
||||
myUIsoAspect->SetNumber (aLink->VIsoAspect()->Number());
|
||||
}
|
||||
myHasOwnVIsoAspect = true;
|
||||
}
|
||||
if (!myHasOwnWireAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myWireAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Wire, Aspect_TOL_SOLID, 1.0);
|
||||
myHasOwnWireAspect = true;
|
||||
if (!aLink.IsNull())
|
||||
{
|
||||
*myWireAspect->Aspect() = *aLink->WireAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!myHasOwnLineAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Line, Aspect_TOL_SOLID, 1.0);
|
||||
myHasOwnLineAspect = true;
|
||||
if (!aLink.IsNull())
|
||||
{
|
||||
*myLineAspect->Aspect() = *aLink->LineAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!myHasOwnSeenLineAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
mySeenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_SeenLine, Aspect_TOL_SOLID, 1.0);
|
||||
myHasOwnSeenLineAspect = true;
|
||||
if (!aLink.IsNull())
|
||||
{
|
||||
*mySeenLineAspect->Aspect() = *aLink->SeenLineAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!myHasOwnHiddenLineAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myHiddenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_HiddenLine, Aspect_TOL_DASH, 1.0);
|
||||
myHasOwnHiddenLineAspect = true;
|
||||
if (!aLink.IsNull())
|
||||
{
|
||||
*myHiddenLineAspect->Aspect() = *aLink->HiddenLineAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!myHasOwnFreeBoundaryAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FreeBoundary, Aspect_TOL_SOLID, 1.0);
|
||||
myHasOwnFreeBoundaryAspect = true;
|
||||
if (!aLink.IsNull())
|
||||
{
|
||||
*myFreeBoundaryAspect->Aspect() = *aLink->FreeBoundaryAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!myHasOwnUnFreeBoundaryAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myUnFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_UnFreeBoundary, Aspect_TOL_SOLID, 1.0);
|
||||
myHasOwnUnFreeBoundaryAspect = true;
|
||||
if (!aLink.IsNull())
|
||||
{
|
||||
*myUnFreeBoundaryAspect->Aspect() = *aLink->UnFreeBoundaryAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!myHasOwnFaceBoundaryAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myFaceBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FaceBoundary, Aspect_TOL_SOLID, 1.0);
|
||||
myHasOwnFaceBoundaryAspect = true;
|
||||
if (!aLink.IsNull())
|
||||
{
|
||||
*myFaceBoundaryAspect->Aspect() = *aLink->FaceBoundaryAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
return isUpdateNeeded;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetOwnDatumAspects
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Prs3d_Drawer::SetOwnDatumAspects (const Handle(Prs3d_Drawer)& theDefaults)
|
||||
{
|
||||
bool isUpdateNeeded = false;
|
||||
const Handle(Prs3d_Drawer)& aLink = (!theDefaults.IsNull() && theDefaults != this) ? theDefaults : myLink;
|
||||
if (!myHasOwnVectorAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myVectorAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Vector, Aspect_TOL_SOLID, 1.0);
|
||||
myHasOwnVectorAspect = true;
|
||||
if (!aLink.IsNull())
|
||||
{
|
||||
*myVectorAspect->Aspect() = *aLink->VectorAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!myHasOwnSectionAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
mySectionAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Section, Aspect_TOL_SOLID, 1.0);
|
||||
myHasOwnSectionAspect = true;
|
||||
if (!aLink.IsNull())
|
||||
{
|
||||
*mySectionAspect->Aspect() = *aLink->SectionAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!myHasOwnPlaneAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myPlaneAspect = new Prs3d_PlaneAspect();
|
||||
myHasOwnPlaneAspect = true;
|
||||
}
|
||||
if (!myHasOwnArrowAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myArrowAspect = new Prs3d_ArrowAspect();
|
||||
myHasOwnArrowAspect = true;
|
||||
}
|
||||
if (!myHasOwnDatumAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myDatumAspect = new Prs3d_DatumAspect();
|
||||
myHasOwnDatumAspect = true;
|
||||
}
|
||||
return isUpdateNeeded;
|
||||
}
|
||||
|
||||
//! Assign the shader program.
|
||||
@ -1100,103 +1300,8 @@ bool Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
|
||||
{
|
||||
if (theToOverrideDefaults)
|
||||
{
|
||||
if (!myHasOwnUIsoAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
Handle(Prs3d_IsoAspect) anAspect = UIsoAspect();
|
||||
if (!myLink.IsNull())
|
||||
{
|
||||
myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
|
||||
*myUIsoAspect->Aspect() = *anAspect->Aspect();
|
||||
myUIsoAspect->SetNumber (anAspect->Number());
|
||||
}
|
||||
myHasOwnUIsoAspect = true;
|
||||
}
|
||||
if (!myHasOwnVIsoAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
Handle(Prs3d_IsoAspect) anAspect = VIsoAspect();
|
||||
if (!myLink.IsNull())
|
||||
{
|
||||
myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
|
||||
*myVIsoAspect->Aspect() = *anAspect->Aspect();
|
||||
myUIsoAspect->SetNumber (anAspect->Number());
|
||||
}
|
||||
myHasOwnVIsoAspect = true;
|
||||
}
|
||||
if (!myHasOwnWireAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
copyLineAspect (myLink, myWireAspect, WireAspect());
|
||||
myHasOwnWireAspect = true;
|
||||
}
|
||||
if (!myHasOwnLineAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
copyLineAspect (myLink, myLineAspect, LineAspect());
|
||||
myHasOwnLineAspect = true;
|
||||
}
|
||||
if (!myHasOwnSeenLineAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
copyLineAspect (myLink, mySeenLineAspect, SeenLineAspect());
|
||||
myHasOwnSeenLineAspect = true;
|
||||
}
|
||||
if (!myHasOwnHiddenLineAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
copyLineAspect (myLink, myHiddenLineAspect, HiddenLineAspect());
|
||||
myHasOwnHiddenLineAspect = true;
|
||||
}
|
||||
if (!myHasOwnVectorAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
copyLineAspect (myLink, myVectorAspect, VectorAspect());
|
||||
myHasOwnVectorAspect = true;
|
||||
}
|
||||
if (!myHasOwnSectionAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
copyLineAspect (myLink, mySectionAspect, SectionAspect());
|
||||
myHasOwnSectionAspect = true;
|
||||
}
|
||||
if (!myHasOwnFreeBoundaryAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
copyLineAspect (myLink, myFreeBoundaryAspect, FreeBoundaryAspect());
|
||||
myHasOwnFreeBoundaryAspect = true;
|
||||
}
|
||||
if (!myHasOwnUnFreeBoundaryAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
copyLineAspect (myLink, myUnFreeBoundaryAspect, UnFreeBoundaryAspect());
|
||||
myHasOwnUnFreeBoundaryAspect = true;
|
||||
}
|
||||
if (!myHasOwnFaceBoundaryAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
copyLineAspect (myLink, myFaceBoundaryAspect, FaceBoundaryAspect());
|
||||
myHasOwnFaceBoundaryAspect = true;
|
||||
}
|
||||
|
||||
if (!myHasOwnPlaneAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myPlaneAspect = new Prs3d_PlaneAspect();
|
||||
myHasOwnPlaneAspect = true;
|
||||
}
|
||||
if (!myHasOwnArrowAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myArrowAspect = new Prs3d_ArrowAspect();
|
||||
myHasOwnArrowAspect = true;
|
||||
}
|
||||
if (!myHasOwnDatumAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myDatumAspect = new Prs3d_DatumAspect();
|
||||
myHasOwnDatumAspect = true;
|
||||
}
|
||||
isUpdateNeeded = SetOwnLineAspects() || isUpdateNeeded;
|
||||
isUpdateNeeded = SetOwnDatumAspects() || isUpdateNeeded;
|
||||
}
|
||||
|
||||
setAspectProgram (theProgram, myHasOwnUIsoAspect, myUIsoAspect);
|
||||
@ -1245,15 +1350,9 @@ bool Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
|
||||
case Graphic3d_ASPECT_MARKER:
|
||||
{
|
||||
if (theToOverrideDefaults
|
||||
&& !myHasOwnPointAspect)
|
||||
&& SetupOwnPointAspect())
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
|
||||
myHasOwnPointAspect = true;
|
||||
if (!myLink.IsNull())
|
||||
{
|
||||
*myPointAspect->Aspect() = *myLink->PointAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
|
||||
setAspectProgram (theProgram, myHasOwnPointAspect, myPointAspect);
|
||||
@ -1262,15 +1361,9 @@ bool Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
|
||||
case Graphic3d_ASPECT_FILL_AREA:
|
||||
{
|
||||
if (theToOverrideDefaults
|
||||
&& !myHasOwnShadingAspect)
|
||||
&& SetupOwnShadingAspect())
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myShadingAspect = new Prs3d_ShadingAspect();
|
||||
myHasOwnShadingAspect = true;
|
||||
if (!myLink.IsNull())
|
||||
{
|
||||
*myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
setAspectProgram (theProgram, myHasOwnShadingAspect, myShadingAspect);
|
||||
return isUpdateNeeded;
|
||||
@ -1289,15 +1382,9 @@ bool Prs3d_Drawer::SetShadingModel (Graphic3d_TypeOfShadingModel theModel,
|
||||
bool isUpdateNeeded = false;
|
||||
|
||||
if (theToOverrideDefaults
|
||||
&& !myHasOwnShadingAspect)
|
||||
&& SetupOwnShadingAspect())
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myShadingAspect = new Prs3d_ShadingAspect();
|
||||
myHasOwnShadingAspect = true;
|
||||
if (!myLink.IsNull())
|
||||
{
|
||||
*myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
|
||||
if (!myShadingAspect.IsNull()
|
||||
|
@ -439,6 +439,10 @@ public:
|
||||
//! point aspect that overrides the one in the link.
|
||||
Standard_Boolean HasOwnPointAspect() const { return myHasOwnPointAspect; }
|
||||
|
||||
//! Sets own point aspect.
|
||||
//! Returns FALSE if the drawer already has its own attribute for point aspect.
|
||||
Standard_EXPORT Standard_Boolean SetupOwnPointAspect (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
|
||||
|
||||
//! Returns settings for line aspects.
|
||||
//! These settings can be edited. The default values are:
|
||||
//! Color: Quantity_NOC_YELLOW
|
||||
@ -457,6 +461,14 @@ public:
|
||||
//! line aspect that overrides the one in the link.
|
||||
Standard_Boolean HasOwnLineAspect() const { return myHasOwnLineAspect; }
|
||||
|
||||
//! Sets own line aspects.
|
||||
//! Returns FALSE if own line aspect are already set.
|
||||
Standard_EXPORT Standard_Boolean SetOwnLineAspects (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
|
||||
|
||||
//! Sets own line aspects for datums.
|
||||
//! Returns FALSE if own line for datums are already set.
|
||||
Standard_EXPORT Standard_Boolean SetOwnDatumAspects (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
|
||||
|
||||
//! Returns settings for text aspect.
|
||||
//! These settings can be edited. The default value is:
|
||||
//! - Color: Quantity_NOC_YELLOW
|
||||
@ -487,6 +499,10 @@ public:
|
||||
//! shading aspect that overrides the one in the link.
|
||||
Standard_Boolean HasOwnShadingAspect() const { return myHasOwnShadingAspect; }
|
||||
|
||||
//! Sets own shading aspect.
|
||||
//! Returns FALSE if the drawer already has its own attribute for shading aspect.
|
||||
Standard_EXPORT Standard_Boolean SetupOwnShadingAspect (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
|
||||
|
||||
//! Returns settings for seen line aspects.
|
||||
//! These settings can be edited. The default values are:
|
||||
//! Color: Quantity_NOC_YELLOW
|
||||
|
@ -3,7 +3,6 @@ QABugs.hxx
|
||||
QABugs_1.cxx
|
||||
QABugs_2.cxx
|
||||
QABugs_3.cxx
|
||||
QABugs_4.cxx
|
||||
QABugs_5.cxx
|
||||
QABugs_6.cxx
|
||||
QABugs_7.cxx
|
||||
|
@ -19,7 +19,6 @@ void QABugs::Commands(Draw_Interpretor& theCommands) {
|
||||
QABugs::Commands_1(theCommands);
|
||||
QABugs::Commands_2(theCommands);
|
||||
QABugs::Commands_3(theCommands);
|
||||
QABugs::Commands_4(theCommands);
|
||||
QABugs::Commands_5(theCommands);
|
||||
QABugs::Commands_6(theCommands);
|
||||
QABugs::Commands_7(theCommands);
|
||||
|
@ -40,9 +40,7 @@ public:
|
||||
Standard_EXPORT static void Commands_2 (Draw_Interpretor& DI);
|
||||
|
||||
Standard_EXPORT static void Commands_3 (Draw_Interpretor& DI);
|
||||
|
||||
Standard_EXPORT static void Commands_4 (Draw_Interpretor& DI);
|
||||
|
||||
|
||||
Standard_EXPORT static void Commands_5 (Draw_Interpretor& DI);
|
||||
|
||||
Standard_EXPORT static void Commands_6 (Draw_Interpretor& DI);
|
||||
|
@ -1,77 +0,0 @@
|
||||
// Created on: 2002-03-19
|
||||
// Created by: QA Admin
|
||||
// Copyright (c) 2002-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <QABugs.hxx>
|
||||
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <DBRep.hxx>
|
||||
#include <DrawTrSurf.hxx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <ViewerTest.hxx>
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
#include <BRepPrimAPI_MakeSphere.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
|
||||
//#include <AcisData_AcisModel.hxx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
|
||||
static Standard_Integer BUC60738 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
|
||||
{
|
||||
|
||||
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
|
||||
if(aContext.IsNull()) {
|
||||
di << "use 'vinit' command before " << argv[0] << "\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(-40,0,0),20).Shape();
|
||||
Handle(AIS_Shape) theAISShape = new AIS_Shape(theSphere);
|
||||
|
||||
//display mode = Shading
|
||||
theAISShape->SetDisplayMode(1);
|
||||
|
||||
//get the drawer
|
||||
Handle(Prs3d_Drawer) theDrawer = theAISShape->Attributes();
|
||||
Handle(Prs3d_ShadingAspect) theShadingAspect = theDrawer->ShadingAspect();
|
||||
Handle(Graphic3d_AspectFillArea3d) theAspectFillArea3d = theShadingAspect->Aspect();
|
||||
|
||||
//allow to display the edges
|
||||
theAspectFillArea3d->SetEdgeOn();
|
||||
//set the style to Dash
|
||||
|
||||
//but the style is not set to dash : it is always solid
|
||||
theAspectFillArea3d->SetEdgeLineType (Aspect_TOL_DASH);
|
||||
theAspectFillArea3d->SetEdgeColor(Quantity_Color(Quantity_NOC_GREEN));
|
||||
theAspectFillArea3d->SetInteriorStyle(Aspect_IS_EMPTY);
|
||||
theShadingAspect->SetAspect(theAspectFillArea3d);
|
||||
theDrawer->SetShadingAspect(theShadingAspect);
|
||||
theAISShape->SetAttributes(theDrawer);
|
||||
|
||||
aContext->Display (theAISShape, Standard_True);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QABugs::Commands_4(Draw_Interpretor& theCommands) {
|
||||
const char *group = "QABugs";
|
||||
|
||||
theCommands.Add("BUC60738","BUC60738",__FILE__,BUC60738,group);
|
||||
|
||||
return;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -28,7 +28,7 @@
|
||||
#include <TColStd_HArray1OfTransient.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <TopTools_HArray1OfShape.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <Quantity_ColorRGBA.hxx>
|
||||
|
||||
class AIS_InteractiveContext;
|
||||
class AIS_InteractiveObject;
|
||||
@ -152,14 +152,32 @@ public:
|
||||
|
||||
Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name);
|
||||
|
||||
//! Parses color argument(s) specified within theArgVec[0], theArgVec[1] and theArgVec[2].
|
||||
//! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3].
|
||||
//! Handles either color specified by name (single argument)
|
||||
//! or by RGB components (3 arguments) in range 0..1.
|
||||
//! or by RGB(A) components (3-4 arguments) in range 0..1.
|
||||
//! The result is stored in theColor on success.
|
||||
//! Returns number of handled arguments (1, 3 or 4) or 0 on syntax error.
|
||||
static Standard_Integer ParseColor (Standard_Integer theArgNb,
|
||||
const char** theArgVec,
|
||||
Quantity_ColorRGBA& theColor)
|
||||
{
|
||||
return parseColor (theArgNb, theArgVec, theColor, true);
|
||||
}
|
||||
|
||||
//! Parses RGB color argument(s).
|
||||
//! Returns number of handled arguments (1 or 3) or 0 on syntax error.
|
||||
Standard_EXPORT static Standard_Integer ParseColor (Standard_Integer theArgNb,
|
||||
const char** theArgVec,
|
||||
Quantity_Color& theColor);
|
||||
static Standard_Integer ParseColor (Standard_Integer theArgNb,
|
||||
const char** theArgVec,
|
||||
Quantity_Color& theColor)
|
||||
{
|
||||
Quantity_ColorRGBA anRgba;
|
||||
Standard_Integer aNbParsed = parseColor (theArgNb, theArgVec, anRgba, false);
|
||||
if (aNbParsed != 0)
|
||||
{
|
||||
theColor = anRgba.GetRGB();
|
||||
}
|
||||
return aNbParsed;
|
||||
}
|
||||
|
||||
//! redraws all defined views.
|
||||
Standard_EXPORT static void RedrawAllViews();
|
||||
@ -197,6 +215,16 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
//! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3].
|
||||
//! Handles either color specified by name (single argument)
|
||||
//! or by RGB(A) components (3-4 arguments) in range 0..1.
|
||||
//! The result is stored in theColor on success.
|
||||
//! Returns number of handled arguments (1, 3 or 4) or 0 on syntax error.
|
||||
Standard_EXPORT static Standard_Integer parseColor (Standard_Integer theArgNb,
|
||||
const char** theArgVec,
|
||||
Quantity_ColorRGBA& theColor,
|
||||
bool theToParseAlpha);
|
||||
|
||||
//! Returns a window class that implements standard behavior of
|
||||
//! all windows of the ViewerTest. This includes usual Open CASCADE
|
||||
//! view conventions for mouse buttons (e.g. Ctrl+MB1 for zoom,
|
||||
|
@ -3031,14 +3031,7 @@ static int VDrawSphere (Draw_Interpretor& /*di*/, Standard_Integer argc, const c
|
||||
aMat,
|
||||
aMat);
|
||||
Handle(Prs3d_ShadingAspect) aShAsp = new Prs3d_ShadingAspect();
|
||||
if (toShowEdges)
|
||||
{
|
||||
anAspect->SetEdgeOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
anAspect->SetEdgeOff();
|
||||
}
|
||||
anAspect->SetDrawEdges (toShowEdges);
|
||||
aShAsp->SetAspect (anAspect);
|
||||
aShape->Attributes()->SetShadingAspect (aShAsp);
|
||||
|
||||
@ -5562,177 +5555,6 @@ static int VFont (Draw_Interpretor& theDI,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VSetEdgeType
|
||||
//purpose : Edges type management
|
||||
//=======================================================================
|
||||
|
||||
static int VSetEdgeType (Draw_Interpretor& theDI,
|
||||
Standard_Integer theArgNum,
|
||||
const char** theArgs)
|
||||
{
|
||||
if (theArgNum < 4 || theArgNum > 9)
|
||||
{
|
||||
theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
|
||||
<< theArgs[0] << "' for more information.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Boolean isForceRedisplay = Standard_False;
|
||||
|
||||
// Get shape name
|
||||
TCollection_AsciiString aName(theArgs[1]);
|
||||
Handle(AIS_InteractiveObject) anObject;
|
||||
if (!GetMapOfAIS().Find2 (aName, anObject))
|
||||
{
|
||||
theDI << theArgs[0] << " error: wrong object name.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Enable triangle edge mode
|
||||
if (!anObject->Attributes()->HasOwnShadingAspect())
|
||||
{
|
||||
anObject->Attributes()->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
*anObject->Attributes()->ShadingAspect()->Aspect() = *anObject->Attributes()->Link()->ShadingAspect()->Aspect();
|
||||
}
|
||||
const Handle(Prs3d_ShadingAspect)& aFillAreaAspect = anObject->Attributes()->ShadingAspect();
|
||||
aFillAreaAspect->Aspect()->SetEdgeOn();
|
||||
|
||||
// Parse parameters
|
||||
for (Standard_Integer anIt = 2; anIt < theArgNum; ++anIt)
|
||||
{
|
||||
TCollection_AsciiString aParam ((theArgs[anIt]));
|
||||
if (aParam.Value (1) == '-' && !aParam.IsRealValue())
|
||||
{
|
||||
if (aParam.IsEqual ("-type"))
|
||||
{
|
||||
if (theArgNum <= anIt + 1)
|
||||
{
|
||||
theDI << theArgs[0] << " error: wrong number of values for parameter '"
|
||||
<< aParam.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
++anIt;
|
||||
Aspect_TypeOfLine aTypeEnum = Aspect_TOL_SOLID;
|
||||
if (!ViewerTest::ParseLineType (theArgs[anIt], aTypeEnum))
|
||||
{
|
||||
std::cout << "Syntax error: wrong line type: '" << theArgs[anIt] << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType (aTypeEnum);
|
||||
}
|
||||
else if (aParam.IsEqual ("-color"))
|
||||
{
|
||||
if (theArgNum <= anIt + 3)
|
||||
{
|
||||
theDI << theArgs[0] << " error: wrong number of values for parameter '"
|
||||
<< aParam.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Real aR = Draw::Atof(theArgs[++anIt]);
|
||||
Standard_Real aG = Draw::Atof(theArgs[++anIt]);
|
||||
Standard_Real aB = Draw::Atof(theArgs[++anIt]);
|
||||
Quantity_Color aColor = Quantity_Color (aR > 1 ? aR / 255.0 : aR,
|
||||
aG > 1 ? aG / 255.0 : aG,
|
||||
aB > 1 ? aB / 255.0 : aB,
|
||||
Quantity_TOC_RGB);
|
||||
|
||||
aFillAreaAspect->Aspect()->SetEdgeColor (aColor);
|
||||
}
|
||||
else if (aParam.IsEqual ("-force"))
|
||||
{
|
||||
isForceRedisplay = Standard_True;
|
||||
}
|
||||
else
|
||||
{
|
||||
theDI << theArgs[0] << " error: unknown parameter '"
|
||||
<< aParam.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update shape presentation as aspect parameters were changed
|
||||
if (isForceRedisplay)
|
||||
{
|
||||
ViewerTest::GetAISContext()->Redisplay (anObject, Standard_False);
|
||||
}
|
||||
else
|
||||
{
|
||||
anObject->SetAspect (aFillAreaAspect);
|
||||
}
|
||||
|
||||
//Update view
|
||||
ViewerTest::CurrentView()->Redraw();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VUnsetEdgeType
|
||||
//purpose : Unsets edges visibility in shading mode
|
||||
//=======================================================================
|
||||
|
||||
static int VUnsetEdgeType (Draw_Interpretor& theDI,
|
||||
Standard_Integer theArgNum,
|
||||
const char** theArgs)
|
||||
{
|
||||
if (theArgNum != 2 && theArgNum != 3)
|
||||
{
|
||||
theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
|
||||
<< theArgs[0] << "' for more information.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Boolean isForceRedisplay = Standard_False;
|
||||
|
||||
// Get shape name
|
||||
TCollection_AsciiString aName (theArgs[1]);
|
||||
Handle(AIS_InteractiveObject) anObject;
|
||||
if (!GetMapOfAIS().Find2 (aName, anObject))
|
||||
{
|
||||
theDI << theArgs[0] << " error: wrong object name.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Enable trianle edge mode
|
||||
anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeOff();
|
||||
|
||||
// Parse parameters
|
||||
if (theArgNum == 3)
|
||||
{
|
||||
TCollection_AsciiString aParam ((theArgs[2]));
|
||||
if (aParam.IsEqual ("-force"))
|
||||
{
|
||||
isForceRedisplay = Standard_True;
|
||||
}
|
||||
else
|
||||
{
|
||||
theDI << theArgs[0] << " error: unknown parameter '"
|
||||
<< aParam.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Update shape presentation as aspect parameters were changed
|
||||
if (isForceRedisplay)
|
||||
{
|
||||
ViewerTest::GetAISContext()->Redisplay (anObject, Standard_False);
|
||||
}
|
||||
else
|
||||
{
|
||||
anObject->SetAspect (anObject->Attributes()->ShadingAspect());
|
||||
}
|
||||
|
||||
//Update view
|
||||
ViewerTest::CurrentView()->Redraw();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : VVertexMode
|
||||
//purpose : Switches vertex display mode for AIS_Shape or displays the current value
|
||||
@ -6639,18 +6461,6 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
|
||||
"vfont [-add pathToFont [fontName] [regular,bold,italic,boldItalic=undefined] [singleStroke]]"
|
||||
"\n\t\t: [-find fontName [regular,bold,italic,boldItalic=undefined]] [-verbose {on|off}]",
|
||||
__FILE__, VFont, group);
|
||||
|
||||
theCommands.Add ("vsetedgetype",
|
||||
"vsetedgetype usage:\n"
|
||||
"vsetedgetype ShapeName [-force] [-type {solid, dash, dot}] [-color R G B] "
|
||||
"\n\t\t: Sets edges type and color for input shape",
|
||||
__FILE__, VSetEdgeType, group);
|
||||
|
||||
theCommands.Add ("vunsetedgetype",
|
||||
"vunsetedgetype usage:\n"
|
||||
"vunsetedgetype ShapeName [-force]"
|
||||
"\n\t\t: Unsets edges type and color for input shape",
|
||||
__FILE__, VUnsetEdgeType, group);
|
||||
|
||||
theCommands.Add ("vvertexmode",
|
||||
"vvertexmode [name | -set {isolated | all | inherited} [name1 name2 ...]]\n"
|
||||
|
@ -5923,6 +5923,7 @@ static int VCaps (Draw_Interpretor& theDI,
|
||||
theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
|
||||
theDI << "SoftMode:" << (aCaps->contextNoAccel ? "1" : "0") << "\n";
|
||||
theDI << "FFP: " << (aCaps->ffpEnable ? "1" : "0") << "\n";
|
||||
theDI << "PolygonMode: " << (aCaps->usePolygonMode ? "1" : "0") << "\n";
|
||||
theDI << "VSync: " << aCaps->swapInterval << "\n";
|
||||
theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
|
||||
theDI << "Stereo: " << (aCaps->contextStereo ? "1" : "0") << "\n";
|
||||
@ -5961,6 +5962,16 @@ static int VCaps (Draw_Interpretor& theDI,
|
||||
}
|
||||
aCaps->ffpEnable = toEnable;
|
||||
}
|
||||
else if (anArgCase == "-polygonmode")
|
||||
{
|
||||
Standard_Boolean toEnable = Standard_True;
|
||||
if (++anArgIter < theArgNb
|
||||
&& !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
|
||||
{
|
||||
--anArgIter;
|
||||
}
|
||||
aCaps->usePolygonMode = toEnable;
|
||||
}
|
||||
else if (anArgCase == "-vbo")
|
||||
{
|
||||
Standard_Boolean toEnable = Standard_True;
|
||||
@ -10566,6 +10577,30 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
|
||||
aParams.NbMsaaSamples = aNbSamples;
|
||||
}
|
||||
}
|
||||
else if (aFlag == "-linefeather"
|
||||
|| aFlag == "-edgefeather"
|
||||
|| aFlag == "-feather")
|
||||
{
|
||||
if (toPrint)
|
||||
{
|
||||
theDI << " " << aParams.LineFeather << " ";
|
||||
continue;
|
||||
}
|
||||
else if (++anArgIter >= theArgNb)
|
||||
{
|
||||
std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aParam = theArgVec[anArgIter];
|
||||
const Standard_ShortReal aFeather = (Standard_ShortReal) Draw::Atof (theArgVec[anArgIter]);
|
||||
if (aFeather <= 0.0f)
|
||||
{
|
||||
std::cerr << "Error: invalid value of line width feather " << aFeather << ". Should be > 0\n";
|
||||
return 1;
|
||||
}
|
||||
aParams.LineFeather = aFeather;
|
||||
}
|
||||
else if (aFlag == "-oit")
|
||||
{
|
||||
if (toPrint)
|
||||
@ -12590,7 +12625,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: greenMagentaSimple",
|
||||
__FILE__, VStereo, group);
|
||||
theCommands.Add ("vcaps",
|
||||
"vcaps [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}]"
|
||||
"vcaps [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}] [-polygonMode {0|1}]"
|
||||
"\n\t\t: [-compatibleProfile {0|1}]"
|
||||
"\n\t\t: [-vsync {0|1}] [-useWinBuffer {0|1}]"
|
||||
"\n\t\t: [-quadBuffer {0|1}] [-stereo {0|1}]"
|
||||
@ -12599,6 +12634,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: FFP - use fixed-function pipeline instead of"
|
||||
"\n\t\t: built-in GLSL programs"
|
||||
"\n\t\t: (requires compatible profile)"
|
||||
"\n\t\t: polygonMode - use Polygon Mode instead of built-in GLSL programs"
|
||||
"\n\t\t: VBO - use Vertex Buffer Object (copy vertex"
|
||||
"\n\t\t: arrays to GPU memory)"
|
||||
"\n\t\t: sprite - use textured sprites instead of bitmaps"
|
||||
@ -12893,6 +12929,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n Manages rendering parameters: "
|
||||
"\n '-raster' Disables GPU ray-tracing"
|
||||
"\n '-msaa 0..4' Specifies number of samples for MSAA"
|
||||
"\n '-lineFeather > 0' Sets line feather factor"
|
||||
"\n '-oit off|0.0-1.0' Enables/disables OIT and sets depth weight factor"
|
||||
"\n '-depthPrePass on|off' Enables/disables depth pre-pass"
|
||||
"\n '-alphatocoverage on|off' Enables/disables alpha to coverage (needs MSAA)"
|
||||
|
@ -10,11 +10,12 @@ bcut result sp b1
|
||||
trotate result 0 0 0 1 0 0 45
|
||||
incmesh result 0.1
|
||||
|
||||
vinit
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
vdefaults -autoTriang 0
|
||||
vdisplay result
|
||||
vsetinteriorstyle 1
|
||||
vsetdispmode 1
|
||||
vdisplay -dispMode 1 result
|
||||
vaspects result -setInteriorStyle HOLLOW -setDrawEdges 1
|
||||
vfit
|
||||
|
||||
set log [tricheck result]
|
||||
|
@ -2,23 +2,17 @@ puts "========================"
|
||||
puts "BUC60738"
|
||||
puts "========================"
|
||||
puts ""
|
||||
puts "=================================="
|
||||
puts "It takes visual check for this BUG"
|
||||
puts "=================================="
|
||||
|
||||
vinit
|
||||
BUC60738
|
||||
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
|
||||
psphere s 20
|
||||
ttranslate s -40 0 0
|
||||
vdisplay -dispMode 1 s
|
||||
vfit
|
||||
vsetdispmode 1
|
||||
vaspects s -setInteriorStyle HOLLOW -setDrawEdges 1 -setEdgeType DASH -setEdgeColor GREEN
|
||||
|
||||
|
||||
set x_coord 261
|
||||
set y_coord 314
|
||||
|
||||
checkcolor $x_coord $y_coord 0 1 0
|
||||
|
||||
if {$stat != 1} {
|
||||
puts "Error : The style of edge is NOT dash"
|
||||
}
|
||||
|
||||
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
||||
checkcolor 261 314 0 1 0
|
||||
if {$stat != 1} { puts "Error : The style of edge is NOT dash" }
|
||||
vdump $imagedir/${casename}.png
|
||||
|
@ -1,27 +1,18 @@
|
||||
puts "============"
|
||||
puts "OCC23363"
|
||||
puts "0023363: Lost gradient background when switching to the hollow interior style"
|
||||
puts "============"
|
||||
puts ""
|
||||
####################################################################################
|
||||
# [Regression] Lost gradient background when switching to the hollow interior style
|
||||
####################################################################################
|
||||
|
||||
set BugNumber OCC23363
|
||||
|
||||
vinit
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
vsetgradientbg 250 0 0 0 255 0 2
|
||||
pcylinder p 100 200
|
||||
vdisplay p
|
||||
vsetdispmode p 1
|
||||
vsetinteriorstyle p 1
|
||||
vdisplay -dispMode 1 p
|
||||
vaspects p -setInteriorStyle HOLLOW -setDrawEdges 1
|
||||
|
||||
puts ""
|
||||
set color1 [vreadpixel 10 0 rgb]
|
||||
set rd1 [lindex $color1 0]
|
||||
if { $rd1 == 0 } {
|
||||
puts "Faulty ${BugNumber}"
|
||||
} else {
|
||||
puts "OK ${BugNumber}"
|
||||
}
|
||||
if { $rd1 == 0 } { puts "Faulty ${BugNumber}" }
|
||||
|
||||
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
||||
|
@ -7,10 +7,8 @@ vclear
|
||||
vinit View1
|
||||
pload MODELING VISUALIZATION
|
||||
box b 10 10 10
|
||||
vclear
|
||||
vinit View1
|
||||
vdisplay -dispMode 1 b
|
||||
vfit
|
||||
vsetinteriorstyle b 2
|
||||
vaspects b -setInteriorStyle HATCH
|
||||
|
||||
vdump $imagedir/${casename}.png
|
||||
|
@ -1,30 +1,22 @@
|
||||
puts "============"
|
||||
puts "CR6987"
|
||||
puts "0006897: Impossible to change edge line type in 3D View"
|
||||
puts "============"
|
||||
puts ""
|
||||
#######################################################################
|
||||
# Impossible to change edge line type in 3D View
|
||||
#######################################################################
|
||||
|
||||
pload VISUALIZATION
|
||||
pload MODELING VISUALIZATION
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
set anImage3 $imagedir/${casename}_3.png
|
||||
|
||||
vinit
|
||||
box b 1 1 1
|
||||
vdisplay b
|
||||
vdisplay -dispMode 1 b
|
||||
vfit
|
||||
vsetdispmode b 1
|
||||
vsetedgetype b -type DASH -color 10 255 10
|
||||
vdump $anImage1
|
||||
|
||||
vsetinteriorstyle b EMPTY
|
||||
vdump $anImage2
|
||||
|
||||
vsetinteriorstyle b SOLID
|
||||
vunsetedgetype b
|
||||
vdump $anImage3
|
||||
vaspects b -setInteriorStyle SOLID
|
||||
vdump $imagedir/${casename}_3.png
|
||||
|
||||
vaspects b -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeType DASH -setEdgeColor 0.392 1.0 0.392
|
||||
vdump $imagedir/${casename}_1.png
|
||||
|
||||
vaspects b -setInteriorStyle HOLLOW -setDrawEdges 1
|
||||
vdump $imagedir/${casename}_2.png
|
||||
|
@ -1,24 +0,0 @@
|
||||
puts "============"
|
||||
puts "CR6987"
|
||||
puts "============"
|
||||
puts ""
|
||||
##########################################################################
|
||||
# Impossible to change edge line type in 3D View
|
||||
# Tests forced redisplay of object after aspect parameter's been changed
|
||||
##########################################################################
|
||||
|
||||
pload VISUALIZATION
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
|
||||
vinit
|
||||
box b 1 1 1
|
||||
vdisplay b
|
||||
vfit
|
||||
vsetdispmode b 1
|
||||
vsetedgetype b -type DASH -color 10 255 10 -force
|
||||
vdump $anImage1
|
||||
|
||||
vunsetedgetype b -force
|
||||
vdump $anImage2
|
@ -1,8 +1,8 @@
|
||||
cpulimit 300
|
||||
set group "v3d"
|
||||
|
||||
pload VISUALIZATION
|
||||
pload TOPTEST
|
||||
pload VISUALIZATION TOPTEST
|
||||
vgldebug -glslWarn 1
|
||||
|
||||
if { [info exists imagedir] == 0 } {
|
||||
set imagedir .
|
||||
|
@ -31,7 +31,7 @@ vdump $::imagedir/${::casename}_msaa2.png
|
||||
vrenderparams -msaa 2 -alphaToCoverage 1
|
||||
vdump $::imagedir/${::casename}_msaa2_cov.png
|
||||
|
||||
vrenderparams -msaa 8 -alphaToCoverage 1
|
||||
vrenderparams -msaa 8 -alphaToCoverage 0
|
||||
vdump $::imagedir/${::casename}_msaa8.png
|
||||
|
||||
vrenderparams -msaa 8 -alphaToCoverage 1
|
||||
|
72
tests/v3d/glsl/interior1
Normal file
72
tests/v3d/glsl/interior1
Normal file
@ -0,0 +1,72 @@
|
||||
puts "============"
|
||||
puts "0029076: Visualization - implement element shrinking Shader"
|
||||
puts "Test case on spheres"
|
||||
puts "============"
|
||||
puts ""
|
||||
|
||||
pload MODELING VISUALIZATION
|
||||
vclear
|
||||
vclose ALL
|
||||
vinit View1 -width 768 -height 409
|
||||
vdefaults -autoTriang 0
|
||||
vzbufftrihedron
|
||||
psphere s1 2
|
||||
psphere s2 1
|
||||
psphere s3 1
|
||||
psphere s4 1
|
||||
psphere s5 1
|
||||
compound s1 s2 s3 s4 s5 c
|
||||
incmesh c 1.0
|
||||
vdisplay -dispMode 1 s1 s2 s3 s4 s5
|
||||
vsetlocation s2 -1.3 -1.3 1.3
|
||||
vsetlocation s3 1.3 1.3 1.3
|
||||
vsetlocation s4 1.3 -1.3 0.0
|
||||
vsetlocation s5 -1.3 -1.3 -1.3
|
||||
vrotate 0.0 0.5 0.0
|
||||
vrotate 0.4 0.0 0.0
|
||||
vfit
|
||||
|
||||
vaspects s1 -setShadingModel PHONG -setInteriorStyle HOLLOW -setDrawEdges 1 -color GRAY80
|
||||
vdrawtext t1 " s1: phong hollow-edges " -pos 2 0 0 -disptype SUBTITLE -color BLACK -subColor GRAY80
|
||||
|
||||
vaspects s2 -setShadingModel GOURAUD -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor YELLOW
|
||||
vdrawtext t2 " s2: gouraud solid-edges " -pos -1.3 -1.3 2.5 -halign CENTER -disptype SUBTITLE -color BLACK -subColor YELLOW
|
||||
|
||||
vaspects s3 -setShadingModel PHONG -setInteriorStyle SOLID -setDrawEdges 1 -edgeWidth 2 -setEdgeColor BLUE1
|
||||
vdrawtext t3 " s3: phong solid-edges " -pos 1.3 1.3 2.5 -halign CENTER -disptype SUBTITLE -color WHITE -subColor BLUE1
|
||||
|
||||
vaspects s4 -setShadingModel GOURAUD -setInteriorStyle HIDDENLINE -setDrawEdges 1 -setEdgeColor RED
|
||||
vdrawtext t4 " s4: hiddenline-edges " -pos 1.3 -1.3 -1.3 -halign CENTER -disptype SUBTITLE -color BLACK -subColor RED
|
||||
|
||||
vaspects s5 -setShadingModel FLAT -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor 0 1 0 0 -edgeWidth 3
|
||||
vdrawtext t5 " s5: flat solid-edges " -pos -1.3 -1.3 -2.5 -halign CENTER -disptype SUBTITLE -color BLACK -subColor GREEN
|
||||
|
||||
vrenderparams -msaa 0
|
||||
vcaps -polygonMode 1
|
||||
vdump $imagedir/${casename}_ortho_polmode.png
|
||||
|
||||
vcaps -polygonMode 0
|
||||
vdump $imagedir/${casename}_ortho_glsl.png
|
||||
|
||||
vrenderparams -msaa 4
|
||||
vcaps -polygonMode 1
|
||||
vdump $imagedir/${casename}_ortho_polmode_msaa.png
|
||||
|
||||
vcaps -polygonMode 0
|
||||
vdump $imagedir/${casename}_ortho_glsl_msaa.png
|
||||
|
||||
vcamera -persp
|
||||
vzoom 0.8
|
||||
vrenderparams -msaa 0
|
||||
vcaps -polygonMode 1
|
||||
vdump $imagedir/${casename}_persp_polmode.png
|
||||
|
||||
vcaps -polygonMode 0
|
||||
vdump $imagedir/${casename}_persp_glsl.png
|
||||
|
||||
vrenderparams -msaa 4
|
||||
vcaps -polygonMode 1
|
||||
vdump $imagedir/${casename}_persp_polmode_msaa.png
|
||||
|
||||
vcaps -polygonMode 0
|
||||
vdump $imagedir/${casename}_persp_glsl_msaa.png
|
69
tests/v3d/glsl/interior2
Normal file
69
tests/v3d/glsl/interior2
Normal file
@ -0,0 +1,69 @@
|
||||
puts "============"
|
||||
puts "0029076: Visualization - implement element shrinking Shader"
|
||||
puts "Test case on boxes"
|
||||
puts "============"
|
||||
puts ""
|
||||
|
||||
pload MODELING VISUALIZATION
|
||||
vclear
|
||||
vclose ALL
|
||||
vinit View1 -width 768 -height 409
|
||||
vzbufftrihedron
|
||||
vsetgradientbg 180 200 255 180 180 180 2
|
||||
box b1 -2 0 2 1 0.2 1
|
||||
box b2 2 0 2 1 0.2 1
|
||||
box b3 0 0 0 1 0.2 1
|
||||
box b4 -2 0 -2 1 0.2 1
|
||||
box b5 2 0 -2 1 0.2 1
|
||||
vdisplay -dispMode 1 b1 b2 b3 b4 b5
|
||||
vfit
|
||||
|
||||
vaspects b1 -setShadingModel PHONG -setInteriorStyle HOLLOW -setDrawEdges 1 -color BLACK
|
||||
vdrawtext t1 " b1: phong hollow-edges " -pos -2 0 2 -halign RIGHT -disptype SUBTITLE -color WHITE -subColor BLACK
|
||||
|
||||
vaspects b2 -setShadingModel GOURAUD -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor YELLOW
|
||||
vdrawtext t2 " b2: gouraud solid-edges " -pos 2 0 2 -halign RIGHT -disptype SUBTITLE -color BLACK -subColor YELLOW
|
||||
|
||||
vaspects b3 -setShadingModel PHONG -setInteriorStyle SOLID -setDrawEdges 1 -edgeWidth 2 -setEdgeColor BLUE1
|
||||
vdrawtext t3 " b3: phong solid-edges " -pos 0 0 0 -halign RIGHT -disptype SUBTITLE -color WHITE -subColor BLUE1
|
||||
|
||||
vaspects b4 -setShadingModel GOURAUD -setInteriorStyle HIDDENLINE -setDrawEdges 1 -setEdgeColor RED
|
||||
vdrawtext t4 " b4: hiddenline-edges " -pos -2 0 -2 -halign RIGHT -disptype SUBTITLE -color BLACK -subColor RED
|
||||
|
||||
vaspects b5 -setShadingModel FLAT -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor 0 1 0 0 -edgeWidth 3
|
||||
vdrawtext t5 " b5: flat solid-edges " -pos 2 0 -2 -halign RIGHT -disptype SUBTITLE -color BLACK -subColor GREEN
|
||||
|
||||
vdrawparray p6 triangles v 0 0 0 v 0 1 0 v 1 1 0 v 1 0 0 v 2 1 0 v 2 0 0 e 3 e 1 e 2 e 1 e 3 e 4 e 5 e 4 e 3 e 4 e 5 e 6
|
||||
vlocation p6 -setLocation 2 1 0
|
||||
vaspects p6 -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor FIREBRICK -setEdgeWidth 4 -setQuadEdges 1
|
||||
vdrawtext t6 " p6: quads " -pos 2 1 -0.4 -halign RIGHT -disptype SUBTITLE -color BLACK -subColor FIREBRICK
|
||||
|
||||
vrenderparams -msaa 0
|
||||
vcaps -polygonMode 1
|
||||
vdump $imagedir/${casename}_ortho_polmode.png
|
||||
|
||||
vcaps -polygonMode 0
|
||||
vdump $imagedir/${casename}_ortho_glsl.png
|
||||
|
||||
vrenderparams -msaa 4
|
||||
vcaps -polygonMode 1
|
||||
vdump $imagedir/${casename}_ortho_polmode_msaa.png
|
||||
|
||||
vcaps -polygonMode 0
|
||||
vdump $imagedir/${casename}_ortho_glsl_msaa.png
|
||||
|
||||
vcamera -persp
|
||||
vzoom 0.7
|
||||
vrenderparams -msaa 0
|
||||
vcaps -polygonMode 1
|
||||
vdump $imagedir/${casename}_persp_polmode.png
|
||||
|
||||
vcaps -polygonMode 0
|
||||
vdump $imagedir/${casename}_persp_glsl.png
|
||||
|
||||
vrenderparams -msaa 4
|
||||
vcaps -polygonMode 1
|
||||
vdump $imagedir/${casename}_persp_polmode_msaa.png
|
||||
|
||||
vcaps -polygonMode 0
|
||||
vdump $imagedir/${casename}_persp_glsl_msaa.png
|
Loading…
x
Reference in New Issue
Block a user