mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-13 14:27:08 +03:00
Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
baa6e38e70 | ||
|
2a33274558 | ||
|
4efe27fc4e | ||
|
ea298f59e4 | ||
|
78d5ea7a71 | ||
|
e084dbbc20 | ||
|
66d1cdc65d | ||
|
e607bd3e6b | ||
|
1ccc1371b9 | ||
|
5ac0f98974 | ||
|
2bda8346dc | ||
|
92435cd0ff | ||
|
597fde688e | ||
|
458ff6a680 | ||
|
a7ced2a456 | ||
|
ab9f6cabdc | ||
|
95c882e9d4 | ||
|
976627e601 | ||
|
d918208af6 | ||
|
98ae54f728 |
@@ -89,6 +89,14 @@ file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\nEXTERNAL_SEARCH = NO")
|
|||||||
# Formula options
|
# Formula options
|
||||||
file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\nMATHJAX_RELPATH = ${3RDPARTY_MATHJAX_RELATIVE_PATH}")
|
file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\nMATHJAX_RELPATH = ${3RDPARTY_MATHJAX_RELATIVE_PATH}")
|
||||||
|
|
||||||
|
# If MSVC is used as build system, change warning format to the one recognized by MSVC
|
||||||
|
if (MSVC)
|
||||||
|
file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\nWARN_FORMAT = \"$file($line): $text\"")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Avoid Doxygen parsing messages in the build log
|
||||||
|
file (APPEND ${OCCT_CONFIG_FOR_DOXYGEN} "\nQUIET = YES")
|
||||||
|
|
||||||
# Copy index file to provide fast access to HTML documentation
|
# Copy index file to provide fast access to HTML documentation
|
||||||
file(COPY "${OCCT_OVERVIEW_RESOURCE_DIR}/index.html" DESTINATION "${OCCT_GENERATED_OVERVIEW_DIR}")
|
file(COPY "${OCCT_OVERVIEW_RESOURCE_DIR}/index.html" DESTINATION "${OCCT_GENERATED_OVERVIEW_DIR}")
|
||||||
|
|
||||||
|
@@ -1091,7 +1091,7 @@ The following environment variables have become redundant:
|
|||||||
|
|
||||||
* *CSF_UnitsLexicon* and *CSF_UnitsDefinition* are no more used. Units definition (*UnitsAPI/Lexi_Expr.dat* and *UnitsAPI/Units.dat*) is now embedded into source code.
|
* *CSF_UnitsLexicon* and *CSF_UnitsDefinition* are no more used. Units definition (*UnitsAPI/Lexi_Expr.dat* and *UnitsAPI/Units.dat*) is now embedded into source code.
|
||||||
* *CSF_XSMessage* and *CSF_XHMessage* are now optional.
|
* *CSF_XSMessage* and *CSF_XHMessage* are now optional.
|
||||||
English messages (XSMessage/*XSTEP.us* and SHMessage/*SHAPE.us*) are now embedded into source code
|
English messages (XSMessage/\*XSTEP.us* and SHMessage/\*SHAPE.us*) are now embedded into source code
|
||||||
and automatically loaded when environment variables are not set.
|
and automatically loaded when environment variables are not set.
|
||||||
* *CSF_ShadersDirectory* is not required any more, though it still can be used to load custom shaders.
|
* *CSF_ShadersDirectory* is not required any more, though it still can be used to load custom shaders.
|
||||||
Mandatory GLSL resources are now embedded into source code.
|
Mandatory GLSL resources are now embedded into source code.
|
||||||
@@ -1678,3 +1678,10 @@ Standard_Boolean meshing_new()
|
|||||||
Some public methods of the class BRepFilletAPI_MakeChamfer are released from excess arguments:
|
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 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.
|
- 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.
|
||||||
|
@@ -16,7 +16,6 @@ WARNINGS = YES
|
|||||||
WARN_IF_UNDOCUMENTED = YES
|
WARN_IF_UNDOCUMENTED = YES
|
||||||
WARN_IF_DOC_ERROR = YES
|
WARN_IF_DOC_ERROR = YES
|
||||||
WARN_NO_PARAMDOC = NO
|
WARN_NO_PARAMDOC = NO
|
||||||
WARN_FORMAT = \\$file:\$line: \$text\
|
|
||||||
INPUT_ENCODING = UTF-8
|
INPUT_ENCODING = UTF-8
|
||||||
FILE_PATTERNS = *.md *.dox
|
FILE_PATTERNS = *.md *.dox
|
||||||
RECURSIVE = YES
|
RECURSIVE = YES
|
||||||
@@ -56,6 +55,6 @@ USE_MATHJAX = YES
|
|||||||
MATHJAX_FORMAT = HTML-CSS
|
MATHJAX_FORMAT = HTML-CSS
|
||||||
|
|
||||||
# Define alias for inserting images in uniform way (both HTML and PDF)
|
# Define alias for inserting images in uniform way (both HTML and PDF)
|
||||||
ALIASES += figure{1}="\image html \1 \n"
|
ALIASES += figure{1}="\image html \1"
|
||||||
ALIASES += figure{2}="\image html \1 \2 \n"
|
ALIASES += figure{2}="\image html \1 \2"
|
||||||
ALIASES += figure{3}="\image html \1 \2 \n"
|
ALIASES += figure{3}="\image html \1 \2"
|
||||||
|
@@ -16,7 +16,6 @@ WARNINGS = YES
|
|||||||
WARN_IF_UNDOCUMENTED = YES
|
WARN_IF_UNDOCUMENTED = YES
|
||||||
WARN_IF_DOC_ERROR = YES
|
WARN_IF_DOC_ERROR = YES
|
||||||
WARN_NO_PARAMDOC = NO
|
WARN_NO_PARAMDOC = NO
|
||||||
WARN_FORMAT = \\$file:\$line: \$text\
|
|
||||||
INPUT_ENCODING = UTF-8
|
INPUT_ENCODING = UTF-8
|
||||||
FILE_PATTERNS = *.md *.dox
|
FILE_PATTERNS = *.md *.dox
|
||||||
RECURSIVE = YES
|
RECURSIVE = YES
|
||||||
@@ -49,6 +48,6 @@ LATEX_CMD_NAME = latex
|
|||||||
MAKEINDEX_CMD_NAME = makeindex
|
MAKEINDEX_CMD_NAME = makeindex
|
||||||
|
|
||||||
# Define alias for inserting images in uniform way (both HTML and PDF)
|
# Define alias for inserting images in uniform way (both HTML and PDF)
|
||||||
ALIASES += figure{1}="\image latex \1 \n"
|
ALIASES += figure{1}="\image latex \1"
|
||||||
ALIASES += figure{2}="\image latex \1 \2 \n"
|
ALIASES += figure{2}="\image latex \1 \2"
|
||||||
ALIASES += figure{3}="\image latex \1 \2 width=\3 \n"
|
ALIASES += figure{3}="\image latex \1 \2 width=\3"
|
||||||
|
@@ -178,10 +178,10 @@ if (!Interface_Static::SetRVal ("read.maxprecision.val",0.1))
|
|||||||
Default value is 1.
|
Default value is 1.
|
||||||
|
|
||||||
<h4>read.stdsameparameter.mode</h4>
|
<h4>read.stdsameparameter.mode</h4>
|
||||||
defines the using of *BRepLib::SameParameter*. Its possible values are:
|
defines the using of *BRepLib\::SameParameter*. Its possible values are:
|
||||||
* 0 (Off) -- *BRepLib::SameParameter* is not called,
|
* 0 (Off) -- *BRepLib\::SameParameter* is not called,
|
||||||
* 1 (On) -- *BRepLib::SameParameter* is called.
|
* 1 (On) -- *BRepLib\::SameParameter* is called.
|
||||||
*BRepLib::SameParameter* is used through *ShapeFix_Edge::SameParameter*. It ensures that the resulting edge will have the lowest tolerance taking pcurves either unmodified from the IGES file or modified by *BRepLib::SameParameter*.
|
*BRepLib\::SameParameter* is used through *ShapeFix_Edge\::SameParameter*. It ensures that the resulting edge will have the lowest tolerance taking pcurves either unmodified from the IGES file or modified by *BRepLib\::SameParameter*.
|
||||||
Read this parameter with:
|
Read this parameter with:
|
||||||
~~~~~
|
~~~~~
|
||||||
Standard_Integer mv = Interface_Static::IVal("read.stdsameparameter.mode");
|
Standard_Integer mv = Interface_Static::IVal("read.stdsameparameter.mode");
|
||||||
@@ -202,7 +202,7 @@ The processor also decides to re-compute either the 3D or the 2D curve even if
|
|||||||
* the number of sub-curves in the 2D curve is different from the number of sub-curves in the 3D curve. This can be either due to different numbers of sub-curves given in the IGES file or because of splitting of curves during translation.
|
* the number of sub-curves in the 2D curve is different from the number of sub-curves in the 3D curve. This can be either due to different numbers of sub-curves given in the IGES file or because of splitting of curves during translation.
|
||||||
* 3D or 2D curve is a Circular Arc (entity type 100) starting and ending in the same point (note that this case is incorrect according to the IGES standard).
|
* 3D or 2D curve is a Circular Arc (entity type 100) starting and ending in the same point (note that this case is incorrect according to the IGES standard).
|
||||||
|
|
||||||
The parameter *read.surfacecurve.mode* defines which curve (3D or 2D) is used for re-computing the other one:
|
The parameter *read.surfacecurve.mode* defines which curve (3D or 2D) is used for re-computing the other one:
|
||||||
* *Default(0)* use the preference flag value in the entity's Parameter Data section. The flag values are:
|
* *Default(0)* use the preference flag value in the entity's Parameter Data section. The flag values are:
|
||||||
* 0: no preference given,
|
* 0: no preference given,
|
||||||
* 1: use 2D for 142 entities and 3D for 141 entities,
|
* 1: use 2D for 142 entities and 3D for 141 entities,
|
||||||
@@ -400,12 +400,12 @@ reader.PrintTransferInfo (failsonly, mode);
|
|||||||
~~~~~
|
~~~~~
|
||||||
displays the messages that appeared during the last invocation of *Transfer* or *TransferRoots*.
|
displays the messages that appeared during the last invocation of *Transfer* or *TransferRoots*.
|
||||||
|
|
||||||
If *failsonly* is *IFSelect_FailOnly*, only fail messages will be output, if it is *IFSelect_FailAndWarn*, all messages will be output. Parameter “mode” can have *IFSelect_xxx* values where *xxx* can be:
|
If *failsonly* is *IFSelect_FailOnly*, only fail messages will be output, if it is *IFSelect_FailAndWarn*, all messages will be output. Parameter “mode” can have *IFSelect_xxx* values where *xxx* can be:
|
||||||
* *GeneralCount* -- gives general statistics on the transfer (number of translated IGES entities, number of fails and warnings, etc)
|
* *GeneralCount* -- gives general statistics on the transfer (number of translated IGES entities, number of fails and warnings, etc)
|
||||||
* *CountByItem* -- gives the number of IGES entities with their types per message.
|
* *CountByItem* -- gives the number of IGES entities with their types per message.
|
||||||
* *ListByItem* -- gives the number of IGES entities with their type and DE numbers per message.
|
* *ListByItem* -- gives the number of IGES entities with their type and DE numbers per message.
|
||||||
* *ResultCount* -- gives the number of resulting OCCT shapes per type.
|
* *ResultCount* -- gives the number of resulting OCCT shapes per type.
|
||||||
* *Mapping* -- gives mapping between roots of the IGES file and the resulting OCCT shape per IGES and OCCT type.
|
* *Mapping* -- gives mapping between roots of the IGES file and the resulting OCCT shape per IGES and OCCT type.
|
||||||
|
|
||||||
@subsection occt_iges_2_4 Mapping of IGES entities to Open CASCADE Technology shapes
|
@subsection occt_iges_2_4 Mapping of IGES entities to Open CASCADE Technology shapes
|
||||||
|
|
||||||
|
@@ -1793,12 +1793,11 @@ Create facet attributes.
|
|||||||
Handle(Graphic3d_AspectFillArea3d) aFaceAspect = new Graphic3d_AspectFillArea3d();
|
Handle(Graphic3d_AspectFillArea3d) aFaceAspect = new Graphic3d_AspectFillArea3d();
|
||||||
Graphic3d_MaterialAspect aBrassMaterial (Graphic3d_NOM_BRASS);
|
Graphic3d_MaterialAspect aBrassMaterial (Graphic3d_NOM_BRASS);
|
||||||
Graphic3d_MaterialAspect aGoldMaterial (Graphic3d_NOM_GOLD);
|
Graphic3d_MaterialAspect aGoldMaterial (Graphic3d_NOM_GOLD);
|
||||||
aFaceAspect->SetInteriorStyle (Aspect_IS_SOLID);
|
aFaceAspect->SetInteriorStyle (Aspect_IS_SOLID_WIREFRAME);
|
||||||
aFaceAspect->SetInteriorColor (aMyColor);
|
aFaceAspect->SetInteriorColor (aMyColor);
|
||||||
aFaceAspect->SetDistinguishOn ();
|
aFaceAspect->SetDistinguishOn ();
|
||||||
aFaceAspect->SetFrontMaterial (aGoldMaterial);
|
aFaceAspect->SetFrontMaterial (aGoldMaterial);
|
||||||
aFaceAspect->SetBackMaterial (aBrassMaterial);
|
aFaceAspect->SetBackMaterial (aBrassMaterial);
|
||||||
aFaceAspect->SetEdgeOn();
|
|
||||||
~~~~~
|
~~~~~
|
||||||
|
|
||||||
Create text attributes.
|
Create text attributes.
|
||||||
|
@@ -14,9 +14,9 @@ Requirements for building sample:
|
|||||||
* Android NDK r9d or newer
|
* Android NDK r9d or newer
|
||||||
* Apache Ant 1.9.4 or higher
|
* Apache Ant 1.9.4 or higher
|
||||||
* OCCT compiled under Android platform and placed in directories:
|
* OCCT compiled under Android platform and placed in directories:
|
||||||
* occt/libs/armeabi-v7a/*.so and occt/inc/*.hxx (libraries and include files of OCCT install)
|
* occt/libs/armeabi-v7a/\*.so and occt/inc/\*.hxx (libraries and include files of OCCT install)
|
||||||
* android/assets/opencascade/shared/Shaders/* (Shaders folder of OCCT install: /share/opencascade/resources/Shaders)
|
* android/assets/opencascade/shared/Shaders/\* (Shaders folder of OCCT install: /share/opencascade/resources/Shaders)
|
||||||
* 3rdparty/include/freetype2/*, 3rdparty/include/FreeImage.h and 3rdparty/libs/armeabi-v7a/libFreeImage.so and 3rdparty/libs/armeabi-v7a/libfreetype.so
|
* 3rdparty/include/freetype2/\*, 3rdparty/include/FreeImage.h and 3rdparty/libs/armeabi-v7a/libFreeImage.so and 3rdparty/libs/armeabi-v7a/libfreetype.so
|
||||||
|
|
||||||
It is also possible to to correct OCCT.pri file an get resources from another tree of directories.
|
It is also possible to to correct OCCT.pri file an get resources from another tree of directories.
|
||||||
|
|
||||||
|
@@ -107,6 +107,10 @@ AIS_ColorScale::AIS_ColorScale()
|
|||||||
myTextHeight (20)
|
myTextHeight (20)
|
||||||
{
|
{
|
||||||
SetDisplayMode (0);
|
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 aBarTop = myYPos + myHeight - aTitleOffset - aBarYOffset;
|
||||||
const Standard_Integer aBarHeight = aBarTop - aBarBottom;
|
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;
|
TColStd_SequenceOfExtendedString aLabels;
|
||||||
if (myLabelType == Aspect_TOCSD_USER)
|
if (myLabelType == Aspect_TOCSD_USER)
|
||||||
{
|
{
|
||||||
@@ -496,11 +491,27 @@ void AIS_ColorScale::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
|
|||||||
aColorBreadth += aTextWidth;
|
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
|
// draw colors
|
||||||
drawColorBar (thePrs, aBarBottom, aBarHeight, aTextWidth, aColorBreadth);
|
drawColorBar (thePrs, aBarBottom, aBarHeight, aTextWidth, aColorBreadth);
|
||||||
|
|
||||||
// draw Labels
|
// 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);
|
aGroup->AddPrimitiveArray (aTriangles);
|
||||||
|
|
||||||
const Quantity_Color aFgColor (hasOwnColor ? myDrawer->Color() : Quantity_NOC_WHITE);
|
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
|
//function : drawLabels
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_ColorScale::drawLabels (const Handle(Prs3d_Presentation)& thePrs,
|
void AIS_ColorScale::drawLabels (const Handle(Graphic3d_Group)& theGroup,
|
||||||
const TColStd_SequenceOfExtendedString& theLabels,
|
const TColStd_SequenceOfExtendedString& theLabels,
|
||||||
const Standard_Integer theBarBottom,
|
const Standard_Integer theBarBottom,
|
||||||
const Standard_Integer theBarHeight,
|
const Standard_Integer theBarHeight,
|
||||||
@@ -716,14 +728,14 @@ void AIS_ColorScale::drawLabels (const Handle(Prs3d_Presentation)& thePrs,
|
|||||||
Standard_Integer aPos2 = aNbLabels - 1 - i2;
|
Standard_Integer aPos2 = aNbLabels - 1 - i2;
|
||||||
if (aFilter && !(aPos1 % aFilter))
|
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),
|
anXLeft, anYBottom + Standard_Integer(i1 * aStepY + anAscent),
|
||||||
Graphic3d_VTA_CENTER);
|
Graphic3d_VTA_CENTER);
|
||||||
aLast1 = i1;
|
aLast1 = i1;
|
||||||
}
|
}
|
||||||
if (aFilter && !(aPos2 % aFilter))
|
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),
|
anXLeft, anYBottom + Standard_Integer(i2 * aStepY + anAscent),
|
||||||
Graphic3d_VTA_CENTER);
|
Graphic3d_VTA_CENTER);
|
||||||
aLast2 = i2;
|
aLast2 = i2;
|
||||||
@@ -746,7 +758,7 @@ void AIS_ColorScale::drawLabels (const Handle(Prs3d_Presentation)& thePrs,
|
|||||||
|
|
||||||
if (i0 != -1)
|
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),
|
anXLeft, anYBottom + Standard_Integer(i0 * aStepY + anAscent),
|
||||||
Graphic3d_VTA_CENTER);
|
Graphic3d_VTA_CENTER);
|
||||||
}
|
}
|
||||||
@@ -769,8 +781,8 @@ void AIS_ColorScale::drawFrame (const Handle(Prs3d_Presentation)& thePrs,
|
|||||||
aPrim->AddVertex (theX, theY, 0.0);
|
aPrim->AddVertex (theX, theY, 0.0);
|
||||||
|
|
||||||
Handle(Graphic3d_AspectLine3d) anAspect = new Graphic3d_AspectLine3d (theColor, Aspect_TOL_SOLID, 1.0);
|
Handle(Graphic3d_AspectLine3d) anAspect = new Graphic3d_AspectLine3d (theColor, Aspect_TOL_SOLID, 1.0);
|
||||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePrs);
|
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
|
||||||
aGroup->SetPrimitivesAspect (anAspect);
|
aGroup->SetGroupPrimitivesAspect (anAspect);
|
||||||
aGroup->AddPrimitiveArray (aPrim);
|
aGroup->AddPrimitiveArray (aPrim);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -784,7 +796,6 @@ void AIS_ColorScale::drawText (const Handle(Graphic3d_Group)& theGroup,
|
|||||||
const Graphic3d_VerticalTextAlignment theVertAlignment)
|
const Graphic3d_VerticalTextAlignment theVertAlignment)
|
||||||
{
|
{
|
||||||
const Handle(Prs3d_TextAspect)& anAspect = myDrawer->TextAspect();
|
const Handle(Prs3d_TextAspect)& anAspect = myDrawer->TextAspect();
|
||||||
theGroup->SetPrimitivesAspect (anAspect->Aspect());
|
|
||||||
theGroup->Text (theText,
|
theGroup->Text (theText,
|
||||||
gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()),
|
gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()),
|
||||||
anAspect->Height(),
|
anAspect->Height(),
|
||||||
|
@@ -406,7 +406,7 @@ private:
|
|||||||
Standard_Integer computeMaxLabelWidth (const TColStd_SequenceOfExtendedString& theLabels) const;
|
Standard_Integer computeMaxLabelWidth (const TColStd_SequenceOfExtendedString& theLabels) const;
|
||||||
|
|
||||||
//! Draw labels.
|
//! Draw labels.
|
||||||
void drawLabels (const Handle(Prs3d_Presentation)& thePrs,
|
void drawLabels (const Handle(Graphic3d_Group)& theGroup,
|
||||||
const TColStd_SequenceOfExtendedString& theLabels,
|
const TColStd_SequenceOfExtendedString& theLabels,
|
||||||
const Standard_Integer theBarBottom,
|
const Standard_Integer theBarBottom,
|
||||||
const Standard_Integer theBarHeight,
|
const Standard_Integer theBarHeight,
|
||||||
|
@@ -493,6 +493,7 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
|
|||||||
const gp_Lin aLine (myStartPosition.Location(), myAxes[myCurrentIndex].Position().Direction());
|
const gp_Lin aLine (myStartPosition.Location(), myAxes[myCurrentIndex].Position().Direction());
|
||||||
Extrema_ExtElC anExtrema (anInputLine, aLine, Precision::Angular());
|
Extrema_ExtElC anExtrema (anInputLine, aLine, Precision::Angular());
|
||||||
if (!anExtrema.IsDone()
|
if (!anExtrema.IsDone()
|
||||||
|
|| anExtrema.IsParallel()
|
||||||
|| anExtrema.NbExt() != 1)
|
|| anExtrema.NbExt() != 1)
|
||||||
{
|
{
|
||||||
// translation cannot be done co-directed with camera
|
// translation cannot be done co-directed with camera
|
||||||
@@ -538,7 +539,9 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
|
|||||||
const gp_Pnt aPosLoc = myStartPosition.Location();
|
const gp_Pnt aPosLoc = myStartPosition.Location();
|
||||||
const gp_Ax1 aCurrAxis = getAx1FromAx2Dir (myStartPosition, myCurrentIndex);
|
const gp_Ax1 aCurrAxis = getAx1FromAx2Dir (myStartPosition, myCurrentIndex);
|
||||||
IntAna_IntConicQuad aIntersector (anInputLine, gp_Pln (aPosLoc, aCurrAxis.Direction()), Precision::Angular(), Precision::Intersection());
|
IntAna_IntConicQuad aIntersector (anInputLine, gp_Pln (aPosLoc, aCurrAxis.Direction()), Precision::Angular(), Precision::Intersection());
|
||||||
if (!aIntersector.IsDone() || aIntersector.NbPoints() < 1)
|
if (!aIntersector.IsDone()
|
||||||
|
|| aIntersector.IsParallel()
|
||||||
|
|| aIntersector.NbPoints() < 1)
|
||||||
{
|
{
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
@@ -350,77 +350,12 @@ bool AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
|
|||||||
const Quantity_Color& theColor) const
|
const Quantity_Color& theColor) const
|
||||||
{
|
{
|
||||||
bool toRecompute = false;
|
bool toRecompute = false;
|
||||||
if (!theDrawer->HasOwnShadingAspect())
|
toRecompute = theDrawer->SetupOwnShadingAspect() || toRecompute;
|
||||||
|
toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
|
||||||
|
|
||||||
|
if (theDrawer->SetupOwnPointAspect())
|
||||||
{
|
{
|
||||||
toRecompute = true;
|
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
|
// override color
|
||||||
@@ -614,61 +549,7 @@ void AIS_Shape::UnsetColor()
|
|||||||
bool AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
|
bool AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
|
||||||
const Standard_Real theLineWidth) const
|
const Standard_Real theLineWidth) const
|
||||||
{
|
{
|
||||||
bool toRecompute = false;
|
bool toRecompute = theDrawer->SetOwnLineAspects();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// override width
|
// override width
|
||||||
theDrawer->LineAspect()->SetWidth (theLineWidth);
|
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 Quantity_Color aColor = theDrawer->ShadingAspect()->Material (myCurrentFacingModel).Color();
|
||||||
const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
|
const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
|
||||||
if (!theDrawer->HasOwnShadingAspect())
|
theDrawer->SetupOwnShadingAspect();
|
||||||
{
|
|
||||||
theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
|
||||||
if (theDrawer->HasLink())
|
|
||||||
{
|
|
||||||
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
|
theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
|
||||||
|
|
||||||
if (theToKeepColor)
|
if (theToKeepColor)
|
||||||
@@ -889,15 +763,7 @@ void AIS_Shape::UnsetMaterial()
|
|||||||
void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
|
void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
|
||||||
const Standard_Real theValue) const
|
const Standard_Real theValue) const
|
||||||
{
|
{
|
||||||
if (!theDrawer->HasOwnShadingAspect())
|
theDrawer->SetupOwnShadingAspect();
|
||||||
{
|
|
||||||
theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
|
||||||
if (theDrawer->HasLink())
|
|
||||||
{
|
|
||||||
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// override transparency
|
// override transparency
|
||||||
theDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
|
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:
|
//! To generate texture coordinates, appropriate shading attribute should be set before computing presentation in AIS_Shaded display mode:
|
||||||
//! @code
|
//! @code
|
||||||
//! Handle(AIS_Shape) aPrs = new AIS_Shape();
|
//! 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()->SetTextureMapOn();
|
||||||
//! aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMap (new Graphic3d_Texture2Dmanual (Graphic3d_NOT_2D_ALUMINUM));
|
//! aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMap (new Graphic3d_Texture2Dmanual (Graphic3d_NOT_2D_ALUMINUM));
|
||||||
//! @endcode
|
//! @endcode
|
||||||
|
@@ -16,23 +16,17 @@
|
|||||||
#ifndef _Aspect_InteriorStyle_HeaderFile
|
#ifndef _Aspect_InteriorStyle_HeaderFile
|
||||||
#define _Aspect_InteriorStyle_HeaderFile
|
#define _Aspect_InteriorStyle_HeaderFile
|
||||||
|
|
||||||
//! Definition of interior types for primitive
|
//! Interior types for primitive faces.
|
||||||
//! 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.
|
|
||||||
enum Aspect_InteriorStyle
|
enum Aspect_InteriorStyle
|
||||||
{
|
{
|
||||||
Aspect_IS_EMPTY,
|
Aspect_IS_EMPTY = -1, //!< no interior
|
||||||
Aspect_IS_HOLLOW,
|
Aspect_IS_SOLID = 0, //!< normally filled surface interior
|
||||||
Aspect_IS_HATCH,
|
Aspect_IS_HATCH, //!< hatched surface interior
|
||||||
Aspect_IS_SOLID,
|
Aspect_IS_HIDDENLINE, //!< interior is filled with viewer background color
|
||||||
Aspect_IS_HIDDENLINE,
|
Aspect_IS_POINT, //!< display only vertices of surface (obsolete)
|
||||||
Aspect_IS_POINT
|
|
||||||
|
// obsolete aliases
|
||||||
|
Aspect_IS_HOLLOW = Aspect_IS_EMPTY, //!< transparent surface interior
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _Aspect_InteriorStyle_HeaderFile
|
#endif // _Aspect_InteriorStyle_HeaderFile
|
||||||
|
@@ -18,7 +18,6 @@
|
|||||||
#include <IMeshData_Edge.hxx>
|
#include <IMeshData_Edge.hxx>
|
||||||
#include <OSD_Parallel.hxx>
|
#include <OSD_Parallel.hxx>
|
||||||
#include <BRepMesh_GeomTool.hxx>
|
#include <BRepMesh_GeomTool.hxx>
|
||||||
#include <BRepMesh_IncAllocator.hxx>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@@ -1,50 +0,0 @@
|
|||||||
// Created on: 2016-06-20
|
|
||||||
// Created by: Oleg AGASHIN
|
|
||||||
// Copyright (c) 2016 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.
|
|
||||||
|
|
||||||
#ifndef _BRepMesh_IncAllocator_HeaderFile
|
|
||||||
#define _BRepMesh_IncAllocator_HeaderFile
|
|
||||||
|
|
||||||
#include <NCollection_IncAllocator.hxx>
|
|
||||||
#include <Standard_Mutex.hxx>
|
|
||||||
|
|
||||||
//! Extension for NCollection_IncAllocator implementing simple thread safety
|
|
||||||
//! by introduction of Mutex. Intended for use in couple with BRepMeshData
|
|
||||||
//! entities in order to prevent data races while building data model in
|
|
||||||
//! parallel mode. Note that this allocator is supposed for use by collections
|
|
||||||
//! which allocate memory by huge blocks at arbitrary moment, thus it should
|
|
||||||
//! not introduce significant performance slow down.
|
|
||||||
class BRepMesh_IncAllocator : public NCollection_IncAllocator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! Constructor
|
|
||||||
BRepMesh_IncAllocator(const size_t theBlockSize = DefaultBlockSize)
|
|
||||||
: NCollection_IncAllocator(theBlockSize)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Allocate memory with given size. Returns NULL on failure
|
|
||||||
virtual void* Allocate(const size_t size) Standard_OVERRIDE
|
|
||||||
{
|
|
||||||
Standard_Mutex::Sentry aSentry(myMutex);
|
|
||||||
return NCollection_IncAllocator::Allocate(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_IncAllocator, NCollection_IncAllocator)
|
|
||||||
|
|
||||||
private:
|
|
||||||
Standard_Mutex myMutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@@ -46,7 +46,6 @@ BRepMesh_FactoryError.hxx
|
|||||||
BRepMesh_FastDiscret.hxx
|
BRepMesh_FastDiscret.hxx
|
||||||
BRepMesh_GeomTool.cxx
|
BRepMesh_GeomTool.cxx
|
||||||
BRepMesh_GeomTool.hxx
|
BRepMesh_GeomTool.hxx
|
||||||
BRepMesh_IncAllocator.hxx
|
|
||||||
BRepMesh_IncrementalMesh.cxx
|
BRepMesh_IncrementalMesh.cxx
|
||||||
BRepMesh_IncrementalMesh.hxx
|
BRepMesh_IncrementalMesh.hxx
|
||||||
BRepMesh_MeshAlgoFactory.cxx
|
BRepMesh_MeshAlgoFactory.cxx
|
||||||
|
@@ -14,11 +14,12 @@
|
|||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
#include <BRepMeshData_Model.hxx>
|
#include <BRepMeshData_Model.hxx>
|
||||||
|
|
||||||
#include <BRepMeshData_Face.hxx>
|
#include <BRepMeshData_Face.hxx>
|
||||||
#include <BRepMeshData_Edge.hxx>
|
#include <BRepMeshData_Edge.hxx>
|
||||||
#include <BRepMesh_IncAllocator.hxx>
|
|
||||||
#include <BRepMesh_OrientedEdge.hxx>
|
#include <BRepMesh_OrientedEdge.hxx>
|
||||||
#include <BRepMesh_Vertex.hxx>
|
#include <BRepMesh_Vertex.hxx>
|
||||||
|
#include <NCollection_IncAllocator.hxx>
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
// Function: Constructor
|
// Function: Constructor
|
||||||
@@ -27,10 +28,11 @@
|
|||||||
BRepMeshData_Model::BRepMeshData_Model (const TopoDS_Shape& theShape)
|
BRepMeshData_Model::BRepMeshData_Model (const TopoDS_Shape& theShape)
|
||||||
: IMeshData_Model (theShape),
|
: IMeshData_Model (theShape),
|
||||||
myMaxSize (0.),
|
myMaxSize (0.),
|
||||||
myAllocator (new BRepMesh_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE)),
|
myAllocator (new NCollection_IncAllocator (IMeshData::MEMORY_BLOCK_SIZE_HUGE)),
|
||||||
myDFaces (256, myAllocator),
|
myDFaces (256, myAllocator),
|
||||||
myDEdges (256, myAllocator)
|
myDEdges (256, myAllocator)
|
||||||
{
|
{
|
||||||
|
myAllocator->SetThreadSafe();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@@ -2731,13 +2731,14 @@ proc _checkpoint {coord_x coord_y rd_ch gr_ch bl_ch} {
|
|||||||
# the check fails and procedure raises error with specified message.
|
# the check fails and procedure raises error with specified message.
|
||||||
#
|
#
|
||||||
# Otherwise the procedure returns false meaning that more iterations are needed.
|
# Otherwise the procedure returns false meaning that more iterations are needed.
|
||||||
# Note that false is returned in any case if length of listval is less than 3.
|
# Note that analysis is peformed only if listval contains at least 5 values,
|
||||||
|
# thus false is returned unconditionally for shorter lists.
|
||||||
#
|
#
|
||||||
# See example of use to check memory leaks in bugs/caf/bug23489
|
# See example of use to check memory leaks in bugs/caf/bug23489
|
||||||
#
|
#
|
||||||
proc checktrend {listval delta tolerance message} {
|
proc checktrend {listval delta tolerance message} {
|
||||||
set nbval [llength $listval]
|
set nbval [llength $listval]
|
||||||
if { $nbval < 3} {
|
if { $nbval < 5} {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -702,20 +702,25 @@ Handle(Font_SystemFont) Font_FontMgr::FindFont (const TCollection_AsciiString& t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Trying to use font names mapping
|
// Trying to use font names mapping
|
||||||
Handle(Font_FontAliasSequence) anAliases;
|
for (int aPass = 0; aPass < 2; ++aPass)
|
||||||
const Standard_Boolean hasAliases = myFontAliases.Find (aFontName, anAliases)
|
|
||||||
&& !anAliases.IsNull()
|
|
||||||
&& !anAliases->IsEmpty();
|
|
||||||
if (!hasAliases
|
|
||||||
&& aFont.IsNull())
|
|
||||||
{
|
{
|
||||||
anAliases = myFallbackAlias;
|
Handle(Font_FontAliasSequence) anAliases;
|
||||||
}
|
if (aPass == 0)
|
||||||
|
{
|
||||||
|
myFontAliases.Find (aFontName, anAliases);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
anAliases = myFallbackAlias;
|
||||||
|
}
|
||||||
|
|
||||||
bool isAliasUsed = false, isBestAlias = false;
|
if (anAliases.IsNull()
|
||||||
if (!anAliases.IsNull()
|
|| anAliases->IsEmpty())
|
||||||
&& !anAliases->IsEmpty())
|
{
|
||||||
{
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isAliasUsed = false, isBestAlias = false;
|
||||||
for (Font_FontAliasSequence::Iterator anAliasIter (*anAliases); anAliasIter.More(); anAliasIter.Next())
|
for (Font_FontAliasSequence::Iterator anAliasIter (*anAliases); anAliasIter.More(); anAliasIter.Next())
|
||||||
{
|
{
|
||||||
const Font_FontAlias& anAlias = anAliasIter.Value();
|
const Font_FontAlias& anAlias = anAliasIter.Value();
|
||||||
@@ -737,24 +742,29 @@ Handle(Font_SystemFont) Font_FontMgr::FindFont (const TCollection_AsciiString& t
|
|||||||
}
|
}
|
||||||
else if (anAlias.FontAspect == Font_FontAspect_UNDEFINED
|
else if (anAlias.FontAspect == Font_FontAspect_UNDEFINED
|
||||||
&& (theFontAspect == Font_FontAspect_UNDEFINED
|
&& (theFontAspect == Font_FontAspect_UNDEFINED
|
||||||
|| aFont2->HasFontAspect (theFontAspect)))
|
|| aFont2->HasFontAspect (theFontAspect)))
|
||||||
{
|
{
|
||||||
isBestAlias = true;
|
isBestAlias = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasAliases)
|
|
||||||
|
if (aPass == 0)
|
||||||
{
|
{
|
||||||
if (isAliasUsed && myToTraceAliases)
|
if (isAliasUsed && myToTraceAliases)
|
||||||
{
|
{
|
||||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("Font_FontMgr, using font alias '") + aFont->FontName() + "'"
|
Message::DefaultMessenger()->Send (TCollection_AsciiString("Font_FontMgr, using font alias '") + aFont->FontName() + "'"
|
||||||
" instead of requested '" + theFontName +"'", Message_Trace);
|
" instead of requested '" + theFontName +"'", Message_Trace);
|
||||||
}
|
}
|
||||||
if (isBestAlias)
|
if (isBestAlias)
|
||||||
{
|
{
|
||||||
return aFont;
|
return aFont;
|
||||||
}
|
}
|
||||||
|
else if (!aFont.IsNull())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
GeometryTest.cxx
|
GeometryTest.cxx
|
||||||
GeometryTest.hxx
|
GeometryTest.hxx
|
||||||
GeometryTest_API2dCommands.cxx
|
|
||||||
GeometryTest_APICommands.cxx
|
GeometryTest_APICommands.cxx
|
||||||
GeometryTest_ConstraintCommands.cxx
|
GeometryTest_ConstraintCommands.cxx
|
||||||
GeometryTest_ContinuityCommands.cxx
|
GeometryTest_ContinuityCommands.cxx
|
||||||
|
@@ -14,9 +14,6 @@
|
|||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
// modified by mps (dec 96) ajout de ContinuityCommands
|
|
||||||
// jpi 09/06/97 utilisation des commandes de GeomliteTest
|
|
||||||
|
|
||||||
#include <GeometryTest.hxx>
|
#include <GeometryTest.hxx>
|
||||||
#include <GeomliteTest.hxx>
|
#include <GeomliteTest.hxx>
|
||||||
#include <Standard_Boolean.hxx>
|
#include <Standard_Boolean.hxx>
|
||||||
@@ -34,10 +31,6 @@ void GeometryTest::AllCommands(Draw_Interpretor& theCommands)
|
|||||||
GeometryTest::FairCurveCommands(theCommands);
|
GeometryTest::FairCurveCommands(theCommands);
|
||||||
GeometryTest::SurfaceCommands(theCommands);
|
GeometryTest::SurfaceCommands(theCommands);
|
||||||
GeometryTest::ConstraintCommands(theCommands);
|
GeometryTest::ConstraintCommands(theCommands);
|
||||||
|
|
||||||
// See bug #0030366
|
|
||||||
// GeometryTest::API2dCommands(theCommands);
|
|
||||||
|
|
||||||
GeometryTest::APICommands(theCommands);
|
GeometryTest::APICommands(theCommands);
|
||||||
GeometryTest::ContinuityCommands(theCommands);
|
GeometryTest::ContinuityCommands(theCommands);
|
||||||
GeometryTest::TestProjCommands(theCommands);
|
GeometryTest::TestProjCommands(theCommands);
|
||||||
|
@@ -50,15 +50,8 @@ public:
|
|||||||
|
|
||||||
//! defines cosntrained curves commands.
|
//! defines cosntrained curves commands.
|
||||||
Standard_EXPORT static void ConstraintCommands (Draw_Interpretor& I);
|
Standard_EXPORT static void ConstraintCommands (Draw_Interpretor& I);
|
||||||
|
|
||||||
//! defines commands to test the Geom2dAPI
|
//! defines commands to test the GeomAPI
|
||||||
//! - Intersection
|
|
||||||
//! - Extrema
|
|
||||||
//! - Projection
|
|
||||||
//! - Approximation, interpolation
|
|
||||||
Standard_EXPORT static void API2dCommands (Draw_Interpretor& I);
|
|
||||||
|
|
||||||
//! defines commands to test the Geom2dAPI
|
|
||||||
//! - Intersection
|
//! - Intersection
|
||||||
//! - Extrema
|
//! - Extrema
|
||||||
//! - Projection
|
//! - Projection
|
||||||
@@ -76,27 +69,6 @@ public:
|
|||||||
//! defines commands to test projection of geometric objects
|
//! defines commands to test projection of geometric objects
|
||||||
Standard_EXPORT static void TestProjCommands (Draw_Interpretor& I);
|
Standard_EXPORT static void TestProjCommands (Draw_Interpretor& I);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _GeometryTest_HeaderFile
|
#endif // _GeometryTest_HeaderFile
|
||||||
|
@@ -1,287 +0,0 @@
|
|||||||
// Created on: 1995-01-11
|
|
||||||
// Created by: Remi LEQUETTE
|
|
||||||
// Copyright (c) 1995-1999 Matra Datavision
|
|
||||||
// Copyright (c) 1999-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 <GeometryTest.hxx>
|
|
||||||
#include <Geom2d_BSplineCurve.hxx>
|
|
||||||
#include <Draw.hxx>
|
|
||||||
#include <Draw_Interpretor.hxx>
|
|
||||||
#include <DrawTrSurf.hxx>
|
|
||||||
#include <Draw_Appli.hxx>
|
|
||||||
#include <DrawTrSurf_Curve2d.hxx>
|
|
||||||
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
|
|
||||||
#include <Geom2dAPI_ExtremaCurveCurve.hxx>
|
|
||||||
#include <Geom2dAPI_PointsToBSpline.hxx>
|
|
||||||
#include <Geom2dAPI_InterCurveCurve.hxx>
|
|
||||||
#include <Geom2d_Line.hxx>
|
|
||||||
#include <Geom2d_TrimmedCurve.hxx>
|
|
||||||
#include <TColgp_Array1OfPnt2d.hxx>
|
|
||||||
#include <gp_Pnt.hxx>
|
|
||||||
#include <Draw_Marker2D.hxx>
|
|
||||||
#include <Draw_Color.hxx>
|
|
||||||
#include <Draw_MarkerShape.hxx>
|
|
||||||
#include <TColStd_Array1OfReal.hxx>
|
|
||||||
#include <GeomAbs_Shape.hxx>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#ifdef _WIN32
|
|
||||||
Standard_IMPORT Draw_Viewer dout;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : proj
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
static Standard_Integer proj (Draw_Interpretor& di, Standard_Integer n, const char** a)
|
|
||||||
{
|
|
||||||
if ( n < 4) return 1;
|
|
||||||
|
|
||||||
gp_Pnt2d P(Draw::Atof(a[2]),Draw::Atof(a[3]));
|
|
||||||
|
|
||||||
char name[100];
|
|
||||||
|
|
||||||
Handle(Geom2d_Curve) GC = DrawTrSurf::GetCurve2d(a[1]);
|
|
||||||
|
|
||||||
if (GC.IsNull())
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
Geom2dAPI_ProjectPointOnCurve proj(P,GC,GC->FirstParameter(),
|
|
||||||
GC->LastParameter());
|
|
||||||
|
|
||||||
for ( Standard_Integer i = 1; i <= proj.NbPoints(); i++) {
|
|
||||||
gp_Pnt2d P1 = proj.Point(i);
|
|
||||||
Handle(Geom2d_Line) L = new Geom2d_Line(P,gp_Vec2d(P,P1));
|
|
||||||
Handle(Geom2d_TrimmedCurve) CT =
|
|
||||||
new Geom2d_TrimmedCurve(L, 0., P.Distance(P1));
|
|
||||||
Sprintf(name,"%s%d","ext_",i);
|
|
||||||
char* temp = name; // portage WNT
|
|
||||||
DrawTrSurf::Set(temp, CT);
|
|
||||||
di << name << " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : appro
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
static Standard_Integer appro(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
|
||||||
{
|
|
||||||
// Approximation et interpolation 2d
|
|
||||||
|
|
||||||
// 2dappro
|
|
||||||
// - affiche la tolerance
|
|
||||||
// 2dappro tol
|
|
||||||
// - change la tolerance
|
|
||||||
// 2dappro result nbpoint
|
|
||||||
// - saisie interactive
|
|
||||||
// 2dappro result nbpoint curve
|
|
||||||
// - calcule des points sur la courbe
|
|
||||||
// 2dappro result nbpoint x1 y1 x2 y2 ..
|
|
||||||
// - tableau de points
|
|
||||||
// 2dappro result nbpoint x1 dx y1 y2 ..
|
|
||||||
// - tableau de points (x1,y1) (x1+dx,y2) ... avec x = t
|
|
||||||
|
|
||||||
|
|
||||||
static Standard_Real Tol2d = 1.e-6;
|
|
||||||
|
|
||||||
if (n < 3) {
|
|
||||||
if (n == 2)
|
|
||||||
Tol2d = Draw::Atof(a[1]);
|
|
||||||
|
|
||||||
di << "Tolerance for 2d approx : "<< Tol2d << "\n";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Standard_Integer i, Nb = Draw::Atoi(a[2]);
|
|
||||||
|
|
||||||
Standard_Boolean hasPoints = Standard_True;
|
|
||||||
TColgp_Array1OfPnt2d Points(1, Nb);
|
|
||||||
TColStd_Array1OfReal YValues(1,Nb);
|
|
||||||
Standard_Real X0=0,DX=0;
|
|
||||||
|
|
||||||
Handle(Draw_Marker2D) mark;
|
|
||||||
|
|
||||||
if (n == 3) {
|
|
||||||
// saisie interactive
|
|
||||||
Standard_Integer id,XX,YY,b;
|
|
||||||
dout.Select(id,XX,YY,b);
|
|
||||||
Standard_Real zoom = dout.Zoom(id);
|
|
||||||
|
|
||||||
Points(1) = gp_Pnt2d( ((Standard_Real)XX)/zoom,
|
|
||||||
((Standard_Real)YY)/zoom );
|
|
||||||
|
|
||||||
mark = new Draw_Marker2D( Points(1), Draw_X, Draw_vert);
|
|
||||||
|
|
||||||
dout << mark;
|
|
||||||
|
|
||||||
for (Standard_Integer j = 2; j<=Nb; j++) {
|
|
||||||
dout.Select(id,XX,YY,b);
|
|
||||||
Points(j) = gp_Pnt2d( ((Standard_Real)XX)/zoom,
|
|
||||||
((Standard_Real)YY)/zoom );
|
|
||||||
mark = new Draw_Marker2D( Points(j), Draw_X, Draw_vert);
|
|
||||||
dout << mark;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ( n == 4) {
|
|
||||||
// points sur courbe
|
|
||||||
Handle(Geom2d_Curve) GC = DrawTrSurf::GetCurve2d(a[3]);
|
|
||||||
if ( GC.IsNull())
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
Standard_Real U, U1, U2;
|
|
||||||
U1 = GC->FirstParameter();
|
|
||||||
U2 = GC->LastParameter();
|
|
||||||
Standard_Real Delta = ( U2 - U1) / (Nb-1);
|
|
||||||
for ( i = 1 ; i <= Nb; i++) {
|
|
||||||
U = U1 + (i-1) * Delta;
|
|
||||||
Points(i) = GC->Value(U);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
// test points ou ordonnees
|
|
||||||
hasPoints = Standard_False;
|
|
||||||
Standard_Integer nc = n - 3;
|
|
||||||
if (nc == 2 * Nb) {
|
|
||||||
// points
|
|
||||||
nc = 3;
|
|
||||||
for (i = 1; i <= Nb; i++) {
|
|
||||||
Points(i).SetCoord(Draw::Atof(a[nc]),Draw::Atof(a[nc+1]));
|
|
||||||
nc += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (nc - 2 == Nb) {
|
|
||||||
// YValues
|
|
||||||
nc = 5;
|
|
||||||
X0 = Draw::Atof(a[3]);
|
|
||||||
DX = Draw::Atof(a[4]);
|
|
||||||
for (i = 1; i <= Nb; i++) {
|
|
||||||
YValues(i) = Draw::Atof(a[nc]);
|
|
||||||
Points(i).SetCoord(X0+(i-1)*DX,YValues(i));
|
|
||||||
nc++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
// display the points
|
|
||||||
for ( i = 1 ; i <= Nb; i++) {
|
|
||||||
mark = new Draw_Marker2D( Points(i), Draw_X, Draw_vert);
|
|
||||||
dout << mark;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dout.Flush();
|
|
||||||
Standard_Integer Dmin = 3;
|
|
||||||
Standard_Integer Dmax = 8;
|
|
||||||
|
|
||||||
Handle(Geom2d_BSplineCurve) TheCurve;
|
|
||||||
if (hasPoints)
|
|
||||||
TheCurve = Geom2dAPI_PointsToBSpline(Points,Dmin,Dmax,GeomAbs_C2,Tol2d);
|
|
||||||
else
|
|
||||||
TheCurve = Geom2dAPI_PointsToBSpline(YValues,X0,DX,Dmin,Dmax,GeomAbs_C2,Tol2d);
|
|
||||||
|
|
||||||
DrawTrSurf::Set(a[1], TheCurve);
|
|
||||||
di << a[1];
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : intersect
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
static Standard_Integer intersect(Draw_Interpretor& /*di*/, Standard_Integer n, const char** a)
|
|
||||||
{
|
|
||||||
if( n < 2)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
Handle(Geom2d_Curve) C1 = DrawTrSurf::GetCurve2d(a[1]);
|
|
||||||
if ( C1.IsNull())
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
Standard_Real Tol = 0.001;
|
|
||||||
Geom2dAPI_InterCurveCurve Intersector;
|
|
||||||
|
|
||||||
Handle(Geom2d_Curve) C2;
|
|
||||||
if ( n == 3) {
|
|
||||||
C2 = DrawTrSurf::GetCurve2d(a[2]);
|
|
||||||
if ( C2.IsNull())
|
|
||||||
return 1;
|
|
||||||
Intersector.Init(C1,C2,Tol);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Intersector.Init(C1, Tol);
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Integer i;
|
|
||||||
|
|
||||||
for ( i = 1; i <= Intersector.NbPoints(); i++) {
|
|
||||||
gp_Pnt2d P = Intersector.Point(i);
|
|
||||||
Handle(Draw_Marker2D) mark = new Draw_Marker2D( P, Draw_X, Draw_vert);
|
|
||||||
dout << mark;
|
|
||||||
}
|
|
||||||
dout.Flush();
|
|
||||||
|
|
||||||
Handle(Geom2d_Curve) S1,S2;
|
|
||||||
Handle(DrawTrSurf_Curve2d) CD;
|
|
||||||
if ( n == 3) {
|
|
||||||
for ( i = 1; i <= Intersector.NbSegments(); i++) {
|
|
||||||
Intersector.Segment(i,S1,S2);
|
|
||||||
CD = new DrawTrSurf_Curve2d(S1, Draw_bleu, 30);
|
|
||||||
dout << CD;
|
|
||||||
CD = new DrawTrSurf_Curve2d(S2, Draw_violet, 30);
|
|
||||||
dout << CD;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dout.Flush();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GeometryTest::API2dCommands(Draw_Interpretor& theCommands)
|
|
||||||
{
|
|
||||||
static Standard_Boolean done = Standard_False;
|
|
||||||
if (done) return;
|
|
||||||
|
|
||||||
const char *g;
|
|
||||||
|
|
||||||
done = Standard_True;
|
|
||||||
g = "GEOMETRY curves and surfaces analysis";
|
|
||||||
|
|
||||||
theCommands.Add("2dproj", "proj curve x y",__FILE__, proj,g);
|
|
||||||
|
|
||||||
g = "GEOMETRY approximations";
|
|
||||||
|
|
||||||
theCommands.Add("2dapprox", "2dapprox result nbpoint [curve] [[x] y [x] y...]",__FILE__,
|
|
||||||
appro,g);
|
|
||||||
theCommands.Add("2dinterpole", "2dinterpole result nbpoint [curve] [[x] y [x] y ...]",__FILE__,
|
|
||||||
appro,g);
|
|
||||||
|
|
||||||
g = "GEOMETRY curves and surfaces analysis";
|
|
||||||
|
|
||||||
g = "GEOMETRY intersections";
|
|
||||||
|
|
||||||
theCommands.Add("2dintersect", "intersect curve curve",__FILE__,
|
|
||||||
intersect,g);
|
|
||||||
}
|
|
@@ -32,6 +32,7 @@ Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d()
|
|||||||
myEdgeType (Aspect_TOL_SOLID),
|
myEdgeType (Aspect_TOL_SOLID),
|
||||||
myEdgeWidth (1.0f),
|
myEdgeWidth (1.0f),
|
||||||
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
|
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
|
||||||
|
myToSkipFirstEdge (false),
|
||||||
myToDistinguishMaterials (false),
|
myToDistinguishMaterials (false),
|
||||||
myToDrawEdges (false),
|
myToDrawEdges (false),
|
||||||
myToSuppressBackFaces (true),
|
myToSuppressBackFaces (true),
|
||||||
@@ -63,6 +64,7 @@ Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (const Aspect_InteriorSty
|
|||||||
myEdgeType (theEdgeLineType),
|
myEdgeType (theEdgeLineType),
|
||||||
myEdgeWidth ((float )theEdgeLineWidth),
|
myEdgeWidth ((float )theEdgeLineWidth),
|
||||||
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
|
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
|
||||||
|
myToSkipFirstEdge (false),
|
||||||
myToDistinguishMaterials (false),
|
myToDistinguishMaterials (false),
|
||||||
myToDrawEdges (false),
|
myToDrawEdges (false),
|
||||||
myToSuppressBackFaces (true),
|
myToSuppressBackFaces (true),
|
||||||
|
@@ -255,19 +255,26 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//! Returns true if edges should be drawn (false by default).
|
//! 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.
|
//! 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.
|
//! Returns true if edges should be drawn.
|
||||||
bool Edge() const { return myToDrawEdges; }
|
bool Edge() const { return ToDrawEdges(); }
|
||||||
|
|
||||||
//! The edges of FillAreas are drawn.
|
//! The edges of FillAreas are drawn.
|
||||||
void SetEdgeOn() { myToDrawEdges = true; }
|
void SetEdgeOn() { SetDrawEdges (true); }
|
||||||
|
|
||||||
//! The edges of FillAreas are not drawn.
|
//! The edges of FillAreas are not drawn.
|
||||||
void SetEdgeOff() { myToDrawEdges = false; }
|
void SetEdgeOff() { SetDrawEdges (false); }
|
||||||
|
|
||||||
//! Return color of edges.
|
//! Return color of edges.
|
||||||
const Quantity_Color& EdgeColor() const { return myEdgeColor.GetRGB(); }
|
const Quantity_Color& EdgeColor() const { return myEdgeColor.GetRGB(); }
|
||||||
@@ -278,6 +285,9 @@ public:
|
|||||||
//! Modifies the color of the edge of the face
|
//! Modifies the color of the edge of the face
|
||||||
void SetEdgeColor (const Quantity_Color& theColor) { myEdgeColor.SetRGB (theColor); }
|
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.
|
//! Return edges line type.
|
||||||
Aspect_TypeOfLine EdgeLineType() const { return myEdgeType; }
|
Aspect_TypeOfLine EdgeLineType() const { return myEdgeType; }
|
||||||
|
|
||||||
@@ -298,6 +308,18 @@ public:
|
|||||||
myEdgeWidth = (float )theWidth;
|
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:
|
public:
|
||||||
|
|
||||||
//! Returns the hatch type used when InteriorStyle is IS_HATCH
|
//! Returns the hatch type used when InteriorStyle is IS_HATCH
|
||||||
@@ -370,6 +392,7 @@ protected:
|
|||||||
Handle(Graphic3d_HatchStyle) myHatchStyle;
|
Handle(Graphic3d_HatchStyle) myHatchStyle;
|
||||||
|
|
||||||
Graphic3d_PolygonOffset myPolygonOffset;
|
Graphic3d_PolygonOffset myPolygonOffset;
|
||||||
|
bool myToSkipFirstEdge;
|
||||||
bool myToDistinguishMaterials;
|
bool myToDistinguishMaterials;
|
||||||
bool myToDrawEdges;
|
bool myToDrawEdges;
|
||||||
bool myToSuppressBackFaces;
|
bool myToSuppressBackFaces;
|
||||||
|
@@ -94,11 +94,12 @@ public:
|
|||||||
Graphic3d_RenderingParams()
|
Graphic3d_RenderingParams()
|
||||||
: Method (Graphic3d_RM_RASTERIZATION),
|
: Method (Graphic3d_RM_RASTERIZATION),
|
||||||
TransparencyMethod (Graphic3d_RTM_BLEND_UNORDERED),
|
TransparencyMethod (Graphic3d_RTM_BLEND_UNORDERED),
|
||||||
|
LineFeather (1.0f),
|
||||||
OitDepthFactor (0.0f),
|
OitDepthFactor (0.0f),
|
||||||
NbMsaaSamples (0),
|
NbMsaaSamples (0),
|
||||||
RenderResolutionScale (1.0f),
|
RenderResolutionScale (1.0f),
|
||||||
ToEnableDepthPrepass (Standard_False),
|
ToEnableDepthPrepass (Standard_False),
|
||||||
ToEnableAlphaToCoverage (Standard_False),
|
ToEnableAlphaToCoverage (Standard_True),
|
||||||
// ray tracing parameters
|
// ray tracing parameters
|
||||||
IsGlobalIlluminationEnabled (Standard_False),
|
IsGlobalIlluminationEnabled (Standard_False),
|
||||||
RaytracingDepth (THE_DEFAULT_DEPTH),
|
RaytracingDepth (THE_DEFAULT_DEPTH),
|
||||||
@@ -109,10 +110,12 @@ public:
|
|||||||
UseEnvironmentMapBackground (Standard_False),
|
UseEnvironmentMapBackground (Standard_False),
|
||||||
CoherentPathTracingMode (Standard_False),
|
CoherentPathTracingMode (Standard_False),
|
||||||
AdaptiveScreenSampling (Standard_False),
|
AdaptiveScreenSampling (Standard_False),
|
||||||
|
AdaptiveScreenSamplingAtomic(Standard_False),
|
||||||
ShowSamplingTiles (Standard_False),
|
ShowSamplingTiles (Standard_False),
|
||||||
TwoSidedBsdfModels (Standard_False),
|
TwoSidedBsdfModels (Standard_False),
|
||||||
RadianceClampingValue (30.0),
|
RadianceClampingValue (30.0),
|
||||||
RebuildRayTracingShaders (Standard_False),
|
RebuildRayTracingShaders (Standard_False),
|
||||||
|
RayTracingTileSize (32),
|
||||||
NbRayTracingTiles (16 * 16),
|
NbRayTracingTiles (16 * 16),
|
||||||
CameraApertureRadius (0.0f),
|
CameraApertureRadius (0.0f),
|
||||||
CameraFocalPlaneDist (1.0f),
|
CameraFocalPlaneDist (1.0f),
|
||||||
@@ -166,12 +169,14 @@ public:
|
|||||||
|
|
||||||
Graphic3d_RenderingMode Method; //!< specifies rendering mode, Graphic3d_RM_RASTERIZATION by default
|
Graphic3d_RenderingMode Method; //!< specifies rendering mode, Graphic3d_RM_RASTERIZATION by default
|
||||||
Graphic3d_RenderTransparentMethod TransparencyMethod; //!< specifies rendering method for transparent graphics
|
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_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_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;
|
Standard_ShortReal RenderResolutionScale; //!< rendering resolution scale factor, 1 by default;
|
||||||
//! incompatible with MSAA (e.g. NbMsaaSamples should be set to 0)
|
//! incompatible with MSAA (e.g. NbMsaaSamples should be set to 0)
|
||||||
Standard_Boolean ToEnableDepthPrepass; //!< enables/disables depth pre-pass, False by default
|
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_Boolean IsGlobalIlluminationEnabled; //!< enables/disables global illumination effects (path tracing)
|
||||||
Standard_Integer SamplesPerPixel; //!< number of samples per pixel (SPP)
|
Standard_Integer SamplesPerPixel; //!< number of samples per pixel (SPP)
|
||||||
@@ -183,11 +188,15 @@ public:
|
|||||||
Standard_Boolean UseEnvironmentMapBackground; //!< enables/disables environment map background
|
Standard_Boolean UseEnvironmentMapBackground; //!< enables/disables environment map background
|
||||||
Standard_Boolean CoherentPathTracingMode; //!< enables/disables 'coherent' tracing mode (single RNG seed within 16x16 image blocks)
|
Standard_Boolean CoherentPathTracingMode; //!< enables/disables 'coherent' tracing mode (single RNG seed within 16x16 image blocks)
|
||||||
Standard_Boolean AdaptiveScreenSampling; //!< enables/disables adaptive screen sampling mode for path tracing, FALSE by default
|
Standard_Boolean AdaptiveScreenSampling; //!< enables/disables adaptive screen sampling mode for path tracing, FALSE by default
|
||||||
|
Standard_Boolean AdaptiveScreenSamplingAtomic;//!< enables/disables usage of atomic float operations within adaptive screen sampling, FALSE by default
|
||||||
Standard_Boolean ShowSamplingTiles; //!< enables/disables debug mode for adaptive screen sampling, FALSE by default
|
Standard_Boolean ShowSamplingTiles; //!< enables/disables debug mode for adaptive screen sampling, FALSE by default
|
||||||
Standard_Boolean TwoSidedBsdfModels; //!< forces path tracing to use two-sided versions of original one-sided scattering models
|
Standard_Boolean TwoSidedBsdfModels; //!< forces path tracing to use two-sided versions of original one-sided scattering models
|
||||||
Standard_ShortReal RadianceClampingValue; //!< maximum radiance value used for clamping radiance estimation.
|
Standard_ShortReal RadianceClampingValue; //!< maximum radiance value used for clamping radiance estimation.
|
||||||
Standard_Boolean RebuildRayTracingShaders; //!< forces rebuilding ray tracing shaders at the next frame
|
Standard_Boolean RebuildRayTracingShaders; //!< forces rebuilding ray tracing shaders at the next frame
|
||||||
Standard_Integer NbRayTracingTiles; //!< total number of screen tiles used in adaptive sampling mode (PT only)
|
Standard_Integer RayTracingTileSize; //!< screen tile size, 32 by default (adaptive sampling mode of path tracing);
|
||||||
|
Standard_Integer NbRayTracingTiles; //!< maximum number of screen tiles per frame, 256 by default (adaptive sampling mode of path tracing);
|
||||||
|
//! this parameter limits the number of tiles to be rendered per redraw, increasing Viewer interactivity,
|
||||||
|
//! but also increasing the time for achieving a good quality; -1 means no limit
|
||||||
Standard_ShortReal CameraApertureRadius; //!< aperture radius of perspective camera used for depth-of-field, 0.0 by default (no DOF) (path tracing only)
|
Standard_ShortReal CameraApertureRadius; //!< aperture radius of perspective camera used for depth-of-field, 0.0 by default (no DOF) (path tracing only)
|
||||||
Standard_ShortReal CameraFocalPlaneDist; //!< focal distance of perspective camera used for depth-of field, 1.0 by default (path tracing only)
|
Standard_ShortReal CameraFocalPlaneDist; //!< focal distance of perspective camera used for depth-of field, 1.0 by default (path tracing only)
|
||||||
FrustumCulling FrustumCullingState; //!< state of frustum culling optimization; FrustumCulling_On by default
|
FrustumCulling FrustumCullingState; //!< state of frustum culling optimization; FrustumCulling_On by default
|
||||||
|
@@ -28,9 +28,11 @@ enum Graphic3d_TypeOfLimit
|
|||||||
Graphic3d_TypeOfLimit_HasRayTracing, //!< indicates whether ray tracing is supported
|
Graphic3d_TypeOfLimit_HasRayTracing, //!< indicates whether ray tracing is supported
|
||||||
Graphic3d_TypeOfLimit_HasRayTracingTextures, //!< indicates whether ray tracing textures are supported
|
Graphic3d_TypeOfLimit_HasRayTracingTextures, //!< indicates whether ray tracing textures are supported
|
||||||
Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSampling, //!< indicates whether adaptive screen sampling is supported
|
Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSampling, //!< indicates whether adaptive screen sampling is supported
|
||||||
|
Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSamplingAtomic,//!< indicates whether optimized adaptive screen sampling is supported (hardware supports atomic float operations)
|
||||||
Graphic3d_TypeOfLimit_HasBlendedOit, //!< indicates whether necessary GL extensions for Weighted, Blended OIT available (without MSAA).
|
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_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_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_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
|
Graphic3d_TypeOfLimit_NB //!< number of elements in this enumeration
|
||||||
};
|
};
|
||||||
|
@@ -193,10 +193,12 @@ void IVtkOCC_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theSel
|
|||||||
aSelEntIter.Value()->SetActiveForSelection();
|
aSelEntIter.Value()->SetActiveForSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
theSelection->SetSelectionState (SelectMgr_SOS_Activated);
|
if (theSelection->GetSelectionState() != SelectMgr_SOS_Activated)
|
||||||
|
{
|
||||||
myTolerances.Add (theSelection->Sensitivity());
|
theSelection->SetSelectionState (SelectMgr_SOS_Activated);
|
||||||
myToUpdateTolerance = Standard_True;
|
myTolerances.Add (theSelection->Sensitivity());
|
||||||
|
myToUpdateTolerance = Standard_True;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
@@ -210,8 +212,10 @@ void IVtkOCC_ViewerSelector::Deactivate (const Handle(SelectMgr_Selection)& theS
|
|||||||
aSelEntIter.Value()->ResetSelectionActiveStatus();
|
aSelEntIter.Value()->ResetSelectionActiveStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
|
if (theSelection->GetSelectionState() == SelectMgr_SOS_Activated)
|
||||||
|
{
|
||||||
myTolerances.Decrement (theSelection->Sensitivity());
|
theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
|
||||||
myToUpdateTolerance = Standard_True;
|
myTolerances.Decrement (theSelection->Sensitivity());
|
||||||
|
myToUpdateTolerance = Standard_True;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ class IVtkTools_ShapeDataSource;
|
|||||||
class Standard_EXPORT IVtkTools_ShapeObject : public vtkDataObject
|
class Standard_EXPORT IVtkTools_ShapeObject : public vtkDataObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
vtkTypeMacro (IVtkTools_ShapeObject, vtkObject)
|
vtkTypeMacro (IVtkTools_ShapeObject, vtkDataObject)
|
||||||
|
|
||||||
static IVtkTools_ShapeObject* New();
|
static IVtkTools_ShapeObject* New();
|
||||||
|
|
||||||
|
@@ -22,7 +22,6 @@
|
|||||||
#include <vtkCellData.h>
|
#include <vtkCellData.h>
|
||||||
#include <vtkDoubleArray.h>
|
#include <vtkDoubleArray.h>
|
||||||
#include <vtkIdList.h>
|
#include <vtkIdList.h>
|
||||||
#include <vtkIdTypeArray.h>
|
|
||||||
#include <vtkPoints.h>
|
#include <vtkPoints.h>
|
||||||
#include <vtkPolyData.h>
|
#include <vtkPolyData.h>
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@@ -80,10 +79,7 @@ void IVtkVTK_ShapeData::InsertVertex (const IVtk_IdType theShapeID,
|
|||||||
{
|
{
|
||||||
vtkIdType aPointIdVTK = thePointId;
|
vtkIdType aPointIdVTK = thePointId;
|
||||||
myPolyData->InsertNextCell (VTK_VERTEX, 1, &aPointIdVTK);
|
myPolyData->InsertNextCell (VTK_VERTEX, 1, &aPointIdVTK);
|
||||||
const vtkIdType aShapeIDVTK = theShapeID;
|
insertNextSubShapeId (theShapeID, theMeshType);
|
||||||
mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
|
|
||||||
const vtkIdType aType = theMeshType;
|
|
||||||
myMeshTypes->InsertNextTupleValue (&aType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================
|
//================================================================
|
||||||
@@ -97,10 +93,7 @@ void IVtkVTK_ShapeData::InsertLine (const IVtk_IdType theShapeID,
|
|||||||
{
|
{
|
||||||
vtkIdType aPoints[2] = { thePointId1, thePointId2 };
|
vtkIdType aPoints[2] = { thePointId1, thePointId2 };
|
||||||
myPolyData->InsertNextCell (VTK_LINE, 2, aPoints);
|
myPolyData->InsertNextCell (VTK_LINE, 2, aPoints);
|
||||||
const vtkIdType aShapeIDVTK = theShapeID;
|
insertNextSubShapeId (theShapeID, theMeshType);
|
||||||
mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
|
|
||||||
const vtkIdType aType = theMeshType;
|
|
||||||
myMeshTypes->InsertNextTupleValue (&aType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================
|
//================================================================
|
||||||
@@ -124,10 +117,7 @@ void IVtkVTK_ShapeData::InsertLine (const IVtk_IdType theShapeID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
myPolyData->InsertNextCell (VTK_POLY_LINE, anIdList);
|
myPolyData->InsertNextCell (VTK_POLY_LINE, anIdList);
|
||||||
const vtkIdType aShapeIDVTK = theShapeID;
|
insertNextSubShapeId (theShapeID, theMeshType);
|
||||||
mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
|
|
||||||
const vtkIdType aType = theMeshType;
|
|
||||||
myMeshTypes->InsertNextTupleValue (&aType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,8 +133,5 @@ void IVtkVTK_ShapeData::InsertTriangle (const IVtk_IdType theShapeID,
|
|||||||
{
|
{
|
||||||
vtkIdType aPoints[3] = { thePointId1, thePointId2, thePointId3 };
|
vtkIdType aPoints[3] = { thePointId1, thePointId2, thePointId3 };
|
||||||
myPolyData->InsertNextCell (VTK_TRIANGLE, 3, aPoints);
|
myPolyData->InsertNextCell (VTK_TRIANGLE, 3, aPoints);
|
||||||
const vtkIdType aShapeIDVTK = theShapeID;
|
insertNextSubShapeId (theShapeID, theMeshType);
|
||||||
mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
|
|
||||||
const vtkIdType aType = theMeshType;
|
|
||||||
myMeshTypes->InsertNextTupleValue (&aType);
|
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <vtkPolyData.h>
|
#include <vtkPolyData.h>
|
||||||
#include <vtkSmartPointer.h>
|
#include <vtkSmartPointer.h>
|
||||||
|
#include <vtkIdTypeArray.h>
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
@@ -105,6 +106,23 @@ public: //! @name Specific methods
|
|||||||
vtkPolyData* getVtkPolyData() const
|
vtkPolyData* getVtkPolyData() const
|
||||||
{ return myPolyData; }
|
{ return myPolyData; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//! Wrapper over vtkGenericDataArray::InsertNextTypedTuple().
|
||||||
|
void insertNextSubShapeId (IVtk_IdType theShapeID,
|
||||||
|
IVtk_MeshType theMeshType)
|
||||||
|
{
|
||||||
|
const vtkIdType aShapeIDVTK = theShapeID;
|
||||||
|
const vtkIdType aType = theMeshType;
|
||||||
|
#if (VTK_MAJOR_VERSION > 7) || (VTK_MAJOR_VERSION == 7 && VTK_MINOR_VERSION >= 1)
|
||||||
|
mySubShapeIDs->InsertNextTypedTuple (&aShapeIDVTK);
|
||||||
|
myMeshTypes->InsertNextTypedTuple (&aType);
|
||||||
|
#else
|
||||||
|
mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
|
||||||
|
myMeshTypes->InsertNextTupleValue (&aType);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vtkSmartPointer< vtkPolyData > myPolyData; //!< Shape geometry as vtkPolyData
|
vtkSmartPointer< vtkPolyData > myPolyData; //!< Shape geometry as vtkPolyData
|
||||||
vtkSmartPointer< vtkIdTypeArray > mySubShapeIDs; //!< Array of sub-shapes ids
|
vtkSmartPointer< vtkIdTypeArray > mySubShapeIDs; //!< Array of sub-shapes ids
|
||||||
|
@@ -7,5 +7,6 @@ Image_Format.hxx
|
|||||||
Image_PixMap.cxx
|
Image_PixMap.cxx
|
||||||
Image_PixMap.hxx
|
Image_PixMap.hxx
|
||||||
Image_PixMapData.hxx
|
Image_PixMapData.hxx
|
||||||
|
Image_PixMapTypedData.hxx
|
||||||
Image_VideoRecorder.cxx
|
Image_VideoRecorder.cxx
|
||||||
Image_VideoRecorder.hxx
|
Image_VideoRecorder.hxx
|
||||||
|
@@ -38,7 +38,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Initializer.
|
//! Initializer.
|
||||||
void Init (const Handle(NCollection_BaseAllocator)& theAlloc,
|
bool Init (const Handle(NCollection_BaseAllocator)& theAlloc,
|
||||||
const Standard_Size theSizeBPP,
|
const Standard_Size theSizeBPP,
|
||||||
const Standard_Size theSizeX,
|
const Standard_Size theSizeX,
|
||||||
const Standard_Size theSizeY,
|
const Standard_Size theSizeY,
|
||||||
@@ -59,6 +59,16 @@ public:
|
|||||||
Allocate (mySize);
|
Allocate (mySize);
|
||||||
}
|
}
|
||||||
SetTopDown (TopToDown == 1);
|
SetTopDown (TopToDown == 1);
|
||||||
|
return !IsEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Reset all values to zeros.
|
||||||
|
void ZeroData()
|
||||||
|
{
|
||||||
|
if (myData != NULL)
|
||||||
|
{
|
||||||
|
memset (myData, 0, mySize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! @return data pointer to requested row (first column).
|
//! @return data pointer to requested row (first column).
|
||||||
|
64
src/Image/Image_PixMapTypedData.hxx
Normal file
64
src/Image/Image_PixMapTypedData.hxx
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
// Copyright (c) 2019 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.
|
||||||
|
|
||||||
|
#ifndef _Image_PixMapTypedData_Header
|
||||||
|
#define _Image_PixMapTypedData_Header
|
||||||
|
|
||||||
|
#include <Image_PixMapData.hxx>
|
||||||
|
|
||||||
|
//! Structure to manage image buffer with predefined pixel type.
|
||||||
|
template<typename PixelType_t>
|
||||||
|
class Image_PixMapTypedData : public Image_PixMapData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Empty constructor.
|
||||||
|
Image_PixMapTypedData() {}
|
||||||
|
|
||||||
|
//! Initializer.
|
||||||
|
bool Init (const Handle(NCollection_BaseAllocator)& theAlloc,
|
||||||
|
Standard_Size theSizeX,
|
||||||
|
Standard_Size theSizeY,
|
||||||
|
Standard_Size theSizeRowBytes = 0,
|
||||||
|
Standard_Byte* theDataPtr = 0)
|
||||||
|
{
|
||||||
|
const Standard_Size aSizeBPP = sizeof(PixelType_t);
|
||||||
|
return Image_PixMapData::Init (theAlloc, aSizeBPP, theSizeX, theSizeY, theSizeRowBytes, theDataPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Reset all values to specified one.
|
||||||
|
void Init (const PixelType_t& theValue)
|
||||||
|
{
|
||||||
|
for (Standard_Size aRowIter = 0; aRowIter < SizeY; ++aRowIter)
|
||||||
|
{
|
||||||
|
for (Standard_Size aColIter = 0; aColIter < SizeX; ++aColIter)
|
||||||
|
{
|
||||||
|
ChangeValue (aRowIter, aColIter) = theValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! @return data pointer to requested row (first column).
|
||||||
|
const PixelType_t* Row (Standard_Size theRow) const { return (const PixelType_t* )Image_PixMapData::Row (theRow); }
|
||||||
|
|
||||||
|
//! @return data pointer to requested row (first column).
|
||||||
|
PixelType_t* ChangeRow (Standard_Size theRow) { return (PixelType_t* )Image_PixMapData::ChangeRow (theRow); }
|
||||||
|
|
||||||
|
//! @return data pointer to requested position.
|
||||||
|
const PixelType_t& Value (Standard_Size theRow, Standard_Size theCol) const { return *(const PixelType_t* )Image_PixMapData::Value (theRow, theCol); }
|
||||||
|
|
||||||
|
//! @return data pointer to requested position.
|
||||||
|
PixelType_t& ChangeValue (Standard_Size theRow, Standard_Size theCol) { return *(PixelType_t* )Image_PixMapData::ChangeValue (theRow, theCol); }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _Image_PixMapTypedData_Header
|
@@ -27,8 +27,11 @@
|
|||||||
* Purpose: The class Array2 represents bi-dimensional arrays
|
* Purpose: The class Array2 represents bi-dimensional arrays
|
||||||
* of fixed size known at run time.
|
* of fixed size known at run time.
|
||||||
* The ranges of indices are user defined.
|
* The ranges of indices are user defined.
|
||||||
*
|
*
|
||||||
* Warning: Programs clients of such class must be independant
|
* Class allocates one 1D array storing full data (all Rows and Columns)
|
||||||
|
* and extra 1D array storing pointers to each Row.
|
||||||
|
*
|
||||||
|
* Warning: Programs clients of such class must be independent
|
||||||
* of the range of the first element. Then, a C++ for
|
* of the range of the first element. Then, a C++ for
|
||||||
* loop must be written like this
|
* loop must be written like this
|
||||||
*
|
*
|
||||||
@@ -85,6 +88,20 @@ public:
|
|||||||
public:
|
public:
|
||||||
// ---------- PUBLIC METHODS ------------
|
// ---------- PUBLIC METHODS ------------
|
||||||
|
|
||||||
|
//! Empty constructor; should be used with caution.
|
||||||
|
//! @sa methods Resize() and Move().
|
||||||
|
NCollection_Array2()
|
||||||
|
: myLowerRow (1),
|
||||||
|
myUpperRow (0),
|
||||||
|
myLowerCol (1),
|
||||||
|
myUpperCol (0),
|
||||||
|
myData (NULL),
|
||||||
|
myStart (NULL),
|
||||||
|
myDeletable(false)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
NCollection_Array2(const Standard_Integer theRowLower,
|
NCollection_Array2(const Standard_Integer theRowLower,
|
||||||
const Standard_Integer theRowUpper,
|
const Standard_Integer theRowUpper,
|
||||||
@@ -109,6 +126,23 @@ public:
|
|||||||
*this = theOther;
|
*this = theOther;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef OCCT_NO_RVALUE_REFERENCE
|
||||||
|
//! Move constructor
|
||||||
|
NCollection_Array2 (NCollection_Array2&& theOther)
|
||||||
|
: myLowerRow (theOther.myLowerRow),
|
||||||
|
myUpperRow (theOther.myUpperRow),
|
||||||
|
myLowerCol (theOther.myLowerRow),
|
||||||
|
myUpperCol (theOther.myUpperCol),
|
||||||
|
myData (theOther.myData),
|
||||||
|
myStart (theOther.myStart),
|
||||||
|
myDeletable(theOther.myDeletable)
|
||||||
|
{
|
||||||
|
theOther.myStart = NULL;
|
||||||
|
theOther.myData = NULL;
|
||||||
|
theOther.myDeletable = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//! C array-based constructor
|
//! C array-based constructor
|
||||||
NCollection_Array2(const TheItemType& theBegin,
|
NCollection_Array2(const TheItemType& theBegin,
|
||||||
const Standard_Integer theRowLower,
|
const Standard_Integer theRowLower,
|
||||||
@@ -138,15 +172,19 @@ public:
|
|||||||
{ return Length(); }
|
{ return Length(); }
|
||||||
//! Length (number of items)
|
//! Length (number of items)
|
||||||
Standard_Integer Length (void) const
|
Standard_Integer Length (void) const
|
||||||
{ return RowLength() * ColLength(); }
|
{ return NbRows() * NbColumns(); }
|
||||||
|
|
||||||
|
//! Returns number of rows
|
||||||
|
Standard_Integer NbRows() const { return myUpperRow - myLowerRow + 1; }
|
||||||
|
|
||||||
|
//! Returns number of columns
|
||||||
|
Standard_Integer NbColumns() const { return myUpperCol - myLowerCol + 1; }
|
||||||
|
|
||||||
//! Returns length of the row, i.e. number of columns
|
//! Returns length of the row, i.e. number of columns
|
||||||
Standard_Integer RowLength (void) const
|
Standard_Integer RowLength() const { return NbColumns(); }
|
||||||
{ return (myUpperCol-myLowerCol+1); }
|
|
||||||
|
|
||||||
//! Returns length of the column, i.e. number of rows
|
//! Returns length of the column, i.e. number of rows
|
||||||
Standard_Integer ColLength (void) const
|
Standard_Integer ColLength() const { return NbRows(); }
|
||||||
{ return (myUpperRow-myLowerRow+1); }
|
|
||||||
|
|
||||||
//! LowerRow
|
//! LowerRow
|
||||||
Standard_Integer LowerRow (void) const
|
Standard_Integer LowerRow (void) const
|
||||||
@@ -179,12 +217,53 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Move assignment.
|
||||||
|
//! This array will borrow all the data from theOther.
|
||||||
|
//! The moved object will be left unitialized and should not be used anymore.
|
||||||
|
NCollection_Array2& Move (NCollection_Array2& theOther)
|
||||||
|
{
|
||||||
|
if (&theOther == this)
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myDeletable)
|
||||||
|
{
|
||||||
|
delete[] myStart;
|
||||||
|
}
|
||||||
|
if (myData != NULL)
|
||||||
|
{
|
||||||
|
delete[] &(myData[myLowerRow]);
|
||||||
|
}
|
||||||
|
|
||||||
|
myLowerRow = theOther.myLowerRow;
|
||||||
|
myUpperRow = theOther.myUpperRow;
|
||||||
|
myLowerCol = theOther.myLowerRow;
|
||||||
|
myUpperCol = theOther.myUpperCol;
|
||||||
|
myData = theOther.myData;
|
||||||
|
myStart = theOther.myStart;
|
||||||
|
myDeletable = theOther.myDeletable;
|
||||||
|
|
||||||
|
theOther.myStart = NULL;
|
||||||
|
theOther.myData = NULL;
|
||||||
|
theOther.myDeletable = Standard_False;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
//! Assignment operator
|
//! Assignment operator
|
||||||
NCollection_Array2& operator= (const NCollection_Array2& theOther)
|
NCollection_Array2& operator= (const NCollection_Array2& theOther)
|
||||||
{
|
{
|
||||||
return Assign (theOther);
|
return Assign (theOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef OCCT_NO_RVALUE_REFERENCE
|
||||||
|
//! Move assignment operator; @sa Move()
|
||||||
|
NCollection_Array2& operator= (NCollection_Array2&& theOther)
|
||||||
|
{
|
||||||
|
return Move (theOther);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//! Constant value access
|
//! Constant value access
|
||||||
const TheItemType& Value (const Standard_Integer theRow,
|
const TheItemType& Value (const Standard_Integer theRow,
|
||||||
const Standard_Integer theCol) const
|
const Standard_Integer theCol) const
|
||||||
@@ -222,12 +301,86 @@ public:
|
|||||||
theCol < myLowerCol || theCol > myUpperCol, "NCollection_Array2::SetValue");
|
theCol < myLowerCol || theCol > myUpperCol, "NCollection_Array2::SetValue");
|
||||||
myData[theRow][theCol] = theItem;
|
myData[theRow][theCol] = theItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Resizes the array to specified bounds.
|
||||||
|
//! No re-allocation will be done if length of array does not change,
|
||||||
|
//! but existing values will not be discarded if theToCopyData set to FALSE.
|
||||||
|
//! @param theRowLower new lower Row of array
|
||||||
|
//! @param theRowUpper new upper Row of array
|
||||||
|
//! @param theColLower new lower Column of array
|
||||||
|
//! @param theColUpper new upper Column of array
|
||||||
|
//! @param theToCopyData flag to copy existing data into new array
|
||||||
|
void Resize (Standard_Integer theRowLower,
|
||||||
|
Standard_Integer theRowUpper,
|
||||||
|
Standard_Integer theColLower,
|
||||||
|
Standard_Integer theColUpper,
|
||||||
|
Standard_Boolean theToCopyData)
|
||||||
|
{
|
||||||
|
Standard_RangeError_Raise_if (theRowUpper < theRowLower
|
||||||
|
|| theColUpper < theColLower, "NCollection_Array2::Resize");
|
||||||
|
const Standard_Integer anOldNbRows = NbRows();
|
||||||
|
const Standard_Integer anOldNbCols = NbColumns();
|
||||||
|
const Standard_Integer aLowerRowOld = myLowerRow;
|
||||||
|
const Standard_Integer aLowerColOld = myLowerCol;
|
||||||
|
const Standard_Integer aNewNbRows = theRowUpper - theRowLower + 1;
|
||||||
|
const Standard_Integer aNewNbCols = theColUpper - theColLower + 1;
|
||||||
|
|
||||||
|
TheItemType* aStartOld = myStart;
|
||||||
|
TheItemType** aTableOld = myData != NULL ? myData + aLowerRowOld : NULL;
|
||||||
|
myLowerRow = theRowLower;
|
||||||
|
myUpperRow = theRowUpper;
|
||||||
|
myLowerCol = theColLower;
|
||||||
|
myUpperCol = theColUpper;
|
||||||
|
if (aNewNbRows == anOldNbRows
|
||||||
|
&& aNewNbCols == anOldNbCols)
|
||||||
|
{
|
||||||
|
if (myLowerCol != aLowerColOld)
|
||||||
|
{
|
||||||
|
fillIndexTable (aTableOld);
|
||||||
|
}
|
||||||
|
myData = aTableOld - myLowerRow;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myDeletable
|
||||||
|
&& !theToCopyData)
|
||||||
|
{
|
||||||
|
delete[] aStartOld;
|
||||||
|
}
|
||||||
|
delete[] aTableOld;
|
||||||
|
|
||||||
|
Allocate();
|
||||||
|
if (!theToCopyData)
|
||||||
|
{
|
||||||
|
myDeletable = Standard_True;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Standard_Integer aNbRowsToCopy = Min (anOldNbRows, aNewNbRows);
|
||||||
|
const Standard_Integer aNbColsToCopy = Min (anOldNbCols, aNewNbCols);
|
||||||
|
for (Standard_Integer aRowIter = 0; aRowIter < aNbRowsToCopy; ++aRowIter)
|
||||||
|
{
|
||||||
|
for (Standard_Integer aColIter = 0; aColIter < aNbColsToCopy; ++aColIter)
|
||||||
|
{
|
||||||
|
myStart[size_t(aRowIter) * size_t(aNewNbCols) + size_t(aColIter)] = aStartOld[size_t(aRowIter) * size_t(anOldNbCols) + size_t(aColIter)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myDeletable)
|
||||||
|
{
|
||||||
|
delete[] aStartOld;
|
||||||
|
}
|
||||||
|
myDeletable = Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
//! Destructor - releases the memory
|
//! Destructor - releases the memory
|
||||||
~NCollection_Array2 (void)
|
~NCollection_Array2 (void)
|
||||||
{
|
{
|
||||||
if (myDeletable) delete [] myStart;
|
if (myDeletable) delete [] myStart;
|
||||||
delete [] &(myData[myLowerRow]);
|
if (myData != NULL)
|
||||||
|
{
|
||||||
|
delete[] &(myData[myLowerRow]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -236,28 +389,37 @@ public:
|
|||||||
//! Allocate memory for the array, set up indirection table
|
//! Allocate memory for the array, set up indirection table
|
||||||
void Allocate (void)
|
void Allocate (void)
|
||||||
{
|
{
|
||||||
const Standard_Integer iRowSize = myUpperCol - myLowerCol + 1;
|
const Standard_Integer aNbRows = NbRows();
|
||||||
const Standard_Integer iColSize = myUpperRow - myLowerRow + 1;
|
const Standard_Integer aNbCols = NbColumns();
|
||||||
Standard_RangeError_Raise_if (iRowSize <= 0 || iColSize <= 0, "NCollection_Array2::Allocate");
|
Standard_RangeError_Raise_if (aNbRows <= 0 || aNbCols <= 0, "NCollection_Array2::Allocate");
|
||||||
if (myDeletable) {
|
if (myDeletable)
|
||||||
|
{
|
||||||
// allocation of the data in the array
|
// allocation of the data in the array
|
||||||
myStart = new TheItemType[iRowSize * iColSize];
|
myStart = new TheItemType[size_t(aNbRows) * size_t(aNbCols)];
|
||||||
Standard_OutOfMemory_Raise_if (!myStart, "NCollection_Array2 : Allocation failed");
|
Standard_OutOfMemory_Raise_if (!myStart, "NCollection_Array2 : Allocation failed");
|
||||||
}
|
}
|
||||||
// else myStart is set to the beginning of the given array
|
// else myStart is set to the beginning of the given array
|
||||||
TheItemType** pTable = new TheItemType* [iColSize];
|
|
||||||
Standard_OutOfMemory_Raise_if (!pTable, "NCollection_Array2 : Allocation failed");
|
|
||||||
|
|
||||||
// Items of pTable point to the '0'th items in the rows of the array
|
TheItemType** pTable = new TheItemType* [aNbRows];
|
||||||
TheItemType* pRow = myStart - myLowerCol;
|
Standard_OutOfMemory_Raise_if (!pTable, "NCollection_Array2 : Allocation failed");
|
||||||
for (Standard_Integer i = 0; i < iColSize; i++)
|
fillIndexTable (pTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Fill index table for accessing array elements.
|
||||||
|
void fillIndexTable (TheItemType** theTable)
|
||||||
|
{
|
||||||
|
// Items of table point to the 0th items in the rows of the array
|
||||||
|
TheItemType* aRow = myStart - myLowerCol;
|
||||||
|
const Standard_Integer aNbRows = NbRows();
|
||||||
|
const Standard_Size aNbCols = NbColumns();
|
||||||
|
for (Standard_Integer aRowIter = 0; aRowIter < aNbRows; ++aRowIter)
|
||||||
{
|
{
|
||||||
pTable[i] = pRow;
|
theTable[aRowIter] = aRow;
|
||||||
pRow += iRowSize;
|
aRow += aNbCols;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set myData to the '0'th row pointer of the pTable
|
// Set myData to the 0th row pointer of the table
|
||||||
myData = pTable - myLowerRow;
|
myData = theTable - myLowerRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -177,7 +177,8 @@ Standard_EXPORT void IncAllocator_PrintAlive()
|
|||||||
//purpose : Constructor
|
//purpose : Constructor
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
NCollection_IncAllocator::NCollection_IncAllocator (const size_t theBlockSize)
|
NCollection_IncAllocator::NCollection_IncAllocator (size_t theBlockSize)
|
||||||
|
: myMutex (NULL)
|
||||||
{
|
{
|
||||||
#ifdef ALLOC_TRACK_USAGE
|
#ifdef ALLOC_TRACK_USAGE
|
||||||
printf ("\n..NCollection_IncAllocator: Created (%x)\n",this);
|
printf ("\n..NCollection_IncAllocator: Created (%x)\n",this);
|
||||||
@@ -207,6 +208,7 @@ NCollection_IncAllocator::NCollection_IncAllocator (const size_t theBlockSize)
|
|||||||
|
|
||||||
NCollection_IncAllocator::~NCollection_IncAllocator ()
|
NCollection_IncAllocator::~NCollection_IncAllocator ()
|
||||||
{
|
{
|
||||||
|
delete myMutex;
|
||||||
#ifdef OCCT_DEBUG
|
#ifdef OCCT_DEBUG
|
||||||
if (IS_DEBUG)
|
if (IS_DEBUG)
|
||||||
Debug_Destroy(this);
|
Debug_Destroy(this);
|
||||||
@@ -215,6 +217,24 @@ NCollection_IncAllocator::~NCollection_IncAllocator ()
|
|||||||
free (myFirstBlock);
|
free (myFirstBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetThreadSafe
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void NCollection_IncAllocator::SetThreadSafe (bool theIsThreadSafe)
|
||||||
|
{
|
||||||
|
if (myMutex == NULL
|
||||||
|
&& theIsThreadSafe)
|
||||||
|
{
|
||||||
|
myMutex = new Standard_Mutex();
|
||||||
|
}
|
||||||
|
else if (!theIsThreadSafe)
|
||||||
|
{
|
||||||
|
delete myMutex;
|
||||||
|
myMutex = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Allocate
|
//function : Allocate
|
||||||
//purpose : allocate a memory
|
//purpose : allocate a memory
|
||||||
@@ -226,6 +246,7 @@ void * NCollection_IncAllocator::Allocate (const size_t aSize)
|
|||||||
aligned_t * aResult = NULL;
|
aligned_t * aResult = NULL;
|
||||||
const size_t cSize = aSize ? IMEM_SIZE(aSize) : 0;
|
const size_t cSize = aSize ? IMEM_SIZE(aSize) : 0;
|
||||||
|
|
||||||
|
Standard_Mutex::Sentry aLock (myMutex);
|
||||||
if (cSize > mySize) {
|
if (cSize > mySize) {
|
||||||
/* If the requested size exceeds normal allocation size, allocate
|
/* If the requested size exceeds normal allocation size, allocate
|
||||||
a separate block and place it as the head of the list */
|
a separate block and place it as the head of the list */
|
||||||
@@ -286,10 +307,12 @@ void * NCollection_IncAllocator::Reallocate (void * theAddress,
|
|||||||
// Check that the dummy parameters are OK
|
// Check that the dummy parameters are OK
|
||||||
if (theAddress == NULL || oldSize == 0)
|
if (theAddress == NULL || oldSize == 0)
|
||||||
return Allocate (newSize);
|
return Allocate (newSize);
|
||||||
|
|
||||||
const size_t cOldSize = IMEM_SIZE(oldSize);
|
const size_t cOldSize = IMEM_SIZE(oldSize);
|
||||||
const size_t cNewSize = newSize ? IMEM_SIZE(newSize) : 0;
|
const size_t cNewSize = newSize ? IMEM_SIZE(newSize) : 0;
|
||||||
aligned_t * anAddress = (aligned_t *) theAddress;
|
aligned_t * anAddress = (aligned_t *) theAddress;
|
||||||
|
|
||||||
|
Standard_Mutex::Sentry aLock (myMutex);
|
||||||
// We check only the LAST allocation to do the real extension/contraction
|
// We check only the LAST allocation to do the real extension/contraction
|
||||||
if (anAddress + cOldSize == myFirstBlock -> p_free_space) {
|
if (anAddress + cOldSize == myFirstBlock -> p_free_space) {
|
||||||
myFirstBlock -> p_free_space = anAddress;
|
myFirstBlock -> p_free_space = anAddress;
|
||||||
@@ -372,6 +395,7 @@ void NCollection_IncAllocator::Clean ()
|
|||||||
|
|
||||||
void NCollection_IncAllocator::Reset (const Standard_Boolean doReleaseMem)
|
void NCollection_IncAllocator::Reset (const Standard_Boolean doReleaseMem)
|
||||||
{
|
{
|
||||||
|
Standard_Mutex::Sentry aLock (myMutex);
|
||||||
if (doReleaseMem)
|
if (doReleaseMem)
|
||||||
Clean();
|
Clean();
|
||||||
else {
|
else {
|
||||||
|
@@ -18,20 +18,26 @@
|
|||||||
|
|
||||||
#include <NCollection_BaseAllocator.hxx>
|
#include <NCollection_BaseAllocator.hxx>
|
||||||
|
|
||||||
|
class Standard_Mutex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class NCollection_IncAllocator - incremental memory allocator. This class
|
* Class NCollection_IncAllocator - incremental memory allocator. This class
|
||||||
* allocates memory on request returning the pointer to an allocated
|
* allocates memory on request returning the pointer to an allocated
|
||||||
* block. This memory is never returned to the system until the allocator is
|
* block. This memory is never returned to the system until the allocator is
|
||||||
* destroyed.
|
* destroyed.
|
||||||
*
|
*
|
||||||
* By comparison with the standard new() and malloc() calls, this method is
|
* By comparison with the standard new() and malloc() calls, this method is
|
||||||
* faster and consumes very small additional memory to maintain the heap.
|
* faster and consumes very small additional memory to maintain the heap.
|
||||||
*
|
*
|
||||||
* All pointers returned by Allocate() are aligned to the size of the data
|
* All pointers returned by Allocate() are aligned to the size of the data
|
||||||
* type "aligned_t". To modify the size of memory blocks requested from the
|
* type "aligned_t". To modify the size of memory blocks requested from the
|
||||||
* OS, use the parameter of the constructor (measured in bytes); if this
|
* OS, use the parameter of the constructor (measured in bytes); if this
|
||||||
* parameter is smaller than 25 bytes on 32bit or 49 bytes on 64bit, the
|
* parameter is smaller than 25 bytes on 32bit or 49 bytes on 64bit, the
|
||||||
* block size will be the default 24 kbytes
|
* block size will be the default 24 kbytes
|
||||||
|
*
|
||||||
|
* Note that this allocator is most suitable for single-threaded algorithms
|
||||||
|
* (consider creating dedicated allocators per working thread),
|
||||||
|
* and thread-safety of allocations is DISABLED by default (see SetThreadSafe()).
|
||||||
*/
|
*/
|
||||||
class NCollection_IncAllocator : public NCollection_BaseAllocator
|
class NCollection_IncAllocator : public NCollection_BaseAllocator
|
||||||
{
|
{
|
||||||
@@ -41,8 +47,13 @@ class NCollection_IncAllocator : public NCollection_BaseAllocator
|
|||||||
|
|
||||||
// ---------- PUBLIC METHODS ----------
|
// ---------- PUBLIC METHODS ----------
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor.
|
||||||
Standard_EXPORT NCollection_IncAllocator (const size_t theBlockSize = DefaultBlockSize);
|
//! Note that this constructor does NOT setup mutex for using allocator concurrently from different threads,
|
||||||
|
//! see SetThreadSafe() method.
|
||||||
|
Standard_EXPORT NCollection_IncAllocator (size_t theBlockSize = DefaultBlockSize);
|
||||||
|
|
||||||
|
//! Setup mutex for thread-safe allocations.
|
||||||
|
Standard_EXPORT void SetThreadSafe (bool theIsThreadSafe = true);
|
||||||
|
|
||||||
//! Allocate memory with given size. Returns NULL on failure
|
//! Allocate memory with given size. Returns NULL on failure
|
||||||
Standard_EXPORT virtual void* Allocate (const size_t size) Standard_OVERRIDE;
|
Standard_EXPORT virtual void* Allocate (const size_t size) Standard_OVERRIDE;
|
||||||
@@ -105,6 +116,7 @@ class NCollection_IncAllocator : public NCollection_BaseAllocator
|
|||||||
};
|
};
|
||||||
protected:
|
protected:
|
||||||
// --------- PROTECTED FIELDS ---------
|
// --------- PROTECTED FIELDS ---------
|
||||||
|
Standard_Mutex* myMutex;
|
||||||
IBlock * myFirstBlock;
|
IBlock * myFirstBlock;
|
||||||
size_t mySize;
|
size_t mySize;
|
||||||
size_t myMemSize;
|
size_t myMemSize;
|
||||||
|
@@ -32,8 +32,6 @@
|
|||||||
|
|
||||||
#include <Image_PixMap.hxx>
|
#include <Image_PixMap.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_AspectFace, OpenGl_Element)
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
//! Initialize default material in this way for backward compatibility.
|
//! Initialize default material in this way for backward compatibility.
|
||||||
@@ -68,7 +66,6 @@ OpenGl_AspectFace::OpenGl_AspectFace()
|
|||||||
THE_DEFAULT_MATERIAL, THE_DEFAULT_MATERIAL)),
|
THE_DEFAULT_MATERIAL, THE_DEFAULT_MATERIAL)),
|
||||||
myShadingModel (Graphic3d_TOSM_UNLIT)
|
myShadingModel (Graphic3d_TOSM_UNLIT)
|
||||||
{
|
{
|
||||||
myAspectEdge = new OpenGl_AspectLine();
|
|
||||||
myAspect->SetShadingModel (myShadingModel);
|
myAspect->SetShadingModel (myShadingModel);
|
||||||
myAspect->SetHatchStyle (Handle(Graphic3d_HatchStyle)());
|
myAspect->SetHatchStyle (Handle(Graphic3d_HatchStyle)());
|
||||||
}
|
}
|
||||||
@@ -80,8 +77,6 @@ OpenGl_AspectFace::OpenGl_AspectFace()
|
|||||||
OpenGl_AspectFace::OpenGl_AspectFace (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
|
OpenGl_AspectFace::OpenGl_AspectFace (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
|
||||||
: myShadingModel (Graphic3d_TOSM_DEFAULT)
|
: myShadingModel (Graphic3d_TOSM_DEFAULT)
|
||||||
{
|
{
|
||||||
myAspectEdge = new OpenGl_AspectLine();
|
|
||||||
|
|
||||||
SetAspect (theAspect);
|
SetAspect (theAspect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,9 +97,9 @@ void OpenGl_AspectFace::SetAspect (const Handle(Graphic3d_AspectFillArea3d)& the
|
|||||||
? theAspect->ShadingModel()
|
? theAspect->ShadingModel()
|
||||||
: Graphic3d_TOSM_UNLIT;
|
: Graphic3d_TOSM_UNLIT;
|
||||||
|
|
||||||
myAspectEdge->Aspect()->SetColor (theAspect->EdgeColor());
|
myAspectEdge.Aspect()->SetColor (theAspect->EdgeColor());
|
||||||
myAspectEdge->Aspect()->SetType (theAspect->EdgeLineType());
|
myAspectEdge.Aspect()->SetType (theAspect->EdgeLineType());
|
||||||
myAspectEdge->Aspect()->SetWidth (theAspect->EdgeWidth());
|
myAspectEdge.Aspect()->SetWidth (theAspect->EdgeWidth());
|
||||||
|
|
||||||
// update texture binding
|
// update texture binding
|
||||||
myResources.UpdateTexturesRediness (myAspect->TextureSet());
|
myResources.UpdateTexturesRediness (myAspect->TextureSet());
|
||||||
|
@@ -28,7 +28,7 @@ class OpenGl_Texture;
|
|||||||
//! The element holding Graphic3d_AspectFillArea3d.
|
//! The element holding Graphic3d_AspectFillArea3d.
|
||||||
class OpenGl_AspectFace : public OpenGl_Element
|
class OpenGl_AspectFace : public OpenGl_Element
|
||||||
{
|
{
|
||||||
DEFINE_STANDARD_RTTIEXT(OpenGl_AspectFace, OpenGl_Element)
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Empty constructor.
|
//! Empty constructor.
|
||||||
@@ -44,10 +44,10 @@ public:
|
|||||||
Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
|
Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
|
||||||
|
|
||||||
//! Set edge aspect.
|
//! Set edge aspect.
|
||||||
void SetAspectEdge (const Handle(OpenGl_AspectLine)& theAspectEdge) { myAspectEdge = theAspectEdge; }
|
void SetAspectEdge (const OpenGl_AspectLine* theAspectEdge) { myAspectEdge = *theAspectEdge; }
|
||||||
|
|
||||||
//! @return edge aspect.
|
//! @return edge aspect.
|
||||||
const Handle(OpenGl_AspectLine)& AspectEdge() const { return myAspectEdge; }
|
const OpenGl_AspectLine* AspectEdge() const { return &myAspectEdge; }
|
||||||
|
|
||||||
//! Returns Shading Model.
|
//! Returns Shading Model.
|
||||||
Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
|
Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
|
||||||
@@ -140,7 +140,7 @@ protected:
|
|||||||
} myResources;
|
} myResources;
|
||||||
|
|
||||||
Handle(Graphic3d_AspectFillArea3d) myAspect;
|
Handle(Graphic3d_AspectFillArea3d) myAspect;
|
||||||
Handle(OpenGl_AspectLine) myAspectEdge;
|
OpenGl_AspectLine myAspectEdge;
|
||||||
Graphic3d_TypeOfShadingModel myShadingModel;
|
Graphic3d_TypeOfShadingModel myShadingModel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@@ -21,8 +21,6 @@
|
|||||||
#include <OpenGl_ShaderProgram.hxx>
|
#include <OpenGl_ShaderProgram.hxx>
|
||||||
#include <OpenGl_Workspace.hxx>
|
#include <OpenGl_Workspace.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_AspectLine, OpenGl_Element)
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
static const TCollection_AsciiString THE_EMPTY_KEY;
|
static const TCollection_AsciiString THE_EMPTY_KEY;
|
||||||
|
@@ -26,7 +26,6 @@ class OpenGl_ShaderProgram;
|
|||||||
//! The element holding Graphic3d_AspectLine3d.
|
//! The element holding Graphic3d_AspectLine3d.
|
||||||
class OpenGl_AspectLine : public OpenGl_Element
|
class OpenGl_AspectLine : public OpenGl_Element
|
||||||
{
|
{
|
||||||
DEFINE_STANDARD_RTTIEXT(OpenGl_AspectLine, OpenGl_Element)
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Empty constructor.
|
//! Empty constructor.
|
||||||
|
@@ -27,8 +27,6 @@
|
|||||||
#include <NCollection_Vec4.hxx>
|
#include <NCollection_Vec4.hxx>
|
||||||
#include <TColStd_HArray1OfByte.hxx>
|
#include <TColStd_HArray1OfByte.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_AspectMarker, OpenGl_Element)
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
static const TCollection_AsciiString THE_EMPTY_KEY;
|
static const TCollection_AsciiString THE_EMPTY_KEY;
|
||||||
|
@@ -29,7 +29,6 @@ class OpenGl_ShaderProgram;
|
|||||||
//! The element holding Graphic3d_AspectMarker3d.
|
//! The element holding Graphic3d_AspectMarker3d.
|
||||||
class OpenGl_AspectMarker : public OpenGl_Element
|
class OpenGl_AspectMarker : public OpenGl_Element
|
||||||
{
|
{
|
||||||
DEFINE_STANDARD_RTTIEXT(OpenGl_AspectMarker, OpenGl_Element)
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Empty constructor.
|
//! Empty constructor.
|
||||||
|
@@ -21,8 +21,6 @@
|
|||||||
#include <OpenGl_ShaderManager.hxx>
|
#include <OpenGl_ShaderManager.hxx>
|
||||||
#include <OpenGl_ShaderProgram.hxx>
|
#include <OpenGl_ShaderProgram.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_AspectText, OpenGl_Element)
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
static const TCollection_AsciiString THE_EMPTY_KEY;
|
static const TCollection_AsciiString THE_EMPTY_KEY;
|
||||||
|
@@ -28,7 +28,7 @@ class OpenGl_ShaderProgram;
|
|||||||
//! Text representation parameters
|
//! Text representation parameters
|
||||||
class OpenGl_AspectText : public OpenGl_Element
|
class OpenGl_AspectText : public OpenGl_Element
|
||||||
{
|
{
|
||||||
DEFINE_STANDARD_RTTIEXT(OpenGl_AspectText, OpenGl_Element)
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Empty constructor.
|
//! Empty constructor.
|
||||||
|
@@ -96,10 +96,10 @@ void OpenGl_BVHTreeSelector::SetViewportSize (Standard_Integer theViewportWidth,
|
|||||||
Standard_Integer theViewportHeight,
|
Standard_Integer theViewportHeight,
|
||||||
Standard_Real theResolutionRatio)
|
Standard_Real theResolutionRatio)
|
||||||
{
|
{
|
||||||
myViewportHeight = theViewportHeight;
|
myViewportHeight = theViewportHeight > 0 ? theViewportHeight : 1;
|
||||||
myViewportWidth = theViewportWidth;
|
myViewportWidth = theViewportWidth > 0 ? theViewportWidth : 1;
|
||||||
myPixelSize = Max (theResolutionRatio / theViewportHeight,
|
myPixelSize = Max (theResolutionRatio / myViewportHeight,
|
||||||
theResolutionRatio / theViewportWidth);
|
theResolutionRatio / myViewportWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
@@ -21,8 +21,6 @@
|
|||||||
#include <OpenGl_View.hxx>
|
#include <OpenGl_View.hxx>
|
||||||
#include <Graphic3d_TextureParams.hxx>
|
#include <Graphic3d_TextureParams.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_BackgroundArray, OpenGl_PrimitiveArray)
|
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// method : Constructor
|
// method : Constructor
|
||||||
// purpose :
|
// purpose :
|
||||||
@@ -339,7 +337,7 @@ Standard_Boolean OpenGl_BackgroundArray::createTextureArray (const Handle(OpenGl
|
|||||||
|
|
||||||
// Get texture parameters
|
// Get texture parameters
|
||||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||||
const Handle(OpenGl_AspectFace)& anAspectFace = theWorkspace->AspectFace();
|
const OpenGl_AspectFace* anAspectFace = theWorkspace->AspectFace();
|
||||||
GLfloat aTextureWidth = (GLfloat )anAspectFace->TextureSet (aCtx)->First()->SizeX();
|
GLfloat aTextureWidth = (GLfloat )anAspectFace->TextureSet (aCtx)->First()->SizeX();
|
||||||
GLfloat aTextureHeight = (GLfloat )anAspectFace->TextureSet (aCtx)->First()->SizeY();
|
GLfloat aTextureHeight = (GLfloat )anAspectFace->TextureSet (aCtx)->First()->SizeY();
|
||||||
|
|
||||||
|
@@ -28,7 +28,6 @@
|
|||||||
//! gradient or texture background rendering.
|
//! gradient or texture background rendering.
|
||||||
class OpenGl_BackgroundArray : public OpenGl_PrimitiveArray
|
class OpenGl_BackgroundArray : public OpenGl_PrimitiveArray
|
||||||
{
|
{
|
||||||
DEFINE_STANDARD_RTTIEXT(OpenGl_BackgroundArray, OpenGl_PrimitiveArray)
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Main constructor.
|
//! Main constructor.
|
||||||
|
@@ -72,7 +72,7 @@ namespace
|
|||||||
aContext->ModelWorldState.SetCurrent (OpenGl_Mat4::Map (*thePlane->Orientation()->mat));
|
aContext->ModelWorldState.SetCurrent (OpenGl_Mat4::Map (*thePlane->Orientation()->mat));
|
||||||
aContext->ApplyModelViewMatrix();
|
aContext->ApplyModelViewMatrix();
|
||||||
|
|
||||||
thePlane->Primitives()->Render (theWorkspace);
|
thePlane->Primitives().Render (theWorkspace);
|
||||||
|
|
||||||
aContext->ModelWorldState.Pop();
|
aContext->ModelWorldState.Pop();
|
||||||
aContext->ApplyModelViewMatrix();
|
aContext->ApplyModelViewMatrix();
|
||||||
@@ -104,11 +104,11 @@ namespace
|
|||||||
theStencilSentry.Init();
|
theStencilSentry.Init();
|
||||||
|
|
||||||
// check if capping plane should be rendered within current pass (only opaque / only transparent)
|
// check if capping plane should be rendered within current pass (only opaque / only transparent)
|
||||||
const Handle(OpenGl_AspectFace) anObjAspectFace = aRenderPlane->ToUseObjectProperties() ? aGroupIter.Value()->AspectFace() : NULL;
|
const OpenGl_AspectFace* anObjAspectFace = aRenderPlane->ToUseObjectProperties() ? aGroupIter.Value()->AspectFace() : NULL;
|
||||||
thePlane->Update (aContext, !anObjAspectFace.IsNull() ? anObjAspectFace->Aspect() : Handle(Graphic3d_AspectFillArea3d)());
|
thePlane->Update (aContext, anObjAspectFace != NULL ? anObjAspectFace->Aspect() : Handle(Graphic3d_AspectFillArea3d)());
|
||||||
theWorkspace->SetAspectFace (thePlane->AspectFace());
|
theWorkspace->SetAspectFace (thePlane->AspectFace());
|
||||||
theWorkspace->SetRenderFilter (aPrevFilter);
|
theWorkspace->SetRenderFilter (aPrevFilter);
|
||||||
if (!theWorkspace->ShouldRender (thePlane->Primitives()))
|
if (!theWorkspace->ShouldRender (&thePlane->Primitives()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ namespace
|
|||||||
const bool aColorMaskBack = aContext->SetColorMask (false);
|
const bool aColorMaskBack = aContext->SetColorMask (false);
|
||||||
|
|
||||||
// override aspects, disable culling
|
// override aspects, disable culling
|
||||||
theWorkspace->SetAspectFace (theWorkspace->NoneCulling());
|
theWorkspace->SetAspectFace (&theWorkspace->NoneCulling());
|
||||||
theWorkspace->ApplyAspectFace();
|
theWorkspace->ApplyAspectFace();
|
||||||
|
|
||||||
// evaluate number of pair faces
|
// evaluate number of pair faces
|
||||||
@@ -156,7 +156,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
// override material, cull back faces
|
// override material, cull back faces
|
||||||
theWorkspace->SetAspectFace (theWorkspace->FrontCulling());
|
theWorkspace->SetAspectFace (&theWorkspace->FrontCulling());
|
||||||
theWorkspace->ApplyAspectFace();
|
theWorkspace->ApplyAspectFace();
|
||||||
|
|
||||||
// enable all clip plane except the rendered one
|
// enable all clip plane except the rendered one
|
||||||
@@ -207,7 +207,7 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remember current aspect face defined in workspace
|
// remember current aspect face defined in workspace
|
||||||
const Handle(OpenGl_AspectFace)& aFaceAsp = theWorkspace->AspectFace();
|
const OpenGl_AspectFace* aFaceAsp = theWorkspace->AspectFace();
|
||||||
|
|
||||||
// only filled primitives should be rendered
|
// only filled primitives should be rendered
|
||||||
const Standard_Integer aPrevFilter = theWorkspace->RenderFilter();
|
const Standard_Integer aPrevFilter = theWorkspace->RenderFilter();
|
||||||
|
@@ -63,7 +63,7 @@ namespace
|
|||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane)
|
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane)
|
||||||
: myPrimitives (new OpenGl_PrimitiveArray(NULL)),
|
: myPrimitives (NULL),
|
||||||
myOrientation (OpenGl_IdentityMatrix),
|
myOrientation (OpenGl_IdentityMatrix),
|
||||||
myAspect (NULL),
|
myAspect (NULL),
|
||||||
myPlaneRoot (thePlane),
|
myPlaneRoot (thePlane),
|
||||||
@@ -82,7 +82,7 @@ OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d
|
|||||||
if (anAttribs->Init (12, anAttribInfo, 3))
|
if (anAttribs->Init (12, anAttribInfo, 3))
|
||||||
{
|
{
|
||||||
memcpy (anAttribs->ChangeData(), THE_CAPPING_PLN_VERTS, sizeof(THE_CAPPING_PLN_VERTS));
|
memcpy (anAttribs->ChangeData(), THE_CAPPING_PLN_VERTS, sizeof(THE_CAPPING_PLN_VERTS));
|
||||||
myPrimitives->InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
|
myPrimitives.InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& ,
|
|||||||
void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
|
void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
|
||||||
{
|
{
|
||||||
OpenGl_Element::Destroy (theContext, myAspect);
|
OpenGl_Element::Destroy (theContext, myAspect);
|
||||||
myPrimitives->Release (theContext);
|
myPrimitives.Release (theContext);
|
||||||
myEquationMod = (unsigned int )-1;
|
myEquationMod = (unsigned int )-1;
|
||||||
myAspectMod = (unsigned int )-1;
|
myAspectMod = (unsigned int )-1;
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_AspectFillArea3d)& theObjAspect)
|
void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_AspectFillArea3d)& theObjAspect)
|
||||||
{
|
{
|
||||||
if (myAspect.IsNull())
|
if (myAspect == NULL)
|
||||||
{
|
{
|
||||||
myAspect = new OpenGl_AspectFace();
|
myAspect = new OpenGl_AspectFace();
|
||||||
myAspectMod = myPlaneRoot->MCountAspect() - 1; // mark out of sync
|
myAspectMod = myPlaneRoot->MCountAspect() - 1; // mark out of sync
|
||||||
|
@@ -61,13 +61,13 @@ public:
|
|||||||
const Handle(Graphic3d_ClipPlane)& Plane() const { return myPlaneRoot; }
|
const Handle(Graphic3d_ClipPlane)& Plane() const { return myPlaneRoot; }
|
||||||
|
|
||||||
//! @return aspect face for rendering capping surface.
|
//! @return aspect face for rendering capping surface.
|
||||||
inline const Handle(OpenGl_AspectFace)& AspectFace() const { return myAspect; }
|
inline const OpenGl_AspectFace* AspectFace() const { return myAspect; }
|
||||||
|
|
||||||
//! @return evaluated orientation matrix to transform infinite plane.
|
//! @return evaluated orientation matrix to transform infinite plane.
|
||||||
inline const OpenGl_Matrix* Orientation() const { return &myOrientation; }
|
inline const OpenGl_Matrix* Orientation() const { return &myOrientation; }
|
||||||
|
|
||||||
//! @return primitive array of vertices to render infinite plane.
|
//! @return primitive array of vertices to render infinite plane.
|
||||||
inline const Handle(OpenGl_PrimitiveArray)& Primitives() const { return myPrimitives; }
|
inline const OpenGl_PrimitiveArray& Primitives() const { return myPrimitives; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -79,9 +79,9 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Handle(OpenGl_PrimitiveArray) myPrimitives; //!< vertices and texture coordinates for rendering
|
OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering
|
||||||
OpenGl_Matrix myOrientation; //!< plane transformation matrix.
|
OpenGl_Matrix myOrientation; //!< plane transformation matrix.
|
||||||
Handle(OpenGl_AspectFace) myAspect; //!< capping face aspect.
|
OpenGl_AspectFace* myAspect; //!< capping face aspect.
|
||||||
Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
|
Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
|
||||||
Handle(Graphic3d_AspectFillArea3d) myFillAreaAspect; //!< own capping aspect
|
Handle(Graphic3d_AspectFillArea3d) myFillAreaAspect; //!< own capping aspect
|
||||||
unsigned int myEquationMod; //!< modification counter for plane equation.
|
unsigned int myEquationMod; //!< modification counter for plane equation.
|
||||||
|
@@ -28,11 +28,11 @@ OpenGl_Caps::OpenGl_Caps()
|
|||||||
: vboDisable (Standard_False),
|
: vboDisable (Standard_False),
|
||||||
pntSpritesDisable (Standard_False),
|
pntSpritesDisable (Standard_False),
|
||||||
keepArrayData (Standard_False),
|
keepArrayData (Standard_False),
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
|
||||||
ffpEnable (Standard_False),
|
ffpEnable (Standard_False),
|
||||||
|
usePolygonMode (Standard_False),
|
||||||
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
useSystemBuffer (Standard_False),
|
useSystemBuffer (Standard_False),
|
||||||
#else
|
#else
|
||||||
ffpEnable (Standard_False),
|
|
||||||
useSystemBuffer (Standard_True),
|
useSystemBuffer (Standard_True),
|
||||||
#endif
|
#endif
|
||||||
swapInterval (1),
|
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 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 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 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_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
|
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),
|
hasFloatBuffer (OpenGl_FeatureNotAvailable),
|
||||||
hasHalfFloatBuffer (OpenGl_FeatureNotAvailable),
|
hasHalfFloatBuffer (OpenGl_FeatureNotAvailable),
|
||||||
hasSampleVariables (OpenGl_FeatureNotAvailable),
|
hasSampleVariables (OpenGl_FeatureNotAvailable),
|
||||||
|
hasGeometryStage (OpenGl_FeatureNotAvailable),
|
||||||
arbDrawBuffers (Standard_False),
|
arbDrawBuffers (Standard_False),
|
||||||
arbNPTW (Standard_False),
|
arbNPTW (Standard_False),
|
||||||
arbTexRG (Standard_False),
|
arbTexRG (Standard_False),
|
||||||
@@ -172,6 +173,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
|
|||||||
myHasRayTracing (Standard_False),
|
myHasRayTracing (Standard_False),
|
||||||
myHasRayTracingTextures (Standard_False),
|
myHasRayTracingTextures (Standard_False),
|
||||||
myHasRayTracingAdaptiveSampling (Standard_False),
|
myHasRayTracingAdaptiveSampling (Standard_False),
|
||||||
|
myHasRayTracingAdaptiveSamplingAtomic (Standard_False),
|
||||||
myFrameStats (new OpenGl_FrameStats()),
|
myFrameStats (new OpenGl_FrameStats()),
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
myPointSpriteOrig (GL_UPPER_LEFT),
|
myPointSpriteOrig (GL_UPPER_LEFT),
|
||||||
@@ -192,6 +194,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
|
|||||||
myResolution (Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION),
|
myResolution (Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION),
|
||||||
myResolutionRatio (1.0f),
|
myResolutionRatio (1.0f),
|
||||||
myLineWidthScale (1.0f),
|
myLineWidthScale (1.0f),
|
||||||
|
myLineFeather (1.0f),
|
||||||
myRenderScale (1.0f),
|
myRenderScale (1.0f),
|
||||||
myRenderScaleInv (1.0f)
|
myRenderScaleInv (1.0f)
|
||||||
{
|
{
|
||||||
@@ -1421,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
|
// dFdx/dFdy are completely broken on tested Adreno devices with versions below OpenGl ES 3.1
|
||||||
hasFlatShading = OpenGl_FeatureNotAvailable;
|
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
|
#else
|
||||||
|
|
||||||
myTexClamp = IsGlGreaterEqual (1, 2) ? GL_CLAMP_TO_EDGE : GL_CLAMP;
|
myTexClamp = IsGlGreaterEqual (1, 2) ? GL_CLAMP_TO_EDGE : GL_CLAMP;
|
||||||
@@ -1445,6 +1454,10 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|
|||||||
CheckExtension ("GL_ARB_color_buffer_float") ? OpenGl_FeatureInExtensions
|
CheckExtension ("GL_ARB_color_buffer_float") ? OpenGl_FeatureInExtensions
|
||||||
: OpenGl_FeatureNotAvailable;
|
: OpenGl_FeatureNotAvailable;
|
||||||
|
|
||||||
|
hasGeometryStage = IsGlGreaterEqual (3, 2)
|
||||||
|
? OpenGl_FeatureInCore
|
||||||
|
: OpenGl_FeatureNotAvailable;
|
||||||
|
|
||||||
hasSampleVariables = IsGlGreaterEqual (4, 0) ? OpenGl_FeatureInCore :
|
hasSampleVariables = IsGlGreaterEqual (4, 0) ? OpenGl_FeatureInCore :
|
||||||
arbSampleShading ? OpenGl_FeatureInExtensions
|
arbSampleShading ? OpenGl_FeatureInExtensions
|
||||||
: OpenGl_FeatureNotAvailable;
|
: OpenGl_FeatureNotAvailable;
|
||||||
@@ -2516,8 +2529,9 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|
|||||||
|
|
||||||
// check whether adaptive screen sampling in ray tracing mode is supported
|
// check whether adaptive screen sampling in ray tracing mode is supported
|
||||||
myHasRayTracingAdaptiveSampling = myHasRayTracing
|
myHasRayTracingAdaptiveSampling = myHasRayTracing
|
||||||
&& has44
|
&& has44;
|
||||||
&& CheckExtension ("GL_NV_shader_atomic_float");
|
myHasRayTracingAdaptiveSamplingAtomic = myHasRayTracingAdaptiveSampling
|
||||||
|
&& CheckExtension ("GL_NV_shader_atomic_float");
|
||||||
|
|
||||||
if (!has32)
|
if (!has32)
|
||||||
{
|
{
|
||||||
@@ -3165,7 +3179,7 @@ Handle(OpenGl_FrameBuffer) OpenGl_Context::SetDefaultFrameBuffer (const Handle(O
|
|||||||
// function : SetShadingMaterial
|
// function : SetShadingMaterial
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Context::SetShadingMaterial (const Handle(OpenGl_AspectFace)& theAspect,
|
void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect,
|
||||||
const Handle(Graphic3d_PresentationAttributes)& theHighlight)
|
const Handle(Graphic3d_PresentationAttributes)& theHighlight)
|
||||||
{
|
{
|
||||||
const Handle(Graphic3d_AspectFillArea3d)& anAspect = (!theHighlight.IsNull() && !theHighlight->BasicFillAreaAspect().IsNull())
|
const Handle(Graphic3d_AspectFillArea3d)& anAspect = (!theHighlight.IsNull() && !theHighlight->BasicFillAreaAspect().IsNull())
|
||||||
@@ -3211,9 +3225,18 @@ void OpenGl_Context::SetShadingMaterial (const Handle(OpenGl_AspectFace)& theAsp
|
|||||||
// do not update material properties in case of zero reflection mode,
|
// do not update material properties in case of zero reflection mode,
|
||||||
// because GL lighting will be disabled by OpenGl_PrimitiveArray::DrawArray() anyway.
|
// because GL lighting will be disabled by OpenGl_PrimitiveArray::DrawArray() anyway.
|
||||||
const OpenGl_MaterialState& aMatState = myShaderManager->MaterialState();
|
const OpenGl_MaterialState& aMatState = myShaderManager->MaterialState();
|
||||||
const float anAlphaCutoff = anAspect->AlphaMode() == Graphic3d_AlphaMode_Mask
|
float anAlphaCutoff = anAspect->AlphaMode() == Graphic3d_AlphaMode_Mask
|
||||||
? anAspect->AlphaCutoff()
|
? anAspect->AlphaCutoff()
|
||||||
: ShortRealLast();
|
: 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 (theAspect->ShadingModel() == Graphic3d_TOSM_UNLIT)
|
||||||
{
|
{
|
||||||
if (anAlphaCutoff == aMatState.AlphaCutoff())
|
if (anAlphaCutoff == aMatState.AlphaCutoff())
|
||||||
@@ -3237,7 +3260,7 @@ void OpenGl_Context::SetShadingMaterial (const Handle(OpenGl_AspectFace)& theAsp
|
|||||||
// function : CheckIsTransparent
|
// function : CheckIsTransparent
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean OpenGl_Context::CheckIsTransparent (const Handle(OpenGl_AspectFace)& theAspect,
|
Standard_Boolean OpenGl_Context::CheckIsTransparent (const OpenGl_AspectFace* theAspect,
|
||||||
const Handle(Graphic3d_PresentationAttributes)& theHighlight,
|
const Handle(Graphic3d_PresentationAttributes)& theHighlight,
|
||||||
Standard_ShortReal& theAlphaFront,
|
Standard_ShortReal& theAlphaFront,
|
||||||
Standard_ShortReal& theAlphaBack)
|
Standard_ShortReal& theAlphaBack)
|
||||||
@@ -3770,14 +3793,15 @@ bool OpenGl_Context::SetColorMask (bool theToWriteColor)
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
bool OpenGl_Context::SetSampleAlphaToCoverage (bool theToEnable)
|
bool OpenGl_Context::SetSampleAlphaToCoverage (bool theToEnable)
|
||||||
{
|
{
|
||||||
if (myAlphaToCoverage == theToEnable)
|
bool toEnable = myAllowAlphaToCov && theToEnable;
|
||||||
|
if (myAlphaToCoverage == toEnable)
|
||||||
{
|
{
|
||||||
return myAlphaToCoverage;
|
return myAlphaToCoverage;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (core15fwd != NULL)
|
if (core15fwd != NULL)
|
||||||
{
|
{
|
||||||
if (theToEnable)
|
if (toEnable)
|
||||||
{
|
{
|
||||||
//core15fwd->core15fwd->glSampleCoverage (1.0f, GL_FALSE);
|
//core15fwd->core15fwd->glSampleCoverage (1.0f, GL_FALSE);
|
||||||
core15fwd->glEnable (GL_SAMPLE_ALPHA_TO_COVERAGE);
|
core15fwd->glEnable (GL_SAMPLE_ALPHA_TO_COVERAGE);
|
||||||
@@ -3789,6 +3813,6 @@ bool OpenGl_Context::SetSampleAlphaToCoverage (bool theToEnable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bool anOldValue = myAlphaToCoverage;
|
const bool anOldValue = myAlphaToCoverage;
|
||||||
myAlphaToCoverage = theToEnable;
|
myAlphaToCoverage = toEnable;
|
||||||
return anOldValue;
|
return anOldValue;
|
||||||
}
|
}
|
||||||
|
@@ -503,6 +503,9 @@ public:
|
|||||||
//! @return TRUE if adaptive screen sampling in ray tracing mode is supported
|
//! @return TRUE if adaptive screen sampling in ray tracing mode is supported
|
||||||
Standard_Boolean HasRayTracingAdaptiveSampling() const { return myHasRayTracingAdaptiveSampling; }
|
Standard_Boolean HasRayTracingAdaptiveSampling() const { return myHasRayTracingAdaptiveSampling; }
|
||||||
|
|
||||||
|
//! @return TRUE if atomic adaptive screen sampling in ray tracing mode is supported
|
||||||
|
Standard_Boolean HasRayTracingAdaptiveSamplingAtomic() const { return myHasRayTracingAdaptiveSamplingAtomic; }
|
||||||
|
|
||||||
//! Returns true if VBO is supported and permitted.
|
//! Returns true if VBO is supported and permitted.
|
||||||
inline bool ToUseVbo() const
|
inline bool ToUseVbo() const
|
||||||
{
|
{
|
||||||
@@ -659,6 +662,12 @@ public: //! @name methods to alter or retrieve current state
|
|||||||
//! Enable/disable writing into color buffer (wrapper for glColorMask).
|
//! Enable/disable writing into color buffer (wrapper for glColorMask).
|
||||||
Standard_EXPORT bool SetColorMask (bool theToWriteColor);
|
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.
|
//! Return GL_SAMPLE_ALPHA_TO_COVERAGE state.
|
||||||
bool SampleAlphaToCoverage() const { return myAlphaToCoverage; }
|
bool SampleAlphaToCoverage() const { return myAlphaToCoverage; }
|
||||||
|
|
||||||
@@ -696,17 +705,17 @@ public: //! @name methods to alter or retrieve current state
|
|||||||
Standard_EXPORT Standard_Boolean BindProgram (const Handle(OpenGl_ShaderProgram)& theProgram);
|
Standard_EXPORT Standard_Boolean BindProgram (const Handle(OpenGl_ShaderProgram)& theProgram);
|
||||||
|
|
||||||
//! Setup current shading material.
|
//! Setup current shading material.
|
||||||
Standard_EXPORT void SetShadingMaterial (const Handle(OpenGl_AspectFace)& theAspect,
|
Standard_EXPORT void SetShadingMaterial (const OpenGl_AspectFace* theAspect,
|
||||||
const Handle(Graphic3d_PresentationAttributes)& theHighlight);
|
const Handle(Graphic3d_PresentationAttributes)& theHighlight);
|
||||||
|
|
||||||
//! Checks if transparency is required for the given aspect and highlight style.
|
//! Checks if transparency is required for the given aspect and highlight style.
|
||||||
Standard_EXPORT static Standard_Boolean CheckIsTransparent (const Handle(OpenGl_AspectFace)& theAspect,
|
Standard_EXPORT static Standard_Boolean CheckIsTransparent (const OpenGl_AspectFace* theAspect,
|
||||||
const Handle(Graphic3d_PresentationAttributes)& theHighlight,
|
const Handle(Graphic3d_PresentationAttributes)& theHighlight,
|
||||||
Standard_ShortReal& theAlphaFront,
|
Standard_ShortReal& theAlphaFront,
|
||||||
Standard_ShortReal& theAlphaBack);
|
Standard_ShortReal& theAlphaBack);
|
||||||
|
|
||||||
//! Checks if transparency is required for the given aspect and highlight style.
|
//! Checks if transparency is required for the given aspect and highlight style.
|
||||||
static Standard_Boolean CheckIsTransparent (const Handle(OpenGl_AspectFace)& theAspect,
|
static Standard_Boolean CheckIsTransparent (const OpenGl_AspectFace* theAspect,
|
||||||
const Handle(Graphic3d_PresentationAttributes)& theHighlight)
|
const Handle(Graphic3d_PresentationAttributes)& theHighlight)
|
||||||
{
|
{
|
||||||
Standard_ShortReal anAlphaFront = 1.0f, anAlphaBack = 1.0f;
|
Standard_ShortReal anAlphaFront = 1.0f, anAlphaBack = 1.0f;
|
||||||
@@ -774,6 +783,9 @@ public: //! @name methods to alter or retrieve current state
|
|||||||
//! Rendering scale factor (inverted value).
|
//! Rendering scale factor (inverted value).
|
||||||
Standard_ShortReal RenderScaleInv() const { return myRenderScaleInv; }
|
Standard_ShortReal RenderScaleInv() const { return myRenderScaleInv; }
|
||||||
|
|
||||||
|
//! Return scale factor for line width.
|
||||||
|
Standard_ShortReal LineWidthScale() const { return myLineWidthScale; }
|
||||||
|
|
||||||
//! Set resolution ratio.
|
//! Set resolution ratio.
|
||||||
//! Note that this method rounds @theRatio to nearest integer.
|
//! Note that this method rounds @theRatio to nearest integer.
|
||||||
void SetResolution (unsigned int theResolution,
|
void SetResolution (unsigned int theResolution,
|
||||||
@@ -794,6 +806,12 @@ public: //! @name methods to alter or retrieve current state
|
|||||||
myLineWidthScale = Max (1.0f, std::floor (theRatio + 0.5f));
|
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.
|
//! Return Graphics Driver's vendor.
|
||||||
const TCollection_AsciiString& Vendor() const { return myVendor; }
|
const TCollection_AsciiString& Vendor() const { return myVendor; }
|
||||||
|
|
||||||
@@ -845,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 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 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 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 arbDrawBuffers; //!< GL_ARB_draw_buffers
|
||||||
Standard_Boolean arbNPTW; //!< GL_ARB_texture_non_power_of_two
|
Standard_Boolean arbNPTW; //!< GL_ARB_texture_non_power_of_two
|
||||||
Standard_Boolean arbTexRG; //!< GL_ARB_texture_rg
|
Standard_Boolean arbTexRG; //!< GL_ARB_texture_rg
|
||||||
@@ -928,9 +947,10 @@ private: // context info
|
|||||||
Standard_Boolean myIsGlNormalizeEnabled; //!< GL_NORMALIZE flag
|
Standard_Boolean myIsGlNormalizeEnabled; //!< GL_NORMALIZE flag
|
||||||
//!< Used to tell OpenGl that normals should be normalized
|
//!< Used to tell OpenGl that normals should be normalized
|
||||||
|
|
||||||
Standard_Boolean myHasRayTracing; //! indicates whether ray tracing mode is supported
|
Standard_Boolean myHasRayTracing; //! indicates whether ray tracing mode is supported
|
||||||
Standard_Boolean myHasRayTracingTextures; //! indicates whether textures in ray tracing mode are supported
|
Standard_Boolean myHasRayTracingTextures; //! indicates whether textures in ray tracing mode are supported
|
||||||
Standard_Boolean myHasRayTracingAdaptiveSampling; //! indicates whether adaptive screen sampling in ray tracing mode is supported
|
Standard_Boolean myHasRayTracingAdaptiveSampling; //! indicates whether adaptive screen sampling in ray tracing mode is supported
|
||||||
|
Standard_Boolean myHasRayTracingAdaptiveSamplingAtomic; //! indicates whether atomic adaptive screen sampling in ray tracing mode is supported
|
||||||
|
|
||||||
Handle(OpenGl_ShaderManager) myShaderManager; //! support object for managing shader programs
|
Handle(OpenGl_ShaderManager) myShaderManager; //! support object for managing shader programs
|
||||||
|
|
||||||
@@ -954,6 +974,7 @@ private: //! @name fields tracking current state
|
|||||||
myDrawBuffers; //!< current draw buffers
|
myDrawBuffers; //!< current draw buffers
|
||||||
unsigned int myDefaultVao; //!< default Vertex Array Object
|
unsigned int myDefaultVao; //!< default Vertex Array Object
|
||||||
Standard_Boolean myColorMask; //!< flag indicating writing into color buffer is enabled or disabled (glColorMask)
|
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 myAlphaToCoverage; //!< flag indicating GL_SAMPLE_ALPHA_TO_COVERAGE state
|
||||||
Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state
|
Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state
|
||||||
TCollection_AsciiString myVendor; //!< Graphics Driver's vendor
|
TCollection_AsciiString myVendor; //!< Graphics Driver's vendor
|
||||||
@@ -962,6 +983,7 @@ private: //! @name fields tracking current state
|
|||||||
Standard_ShortReal myResolutionRatio; //!< scaling factor for parameters like text size
|
Standard_ShortReal myResolutionRatio; //!< scaling factor for parameters like text size
|
||||||
//! to be properly displayed on device (screen / printer)
|
//! to be properly displayed on device (screen / printer)
|
||||||
Standard_ShortReal myLineWidthScale; //!< scaling factor for line width
|
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 myRenderScale; //!< scaling factor for rendering resolution
|
||||||
Standard_ShortReal myRenderScaleInv; //!< scaling factor for rendering resolution (inverted value)
|
Standard_ShortReal myRenderScaleInv; //!< scaling factor for rendering resolution (inverted value)
|
||||||
OpenGl_Material myMatFront; //!< current front material state (cached to reduce GL context updates)
|
OpenGl_Material myMatFront; //!< current front material state (cached to reduce GL context updates)
|
||||||
|
@@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
#include <OpenGl_Element.hxx>
|
#include <OpenGl_Element.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Element, Standard_Transient)
|
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : OpenGl_Element
|
// function : OpenGl_Element
|
||||||
// purpose :
|
// purpose :
|
||||||
|
@@ -23,9 +23,8 @@ class OpenGl_Workspace;
|
|||||||
class OpenGl_Context;
|
class OpenGl_Context;
|
||||||
|
|
||||||
//! Base interface for drawable elements.
|
//! Base interface for drawable elements.
|
||||||
class OpenGl_Element : public Standard_Transient
|
class OpenGl_Element
|
||||||
{
|
{
|
||||||
DEFINE_STANDARD_RTTIEXT(OpenGl_Element, Standard_Transient)
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Standard_EXPORT OpenGl_Element();
|
Standard_EXPORT OpenGl_Element();
|
||||||
@@ -41,14 +40,18 @@ public:
|
|||||||
//! Pointer to the context is used because this method might be called
|
//! Pointer to the context is used because this method might be called
|
||||||
//! when the context is already being destroyed and usage of a handle
|
//! when the context is already being destroyed and usage of a handle
|
||||||
//! would be unsafe
|
//! would be unsafe
|
||||||
|
template <typename theResource_t>
|
||||||
static void Destroy (OpenGl_Context* theContext,
|
static void Destroy (OpenGl_Context* theContext,
|
||||||
Handle(OpenGl_Element)& theElement)
|
theResource_t*& theElement)
|
||||||
{
|
{
|
||||||
if (theElement.IsNull())
|
if (theElement == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
theElement->Release (theContext);
|
theElement->Release (theContext);
|
||||||
|
OpenGl_Element* anElement = theElement;
|
||||||
|
delete anElement;
|
||||||
theElement = NULL;
|
theElement = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,8 +22,6 @@
|
|||||||
|
|
||||||
#include <gp_Ax2.hxx>
|
#include <gp_Ax2.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Flipper, OpenGl_Element)
|
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : Constructor
|
// function : Constructor
|
||||||
// purpose :
|
// purpose :
|
||||||
|
@@ -27,7 +27,6 @@ class gp_Ax2;
|
|||||||
//! Originally, this element serves for need of flipping the 3D text of dimension presentations.
|
//! Originally, this element serves for need of flipping the 3D text of dimension presentations.
|
||||||
class OpenGl_Flipper : public OpenGl_Element
|
class OpenGl_Flipper : public OpenGl_Element
|
||||||
{
|
{
|
||||||
DEFINE_STANDARD_RTTIEXT(OpenGl_Flipper, OpenGl_Element)
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Construct rendering element to flip model-view matrix
|
//! Construct rendering element to flip model-view matrix
|
||||||
|
@@ -161,6 +161,8 @@ void OpenGl_FrameStats::updateStatistics (const Handle(Graphic3d_CView)& theView
|
|||||||
aMemFbos += estimatedDataSize (aView->myRaytraceVisualErrorTexture[1]);
|
aMemFbos += estimatedDataSize (aView->myRaytraceVisualErrorTexture[1]);
|
||||||
aMemFbos += estimatedDataSize (aView->myRaytraceTileOffsetsTexture[0]);
|
aMemFbos += estimatedDataSize (aView->myRaytraceTileOffsetsTexture[0]);
|
||||||
aMemFbos += estimatedDataSize (aView->myRaytraceTileOffsetsTexture[1]);
|
aMemFbos += estimatedDataSize (aView->myRaytraceTileOffsetsTexture[1]);
|
||||||
|
aMemFbos += estimatedDataSize (aView->myRaytraceTileSamplesTexture[0]);
|
||||||
|
aMemFbos += estimatedDataSize (aView->myRaytraceTileSamplesTexture[1]);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Ray Tracing geometry
|
// Ray Tracing geometry
|
||||||
@@ -203,10 +205,9 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
|
|||||||
for (OpenGl_Structure::GroupIterator aGroupIter (aStruct->Groups()); aGroupIter.More(); aGroupIter.Next())
|
for (OpenGl_Structure::GroupIterator aGroupIter (aStruct->Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||||
{
|
{
|
||||||
const OpenGl_Group* aGroup = aGroupIter.Value();
|
const OpenGl_Group* aGroup = aGroupIter.Value();
|
||||||
for (OpenGl_ElementNodes::Iterator anElemIterator (aGroup->GetElements()); anElemIterator.More(); anElemIterator.Next())
|
for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
|
||||||
{
|
{
|
||||||
Handle(OpenGl_PrimitiveArray) aPrim = Handle(OpenGl_PrimitiveArray)::DownCast (anElemIterator.Value());
|
if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
|
||||||
if (!aPrim.IsNull())
|
|
||||||
{
|
{
|
||||||
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->AttributesVbo());
|
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->AttributesVbo());
|
||||||
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->IndexVbo());
|
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->IndexVbo());
|
||||||
@@ -226,10 +227,9 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
|
|||||||
for (OpenGl_Structure::GroupIterator aGroupIter (aStruct->Groups()); aGroupIter.More(); aGroupIter.Next())
|
for (OpenGl_Structure::GroupIterator aGroupIter (aStruct->Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||||
{
|
{
|
||||||
const OpenGl_Group* aGroup = aGroupIter.Value();
|
const OpenGl_Group* aGroup = aGroupIter.Value();
|
||||||
for (OpenGl_ElementNodes::Iterator anElemIterator (aGroup->GetElements()); anElemIterator.More(); anElemIterator.Next())
|
for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
|
||||||
{
|
{
|
||||||
Handle(OpenGl_PrimitiveArray) aPrim = Handle(OpenGl_PrimitiveArray)::DownCast (anElemIterator.Value());
|
if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
|
||||||
if (!aPrim.IsNull())
|
|
||||||
{
|
{
|
||||||
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
|
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
|
||||||
if (theToCountMem)
|
if (theToCountMem)
|
||||||
@@ -313,8 +313,9 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
|
|||||||
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsLineNotCulled];
|
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsLineNotCulled];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!Handle(OpenGl_Text)::DownCast(anElemIterator.Value()).IsNull())
|
else if (const OpenGl_Text* aText = dynamic_cast<const OpenGl_Text*> (aNodeIter->elem))
|
||||||
{
|
{
|
||||||
|
(void )aText;
|
||||||
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
|
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
|
||||||
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsTextNotCulled];
|
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsTextNotCulled];
|
||||||
}
|
}
|
||||||
|
@@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_FrameStatsPrs, OpenGl_Element)
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
//! Auxiliary structure defining vertex with two attributes.
|
//! Auxiliary structure defining vertex with two attributes.
|
||||||
@@ -52,11 +50,7 @@ OpenGl_FrameStatsPrs::OpenGl_FrameStatsPrs()
|
|||||||
myChartIndices (new OpenGl_IndexBuffer()),
|
myChartIndices (new OpenGl_IndexBuffer()),
|
||||||
myChartLines (new OpenGl_VertexBuffer())
|
myChartLines (new OpenGl_VertexBuffer())
|
||||||
{
|
{
|
||||||
myCountersText = new OpenGl_Text();
|
//
|
||||||
myTextAspect = new OpenGl_AspectText();
|
|
||||||
myChartLabels[0] = new OpenGl_Text();
|
|
||||||
myChartLabels[1] = new OpenGl_Text();
|
|
||||||
myChartLabels[2] = new OpenGl_Text();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -74,10 +68,10 @@ OpenGl_FrameStatsPrs::~OpenGl_FrameStatsPrs()
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_FrameStatsPrs::Release (OpenGl_Context* theCtx)
|
void OpenGl_FrameStatsPrs::Release (OpenGl_Context* theCtx)
|
||||||
{
|
{
|
||||||
myCountersText->Release (theCtx);
|
myCountersText.Release (theCtx);
|
||||||
myChartLabels[0]->Release (theCtx);
|
myChartLabels[0].Release (theCtx);
|
||||||
myChartLabels[1]->Release (theCtx);
|
myChartLabels[1].Release (theCtx);
|
||||||
myChartLabels[2]->Release (theCtx);
|
myChartLabels[2].Release (theCtx);
|
||||||
myChartVertices->Release (theCtx);
|
myChartVertices->Release (theCtx);
|
||||||
myChartIndices->Release (theCtx);
|
myChartIndices->Release (theCtx);
|
||||||
myChartLines->Release (theCtx);
|
myChartLines->Release (theCtx);
|
||||||
@@ -94,7 +88,7 @@ void OpenGl_FrameStatsPrs::Update (const Handle(OpenGl_Workspace)& theWorkspace)
|
|||||||
const Graphic3d_RenderingParams& aRendParams = theWorkspace->View()->RenderingParams();
|
const Graphic3d_RenderingParams& aRendParams = theWorkspace->View()->RenderingParams();
|
||||||
myCountersTrsfPers = theWorkspace->View()->RenderingParams().StatsPosition;
|
myCountersTrsfPers = theWorkspace->View()->RenderingParams().StatsPosition;
|
||||||
myChartTrsfPers = theWorkspace->View()->RenderingParams().ChartPosition;
|
myChartTrsfPers = theWorkspace->View()->RenderingParams().ChartPosition;
|
||||||
myTextAspect->SetAspect (aRendParams.StatsTextAspect);
|
myTextAspect.SetAspect (aRendParams.StatsTextAspect);
|
||||||
|
|
||||||
// adjust text alignment depending on corner
|
// adjust text alignment depending on corner
|
||||||
OpenGl_TextParam aParams;
|
OpenGl_TextParam aParams;
|
||||||
@@ -117,21 +111,21 @@ void OpenGl_FrameStatsPrs::Update (const Handle(OpenGl_Workspace)& theWorkspace)
|
|||||||
{
|
{
|
||||||
aParams.VAlign = Graphic3d_VTA_BOTTOM;
|
aParams.VAlign = Graphic3d_VTA_BOTTOM;
|
||||||
}
|
}
|
||||||
if (aParams.Height != myCountersText->FormatParams().Height
|
if (aParams.Height != myCountersText.FormatParams().Height
|
||||||
|| aParams.HAlign != myCountersText->FormatParams().HAlign
|
|| aParams.HAlign != myCountersText.FormatParams().HAlign
|
||||||
|| aParams.VAlign != myCountersText->FormatParams().VAlign)
|
|| aParams.VAlign != myCountersText.FormatParams().VAlign)
|
||||||
{
|
{
|
||||||
myCountersText->Release (aCtx.operator->());
|
myCountersText.Release (aCtx.operator->());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aStats->IsFrameUpdated (myStatsPrev)
|
if (!aStats->IsFrameUpdated (myStatsPrev)
|
||||||
&& !myCountersText->Text().IsEmpty())
|
&& !myCountersText.Text().IsEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TCollection_AsciiString aText = aStats->FormatStats (aRendParams.CollectedStats);
|
TCollection_AsciiString aText = aStats->FormatStats (aRendParams.CollectedStats);
|
||||||
myCountersText->Init (aCtx, aText.ToCString(), OpenGl_Vec3 (0.0f, 0.0f, 0.0f), aParams);
|
myCountersText.Init (aCtx, aText.ToCString(), OpenGl_Vec3 (0.0f, 0.0f, 0.0f), aParams);
|
||||||
|
|
||||||
updateChart (theWorkspace);
|
updateChart (theWorkspace);
|
||||||
}
|
}
|
||||||
@@ -347,9 +341,9 @@ void OpenGl_FrameStatsPrs::updateChart (const Handle(OpenGl_Workspace)& theWorks
|
|||||||
const float aLabX = aParams.HAlign == Graphic3d_HTA_RIGHT
|
const float aLabX = aParams.HAlign == Graphic3d_HTA_RIGHT
|
||||||
? float(anOffset.x())
|
? float(anOffset.x())
|
||||||
: float(anOffset.x() + aCharSize.x());
|
: float(anOffset.x() + aCharSize.x());
|
||||||
myChartLabels[0]->Init (aCtx, aLabels[isTopDown ? 0 : 2].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y()), 0.0f), aParams);
|
myChartLabels[0].Init (aCtx, aLabels[isTopDown ? 0 : 2].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y()), 0.0f), aParams);
|
||||||
myChartLabels[1]->Init (aCtx, aLabels[isTopDown ? 1 : 1].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f), aParams);
|
myChartLabels[1].Init (aCtx, aLabels[isTopDown ? 1 : 1].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f), aParams);
|
||||||
myChartLabels[2]->Init (aCtx, aLabels[isTopDown ? 2 : 0].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y()), 0.0f), aParams);
|
myChartLabels[2].Init (aCtx, aLabels[isTopDown ? 2 : 0].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y()), 0.0f), aParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,8 +361,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
|
|||||||
glDepthMask (GL_FALSE);
|
glDepthMask (GL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Handle(OpenGl_AspectText)& aTextAspectBack = theWorkspace->AspectText();
|
const OpenGl_AspectText* aTextAspectBack = theWorkspace->SetAspectText (&myTextAspect);
|
||||||
theWorkspace->SetAspectText (myTextAspect);
|
|
||||||
|
|
||||||
aCtx->ModelWorldState.Push();
|
aCtx->ModelWorldState.Push();
|
||||||
aCtx->ModelWorldState.ChangeCurrent().InitIdentity();
|
aCtx->ModelWorldState.ChangeCurrent().InitIdentity();
|
||||||
@@ -383,7 +376,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
|
|||||||
aCtx->VirtualViewport()[2], aCtx->VirtualViewport()[3]);
|
aCtx->VirtualViewport()[2], aCtx->VirtualViewport()[3]);
|
||||||
}
|
}
|
||||||
aCtx->ApplyModelViewMatrix();
|
aCtx->ApplyModelViewMatrix();
|
||||||
myCountersText->Render (theWorkspace);
|
myCountersText.Render (theWorkspace);
|
||||||
aCtx->WorldViewState.Pop();
|
aCtx->WorldViewState.Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,9 +419,9 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
|
|||||||
myChartLines->unbindAttribute (aCtx, Graphic3d_TOA_COLOR);
|
myChartLines->unbindAttribute (aCtx, Graphic3d_TOA_COLOR);
|
||||||
myChartLines->unbindAttribute (aCtx, Graphic3d_TOA_POS);
|
myChartLines->unbindAttribute (aCtx, Graphic3d_TOA_POS);
|
||||||
|
|
||||||
myChartLabels[0]->Render (theWorkspace);
|
myChartLabels[0].Render (theWorkspace);
|
||||||
myChartLabels[1]->Render (theWorkspace);
|
myChartLabels[1].Render (theWorkspace);
|
||||||
myChartLabels[2]->Render (theWorkspace);
|
myChartLabels[2].Render (theWorkspace);
|
||||||
|
|
||||||
aCtx->WorldViewState.Pop();
|
aCtx->WorldViewState.Pop();
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,6 @@ class OpenGl_VertexBuffer;
|
|||||||
//! Element rendering frame statistics.
|
//! Element rendering frame statistics.
|
||||||
class OpenGl_FrameStatsPrs : public OpenGl_Element
|
class OpenGl_FrameStatsPrs : public OpenGl_Element
|
||||||
{
|
{
|
||||||
DEFINE_STANDARD_RTTIEXT(OpenGl_FrameStatsPrs, OpenGl_Element)
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Default constructor.
|
//! Default constructor.
|
||||||
@@ -44,7 +43,7 @@ public:
|
|||||||
Standard_EXPORT void Update (const Handle(OpenGl_Workspace)& theWorkspace);
|
Standard_EXPORT void Update (const Handle(OpenGl_Workspace)& theWorkspace);
|
||||||
|
|
||||||
//! Assign text aspect.
|
//! Assign text aspect.
|
||||||
void SetTextAspect (const Handle(Graphic3d_AspectText3d)& theAspect) { myTextAspect->SetAspect (theAspect); }
|
void SetTextAspect (const Handle(Graphic3d_AspectText3d)& theAspect) { myTextAspect.SetAspect (theAspect); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -55,14 +54,14 @@ protected:
|
|||||||
|
|
||||||
Handle(OpenGl_FrameStats) myStatsPrev; //!< currently displayed stats
|
Handle(OpenGl_FrameStats) myStatsPrev; //!< currently displayed stats
|
||||||
Handle(Graphic3d_TransformPers) myCountersTrsfPers; //!< transformation persistence for counters presentation
|
Handle(Graphic3d_TransformPers) myCountersTrsfPers; //!< transformation persistence for counters presentation
|
||||||
Handle(OpenGl_Text) myCountersText; //!< counters presentation
|
OpenGl_Text myCountersText; //!< counters presentation
|
||||||
Handle(OpenGl_AspectText) myTextAspect; //!< text aspect
|
OpenGl_AspectText myTextAspect; //!< text aspect
|
||||||
Handle(Graphic3d_TransformPers) myChartTrsfPers; //!< transformation persistence for chart presentation
|
Handle(Graphic3d_TransformPers) myChartTrsfPers; //!< transformation persistence for chart presentation
|
||||||
Handle(Graphic3d_ArrayOfTriangles) myChartArray; //!< array of chart triangles
|
Handle(Graphic3d_ArrayOfTriangles) myChartArray; //!< array of chart triangles
|
||||||
Handle(OpenGl_VertexBuffer) myChartVertices; //!< VBO with chart triangles
|
Handle(OpenGl_VertexBuffer) myChartVertices; //!< VBO with chart triangles
|
||||||
Handle(OpenGl_IndexBuffer) myChartIndices; //!< VBO with chart triangle indexes
|
Handle(OpenGl_IndexBuffer) myChartIndices; //!< VBO with chart triangle indexes
|
||||||
Handle(OpenGl_VertexBuffer) myChartLines; //!< array of chart lines
|
Handle(OpenGl_VertexBuffer) myChartLines; //!< array of chart lines
|
||||||
Handle(OpenGl_Text) myChartLabels[3]; //!< chart labels
|
OpenGl_Text myChartLabels[3]; //!< chart labels
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -32,8 +32,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraduatedTrihedron, OpenGl_Element)
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
static const OpenGl_TextParam THE_LABEL_PARAMS =
|
static const OpenGl_TextParam THE_LABEL_PARAMS =
|
||||||
@@ -51,11 +49,7 @@ OpenGl_GraduatedTrihedron::OpenGl_GraduatedTrihedron()
|
|||||||
myMax (100.0f, 100.0f, 100.0f),
|
myMax (100.0f, 100.0f, 100.0f),
|
||||||
myIsInitialized (Standard_False)
|
myIsInitialized (Standard_False)
|
||||||
{
|
{
|
||||||
myGridLineAspect = new OpenGl_AspectLine();
|
//
|
||||||
|
|
||||||
myLabelValues = new OpenGl_Text();
|
|
||||||
myAspectLabels = new OpenGl_AspectText();
|
|
||||||
myAspectValues = new OpenGl_AspectText();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -86,7 +80,7 @@ void OpenGl_GraduatedTrihedron::Release (OpenGl_Context* theCtx)
|
|||||||
myAxes[0].Release (theCtx);
|
myAxes[0].Release (theCtx);
|
||||||
myAxes[1].Release (theCtx);
|
myAxes[1].Release (theCtx);
|
||||||
myAxes[2].Release (theCtx);
|
myAxes[2].Release (theCtx);
|
||||||
myLabelValues->Release (theCtx);
|
myLabelValues.Release (theCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -98,7 +92,7 @@ void OpenGl_GraduatedTrihedron::initGlResources (const Handle(OpenGl_Context)& t
|
|||||||
myAxes[0].Release (theCtx.operator->());
|
myAxes[0].Release (theCtx.operator->());
|
||||||
myAxes[1].Release (theCtx.operator->());
|
myAxes[1].Release (theCtx.operator->());
|
||||||
myAxes[2].Release (theCtx.operator->());
|
myAxes[2].Release (theCtx.operator->());
|
||||||
myLabelValues->Release (theCtx.operator->());
|
myLabelValues.Release (theCtx.operator->());
|
||||||
|
|
||||||
// Initialize text label parameters for x, y, and z axes
|
// Initialize text label parameters for x, y, and z axes
|
||||||
myAxes[0] = Axis (myData.XAxisAspect(), OpenGl_Vec3 (1.0f, 0.0f, 0.0f));
|
myAxes[0] = Axis (myData.XAxisAspect(), OpenGl_Vec3 (1.0f, 0.0f, 0.0f));
|
||||||
@@ -111,19 +105,19 @@ void OpenGl_GraduatedTrihedron::initGlResources (const Handle(OpenGl_Context)& t
|
|||||||
myAxes[2].InitArrow (theCtx, myData.ArrowsLength(), OpenGl_Vec3 (1.0f, 0.0f, 0.0f));
|
myAxes[2].InitArrow (theCtx, myData.ArrowsLength(), OpenGl_Vec3 (1.0f, 0.0f, 0.0f));
|
||||||
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
|
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
|
||||||
{
|
{
|
||||||
myAxes[anIt].Label->SetFontSize (theCtx, myData.NamesSize());
|
myAxes[anIt].Label.SetFontSize (theCtx, myData.NamesSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
myLabelValues->SetFontSize (theCtx, myData.ValuesSize());
|
myLabelValues.SetFontSize (theCtx, myData.ValuesSize());
|
||||||
|
|
||||||
myAspectLabels->Aspect()->SetTextFontAspect (myData.NamesFontAspect());
|
myAspectLabels.Aspect()->SetTextFontAspect (myData.NamesFontAspect());
|
||||||
myAspectLabels->Aspect()->SetFont (myData.NamesFont());
|
myAspectLabels.Aspect()->SetFont (myData.NamesFont());
|
||||||
|
|
||||||
myAspectValues->Aspect()->SetTextFontAspect (myData.ValuesFontAspect());
|
myAspectValues.Aspect()->SetTextFontAspect (myData.ValuesFontAspect());
|
||||||
myAspectValues->Aspect()->SetFont (myData.ValuesFont());
|
myAspectValues.Aspect()->SetFont (myData.ValuesFont());
|
||||||
|
|
||||||
// Grid aspect
|
// Grid aspect
|
||||||
myGridLineAspect->Aspect()->SetColor (myData.GridColor());
|
myGridLineAspect.Aspect()->SetColor (myData.GridColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -332,7 +326,7 @@ Standard_ExtCharacter OpenGl_GraduatedTrihedron::getGridAxes (const Standard_Sho
|
|||||||
// function : renderLine
|
// function : renderLine
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_GraduatedTrihedron::renderLine (const Handle(OpenGl_PrimitiveArray)& theLine,
|
void OpenGl_GraduatedTrihedron::renderLine (const OpenGl_PrimitiveArray& theLine,
|
||||||
const Handle(OpenGl_Workspace)& theWorkspace,
|
const Handle(OpenGl_Workspace)& theWorkspace,
|
||||||
const OpenGl_Mat4& theMat,
|
const OpenGl_Mat4& theMat,
|
||||||
const Standard_ShortReal theXt,
|
const Standard_ShortReal theXt,
|
||||||
@@ -344,7 +338,7 @@ void OpenGl_GraduatedTrihedron::renderLine (const Handle(OpenGl_PrimitiveArray)&
|
|||||||
Graphic3d_TransformUtils::Translate (aMat, theXt, theYt, theZt);
|
Graphic3d_TransformUtils::Translate (aMat, theXt, theYt, theZt);
|
||||||
aContext->WorldViewState.SetCurrent (aMat);
|
aContext->WorldViewState.SetCurrent (aMat);
|
||||||
aContext->ApplyWorldViewMatrix();
|
aContext->ApplyWorldViewMatrix();
|
||||||
theLine->Render (theWorkspace);
|
theLine.Render (theWorkspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -391,7 +385,7 @@ void OpenGl_GraduatedTrihedron::renderGridPlane (const Handle(OpenGl_Workspace)&
|
|||||||
Graphic3d_TransformUtils::Translate (aMat, aStepVec.x(), aStepVec.y(), aStepVec.z());
|
Graphic3d_TransformUtils::Translate (aMat, aStepVec.x(), aStepVec.y(), aStepVec.z());
|
||||||
aContext->WorldViewState.SetCurrent (aMat);
|
aContext->WorldViewState.SetCurrent (aMat);
|
||||||
aContext->ApplyWorldViewMatrix();
|
aContext->ApplyWorldViewMatrix();
|
||||||
anAxis.Line->Render (theWorkspace);
|
anAxis.Line.Render (theWorkspace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -406,7 +400,7 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW
|
|||||||
{
|
{
|
||||||
const Axis& anAxis = myAxes[theIndex];
|
const Axis& anAxis = myAxes[theIndex];
|
||||||
|
|
||||||
theWorkspace->SetAspectLine (anAxis.LineAspect);
|
theWorkspace->SetAspectLine (&anAxis.LineAspect);
|
||||||
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
|
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
|
||||||
|
|
||||||
// Reset transformations
|
// Reset transformations
|
||||||
@@ -428,7 +422,7 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW
|
|||||||
aContext->ModelWorldState.SetCurrent (aTransMode.Compute (theWorkspace->View()->Camera(), aProjection, aWorldView, aWidth, aHeight));
|
aContext->ModelWorldState.SetCurrent (aTransMode.Compute (theWorkspace->View()->Camera(), aProjection, aWorldView, aWidth, aHeight));
|
||||||
aContext->ApplyModelViewMatrix();
|
aContext->ApplyModelViewMatrix();
|
||||||
|
|
||||||
anAxis.Arrow->Render (theWorkspace);
|
anAxis.Arrow.Render (theWorkspace);
|
||||||
|
|
||||||
// Get current Model-View and Projection states
|
// Get current Model-View and Projection states
|
||||||
OpenGl_Mat4 aModelMat;
|
OpenGl_Mat4 aModelMat;
|
||||||
@@ -463,7 +457,7 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW
|
|||||||
|
|
||||||
aContext->WorldViewState.SetCurrent (aModelMat);
|
aContext->WorldViewState.SetCurrent (aModelMat);
|
||||||
aContext->ApplyWorldViewMatrix();
|
aContext->ApplyWorldViewMatrix();
|
||||||
anAxis.Line->Render (theWorkspace);
|
anAxis.Line.Render (theWorkspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -493,7 +487,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
|
|||||||
|
|
||||||
if (aCurAspect.ToDrawTickmarks() && aCurAspect.TickmarksNumber() > 0)
|
if (aCurAspect.ToDrawTickmarks() && aCurAspect.TickmarksNumber() > 0)
|
||||||
{
|
{
|
||||||
theWorkspace->SetAspectLine (myGridLineAspect);
|
theWorkspace->SetAspectLine (&myGridLineAspect);
|
||||||
|
|
||||||
OpenGl_Mat4 aModelMat (theMat);
|
OpenGl_Mat4 aModelMat (theMat);
|
||||||
|
|
||||||
@@ -506,7 +500,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
|
|||||||
OpenGl_Vec3 aStepVec = anAxis.Direction * aStep;
|
OpenGl_Vec3 aStepVec = anAxis.Direction * aStep;
|
||||||
for (Standard_Integer anIter = 0; anIter <= aCurAspect.TickmarksNumber(); ++anIter)
|
for (Standard_Integer anIter = 0; anIter <= aCurAspect.TickmarksNumber(); ++anIter)
|
||||||
{
|
{
|
||||||
anAxis.Tickmark->Render (theWorkspace);
|
anAxis.Tickmark.Render (theWorkspace);
|
||||||
Graphic3d_TransformUtils::Translate (aModelMat, aStepVec.x(), aStepVec.y(), aStepVec.z());
|
Graphic3d_TransformUtils::Translate (aModelMat, aStepVec.x(), aStepVec.y(), aStepVec.z());
|
||||||
aContext->WorldViewState.SetCurrent (aModelMat);
|
aContext->WorldViewState.SetCurrent (aModelMat);
|
||||||
aContext->ApplyWorldViewMatrix();
|
aContext->ApplyWorldViewMatrix();
|
||||||
@@ -523,24 +517,24 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
|
|||||||
|
|
||||||
OpenGl_Vec3 aMiddle (theGridAxes.Ticks[theIndex] + aSizeVec * theGridAxes.Axes[theIndex] * 0.5f + aDir * (Standard_ShortReal)(theDpix * anOffset));
|
OpenGl_Vec3 aMiddle (theGridAxes.Ticks[theIndex] + aSizeVec * theGridAxes.Axes[theIndex] * 0.5f + aDir * (Standard_ShortReal)(theDpix * anOffset));
|
||||||
|
|
||||||
myAspectLabels->Aspect()->SetColor (anAxis.NameColor);
|
myAspectLabels.Aspect()->SetColor (anAxis.NameColor);
|
||||||
theWorkspace->SetAspectText (myAspectLabels);
|
theWorkspace->SetAspectText (&myAspectLabels);
|
||||||
anAxis.Label->SetPosition (aMiddle);
|
anAxis.Label.SetPosition (aMiddle);
|
||||||
anAxis.Label->Render (theWorkspace);
|
anAxis.Label.Render (theWorkspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aCurAspect.ToDrawValues() && aCurAspect.TickmarksNumber() > 0)
|
if (aCurAspect.ToDrawValues() && aCurAspect.TickmarksNumber() > 0)
|
||||||
{
|
{
|
||||||
myAspectValues->Aspect()->SetColor (anAxis.LineAspect->Aspect()->Color());
|
myAspectValues.Aspect()->SetColor (anAxis.LineAspect.Aspect()->Color());
|
||||||
theWorkspace->SetAspectText (myAspectValues);
|
theWorkspace->SetAspectText (&myAspectValues);
|
||||||
Standard_Real anOffset = aCurAspect.ValuesOffset() + aCurAspect.TickmarksLength();
|
Standard_Real anOffset = aCurAspect.ValuesOffset() + aCurAspect.TickmarksLength();
|
||||||
|
|
||||||
for (Standard_Integer anIt = 0; anIt <= aCurAspect.TickmarksNumber(); ++anIt)
|
for (Standard_Integer anIt = 0; anIt <= aCurAspect.TickmarksNumber(); ++anIt)
|
||||||
{
|
{
|
||||||
sprintf (aTextValue, "%g", theGridAxes.Ticks[theIndex].GetData()[theIndex] + anIt * aStep);
|
sprintf (aTextValue, "%g", theGridAxes.Ticks[theIndex].GetData()[theIndex] + anIt * aStep);
|
||||||
OpenGl_Vec3 aPos (theGridAxes.Ticks[theIndex] + anAxis.Direction* (Standard_ShortReal) (anIt * aStep) + aDir * (Standard_ShortReal) (theDpix * anOffset));
|
OpenGl_Vec3 aPos (theGridAxes.Ticks[theIndex] + anAxis.Direction* (Standard_ShortReal) (anIt * aStep) + aDir * (Standard_ShortReal) (theDpix * anOffset));
|
||||||
myLabelValues->Init (theWorkspace->GetGlContext(), aTextValue, aPos);
|
myLabelValues.Init (theWorkspace->GetGlContext(), aTextValue, aPos);
|
||||||
myLabelValues->Render (theWorkspace);
|
myLabelValues.Render (theWorkspace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -565,9 +559,9 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks
|
|||||||
if (myData.CubicAxesCallback)
|
if (myData.CubicAxesCallback)
|
||||||
{
|
{
|
||||||
myData.CubicAxesCallback (myData.PtrView);
|
myData.CubicAxesCallback (myData.PtrView);
|
||||||
if (!myAxes[0].Line->IsInitialized()
|
if (!myAxes[0].Line.IsInitialized()
|
||||||
|| !myAxes[1].Line->IsInitialized()
|
|| !myAxes[1].Line.IsInitialized()
|
||||||
|| !myAxes[2].Line->IsInitialized()
|
|| !myAxes[2].Line.IsInitialized()
|
||||||
|| OpenGl_Vec3 (anOldMin - myMin).Modulus() > Precision::Confusion()
|
|| OpenGl_Vec3 (anOldMin - myMin).Modulus() > Precision::Confusion()
|
||||||
|| OpenGl_Vec3 (anOldMax - myMax).Modulus() > Precision::Confusion())
|
|| OpenGl_Vec3 (anOldMax - myMax).Modulus() > Precision::Confusion())
|
||||||
{
|
{
|
||||||
@@ -611,8 +605,8 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks
|
|||||||
Standard_ExtCharacter anAxesState = getGridAxes (aCorners, aGridAxes);
|
Standard_ExtCharacter anAxesState = getGridAxes (aCorners, aGridAxes);
|
||||||
|
|
||||||
// Remember current aspects
|
// Remember current aspects
|
||||||
const Handle(OpenGl_AspectLine)& anOldAspectLine = theWorkspace->AspectLine();
|
const OpenGl_AspectLine* anOldAspectLine = theWorkspace->AspectLine();
|
||||||
const Handle(OpenGl_AspectText)& anOldAspectText = theWorkspace->AspectText();
|
const OpenGl_AspectText* anOldAspectText = theWorkspace->AspectText();
|
||||||
|
|
||||||
OpenGl_Mat4 aModelMatrix;
|
OpenGl_Mat4 aModelMatrix;
|
||||||
aModelMatrix.Convert (aContext->WorldViewState.Current());
|
aModelMatrix.Convert (aContext->WorldViewState.Current());
|
||||||
@@ -624,7 +618,7 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks
|
|||||||
|
|
||||||
if (myData.ToDrawGrid())
|
if (myData.ToDrawGrid())
|
||||||
{
|
{
|
||||||
theWorkspace->SetAspectLine (myGridLineAspect);
|
theWorkspace->SetAspectLine (&myGridLineAspect);
|
||||||
|
|
||||||
// render grid edges
|
// render grid edges
|
||||||
if (anAxesState & XOO_XYO)
|
if (anAxesState & XOO_XYO)
|
||||||
@@ -720,14 +714,13 @@ void OpenGl_GraduatedTrihedron::SetMinMax (const OpenGl_Vec3& theMin, const Open
|
|||||||
OpenGl_GraduatedTrihedron::Axis::Axis (const Graphic3d_AxisAspect& theAspect,
|
OpenGl_GraduatedTrihedron::Axis::Axis (const Graphic3d_AxisAspect& theAspect,
|
||||||
const OpenGl_Vec3& theDirection)
|
const OpenGl_Vec3& theDirection)
|
||||||
: Direction (theDirection),
|
: Direction (theDirection),
|
||||||
Label (new OpenGl_Text(NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()).ToCString(), theDirection, THE_LABEL_PARAMS)),
|
Label (NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()).ToCString(), theDirection, THE_LABEL_PARAMS),
|
||||||
Tickmark (new OpenGl_PrimitiveArray (NULL)),
|
Tickmark (NULL),
|
||||||
Line (new OpenGl_PrimitiveArray (NULL)),
|
Line (NULL),
|
||||||
Arrow (new OpenGl_PrimitiveArray (NULL))
|
Arrow (NULL)
|
||||||
{
|
{
|
||||||
NameColor = theAspect.NameColor();
|
NameColor = theAspect.NameColor();
|
||||||
LineAspect = new OpenGl_AspectLine();
|
LineAspect.Aspect()->SetColor (theAspect.Color());
|
||||||
LineAspect->Aspect()->SetColor (theAspect.Color());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -750,9 +743,9 @@ OpenGl_GraduatedTrihedron::Axis& OpenGl_GraduatedTrihedron::Axis::operator= (con
|
|||||||
LineAspect = theOther.LineAspect;
|
LineAspect = theOther.LineAspect;
|
||||||
Label = theOther.Label;
|
Label = theOther.Label;
|
||||||
|
|
||||||
Line ->InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS, theOther.Line->Indices(), theOther.Line->Attributes(), theOther.Line->Bounds());
|
Line .InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS, theOther.Line.Indices(), theOther.Line.Attributes(), theOther.Line.Bounds());
|
||||||
Tickmark->InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS, theOther.Tickmark->Indices(), theOther.Tickmark->Attributes(), theOther.Tickmark->Bounds());
|
Tickmark.InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS, theOther.Tickmark.Indices(), theOther.Tickmark.Attributes(), theOther.Tickmark.Bounds());
|
||||||
Arrow ->InitBuffers (NULL, Graphic3d_TOPA_POLYLINES, theOther.Arrow->Indices(), theOther.Arrow->Attributes(), theOther.Arrow->Bounds());
|
Arrow .InitBuffers (NULL, Graphic3d_TOPA_POLYLINES, theOther.Arrow.Indices(), theOther.Arrow.Attributes(), theOther.Arrow.Bounds());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -787,8 +780,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitArrow (const Handle(OpenGl_Context)& t
|
|||||||
anArray->AddVertex (aPoint3);
|
anArray->AddVertex (aPoint3);
|
||||||
anArray->AddVertex (aPoint1);
|
anArray->AddVertex (aPoint1);
|
||||||
|
|
||||||
Arrow->InitBuffers (theContext, Graphic3d_TOPA_POLYLINES,
|
Arrow.InitBuffers (theContext, Graphic3d_TOPA_POLYLINES,
|
||||||
anArray->Indices(), anArray->Attributes(), anArray->Bounds());
|
anArray->Indices(), anArray->Attributes(), anArray->Bounds());
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -802,8 +795,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitTickmark (const Handle(OpenGl_Context)
|
|||||||
Handle(Graphic3d_ArrayOfSegments) anArray = new Graphic3d_ArrayOfSegments (2);
|
Handle(Graphic3d_ArrayOfSegments) anArray = new Graphic3d_ArrayOfSegments (2);
|
||||||
anArray->AddVertex (0.0f, 0.0f, 0.0f);
|
anArray->AddVertex (0.0f, 0.0f, 0.0f);
|
||||||
anArray->AddVertex (theDir);
|
anArray->AddVertex (theDir);
|
||||||
Tickmark->InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS,
|
Tickmark.InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS,
|
||||||
anArray->Indices(), anArray->Attributes(), anArray->Bounds());
|
anArray->Indices(), anArray->Attributes(), anArray->Bounds());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -819,8 +812,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitLine (const Handle(OpenGl_Context)& th
|
|||||||
anArray->AddVertex (0.0f, 0.0f, 0.0f);
|
anArray->AddVertex (0.0f, 0.0f, 0.0f);
|
||||||
anArray->AddVertex (theDir);
|
anArray->AddVertex (theDir);
|
||||||
|
|
||||||
Line->InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS,
|
Line.InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS,
|
||||||
anArray->Indices(), anArray->Attributes(), anArray->Bounds());
|
anArray->Indices(), anArray->Attributes(), anArray->Bounds());
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -829,8 +822,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitLine (const Handle(OpenGl_Context)& th
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_GraduatedTrihedron::Axis::Release (OpenGl_Context* theCtx)
|
void OpenGl_GraduatedTrihedron::Axis::Release (OpenGl_Context* theCtx)
|
||||||
{
|
{
|
||||||
Label ->Release (theCtx);
|
Label .Release (theCtx);
|
||||||
Tickmark->Release (theCtx);
|
Tickmark.Release (theCtx);
|
||||||
Line ->Release (theCtx);
|
Line .Release (theCtx);
|
||||||
Arrow ->Release (theCtx);
|
Arrow .Release (theCtx);
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,6 @@ class OpenGl_View;
|
|||||||
//! @sa Graphic3d_GraduatedTrihedron
|
//! @sa Graphic3d_GraduatedTrihedron
|
||||||
class OpenGl_GraduatedTrihedron : public OpenGl_Element
|
class OpenGl_GraduatedTrihedron : public OpenGl_Element
|
||||||
{
|
{
|
||||||
DEFINE_STANDARD_RTTIEXT(OpenGl_GraduatedTrihedron, OpenGl_Element)
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DEFINE_STANDARD_ALLOC
|
DEFINE_STANDARD_ALLOC
|
||||||
@@ -71,11 +70,11 @@ private:
|
|||||||
|
|
||||||
OpenGl_Vec3 Direction;
|
OpenGl_Vec3 Direction;
|
||||||
Quantity_Color NameColor;
|
Quantity_Color NameColor;
|
||||||
Handle(OpenGl_AspectLine) LineAspect;
|
OpenGl_AspectLine LineAspect;
|
||||||
mutable Handle(OpenGl_Text) Label;
|
mutable OpenGl_Text Label;
|
||||||
mutable Handle(OpenGl_PrimitiveArray) Tickmark;
|
mutable OpenGl_PrimitiveArray Tickmark;
|
||||||
mutable Handle(OpenGl_PrimitiveArray) Line;
|
mutable OpenGl_PrimitiveArray Line;
|
||||||
mutable Handle(OpenGl_PrimitiveArray) Arrow;
|
mutable OpenGl_PrimitiveArray Arrow;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -166,7 +165,7 @@ private:
|
|||||||
//! @param thaTx the X for vector of translation
|
//! @param thaTx the X for vector of translation
|
||||||
//! @param thaTy the Y for vector of translation
|
//! @param thaTy the Y for vector of translation
|
||||||
//! @param thaTz the Z for vector of translation
|
//! @param thaTz the Z for vector of translation
|
||||||
void renderLine (const Handle(OpenGl_PrimitiveArray)& theLine,
|
void renderLine (const OpenGl_PrimitiveArray& theLine,
|
||||||
const Handle(OpenGl_Workspace)& theWorkspace,
|
const Handle(OpenGl_Workspace)& theWorkspace,
|
||||||
const OpenGl_Mat4& theMat,
|
const OpenGl_Mat4& theMat,
|
||||||
const Standard_ShortReal theXt,
|
const Standard_ShortReal theXt,
|
||||||
@@ -216,13 +215,13 @@ protected:
|
|||||||
|
|
||||||
mutable Axis myAxes[3]; //!< Axes for trihedron
|
mutable Axis myAxes[3]; //!< Axes for trihedron
|
||||||
mutable Graphic3d_GraduatedTrihedron myData;
|
mutable Graphic3d_GraduatedTrihedron myData;
|
||||||
mutable Handle(OpenGl_AspectLine) myGridLineAspect; //!< Color grid properties
|
mutable OpenGl_AspectLine myGridLineAspect; //!< Color grid properties
|
||||||
|
|
||||||
protected: //! @name Labels properties
|
protected: //! @name Labels properties
|
||||||
|
|
||||||
mutable Handle(OpenGl_Text) myLabelValues;
|
mutable OpenGl_Text myLabelValues;
|
||||||
mutable Handle(OpenGl_AspectText) myAspectLabels;
|
mutable OpenGl_AspectText myAspectLabels;
|
||||||
mutable Handle(OpenGl_AspectText) myAspectValues;
|
mutable OpenGl_AspectText myAspectValues;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@@ -451,6 +451,8 @@ Standard_Integer OpenGl_GraphicDriver::InquireLimit (const Graphic3d_TypeOfLimit
|
|||||||
return (!aCtx.IsNull() && aCtx->HasRayTracingTextures()) ? 1 : 0;
|
return (!aCtx.IsNull() && aCtx->HasRayTracingTextures()) ? 1 : 0;
|
||||||
case Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSampling:
|
case Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSampling:
|
||||||
return (!aCtx.IsNull() && aCtx->HasRayTracingAdaptiveSampling()) ? 1 : 0;
|
return (!aCtx.IsNull() && aCtx->HasRayTracingAdaptiveSampling()) ? 1 : 0;
|
||||||
|
case Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSamplingAtomic:
|
||||||
|
return (!aCtx.IsNull() && aCtx->HasRayTracingAdaptiveSamplingAtomic()) ? 1 : 0;
|
||||||
case Graphic3d_TypeOfLimit_HasBlendedOit:
|
case Graphic3d_TypeOfLimit_HasBlendedOit:
|
||||||
return (!aCtx.IsNull()
|
return (!aCtx.IsNull()
|
||||||
&& aCtx->hasDrawBuffers != OpenGl_FeatureNotAvailable
|
&& aCtx->hasDrawBuffers != OpenGl_FeatureNotAvailable
|
||||||
@@ -463,6 +465,8 @@ Standard_Integer OpenGl_GraphicDriver::InquireLimit (const Graphic3d_TypeOfLimit
|
|||||||
return !aCtx.IsNull() && aCtx->hasFlatShading != OpenGl_FeatureNotAvailable ? 1 : 0;
|
return !aCtx.IsNull() && aCtx->hasFlatShading != OpenGl_FeatureNotAvailable ? 1 : 0;
|
||||||
case Graphic3d_TypeOfLimit_IsWorkaroundFBO:
|
case Graphic3d_TypeOfLimit_IsWorkaroundFBO:
|
||||||
return !aCtx.IsNull() && aCtx->MaxTextureSize() != aCtx->MaxDumpSizeX() ? 1 : 0;
|
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:
|
case Graphic3d_TypeOfLimit_NB:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -560,8 +564,8 @@ void OpenGl_GraphicDriver::TextSize (const Handle(Graphic3d_CView)& theView,
|
|||||||
const Standard_ShortReal aHeight = (theHeight < 2.0f) ? DefaultTextHeight() : theHeight;
|
const Standard_ShortReal aHeight = (theHeight < 2.0f) ? DefaultTextHeight() : theHeight;
|
||||||
OpenGl_TextParam aTextParam;
|
OpenGl_TextParam aTextParam;
|
||||||
aTextParam.Height = (int )aHeight;
|
aTextParam.Height = (int )aHeight;
|
||||||
Handle(OpenGl_AspectText) aTextAspect = new OpenGl_AspectText();
|
OpenGl_AspectText aTextAspect;
|
||||||
aTextAspect->Aspect()->SetSpace (0.3);
|
aTextAspect.Aspect()->SetSpace (0.3);
|
||||||
TCollection_ExtendedString anExtText = theText;
|
TCollection_ExtendedString anExtText = theText;
|
||||||
NCollection_String aText (anExtText.ToExtString());
|
NCollection_String aText (anExtText.ToExtString());
|
||||||
OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aTextParam, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent);
|
OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aTextParam, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent);
|
||||||
|
@@ -40,7 +40,7 @@ namespace
|
|||||||
//! should be rendered or not.
|
//! should be rendered or not.
|
||||||
//! @return True if element passes the check and renders,
|
//! @return True if element passes the check and renders,
|
||||||
static bool renderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
|
static bool renderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||||
const Handle(OpenGl_Element)& theElement)
|
OpenGl_Element* theElement)
|
||||||
{
|
{
|
||||||
if (!theWorkspace->ShouldRender (theElement))
|
if (!theWorkspace->ShouldRender (theElement))
|
||||||
{
|
{
|
||||||
@@ -58,6 +58,12 @@ namespace
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
OpenGl_Group::OpenGl_Group (const Handle(Graphic3d_Structure)& theStruct)
|
OpenGl_Group::OpenGl_Group (const Handle(Graphic3d_Structure)& theStruct)
|
||||||
: Graphic3d_Group (theStruct),
|
: Graphic3d_Group (theStruct),
|
||||||
|
myAspectLine(NULL),
|
||||||
|
myAspectFace(NULL),
|
||||||
|
myAspectMarker(NULL),
|
||||||
|
myAspectText(NULL),
|
||||||
|
myFirst(NULL),
|
||||||
|
myLast(NULL),
|
||||||
myIsRaytracable (Standard_False)
|
myIsRaytracable (Standard_False)
|
||||||
{
|
{
|
||||||
Handle(OpenGl_Structure) aStruct = Handle(OpenGl_Structure)::DownCast (myStructure->CStructure());
|
Handle(OpenGl_Structure) aStruct = Handle(OpenGl_Structure)::DownCast (myStructure->CStructure());
|
||||||
@@ -87,7 +93,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myAspectLine.IsNull())
|
if (myAspectLine == NULL)
|
||||||
{
|
{
|
||||||
myAspectLine = new OpenGl_AspectLine (theAspect);
|
myAspectLine = new OpenGl_AspectLine (theAspect);
|
||||||
}
|
}
|
||||||
@@ -104,7 +110,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect)
|
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect)
|
||||||
{
|
{
|
||||||
if (myAspectLine.IsNull())
|
if (myAspectLine == NULL)
|
||||||
{
|
{
|
||||||
SetGroupPrimitivesAspect (theAspect);
|
SetGroupPrimitivesAspect (theAspect);
|
||||||
return;
|
return;
|
||||||
@@ -114,7 +120,7 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& th
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(OpenGl_AspectLine) anAspectLine = new OpenGl_AspectLine (theAspect);
|
OpenGl_AspectLine* anAspectLine = new OpenGl_AspectLine (theAspect);
|
||||||
AddElement (anAspectLine);
|
AddElement (anAspectLine);
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
@@ -130,7 +136,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillAr
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myAspectFace.IsNull())
|
if (myAspectFace == NULL)
|
||||||
{
|
{
|
||||||
myAspectFace = new OpenGl_AspectFace (theAspect);
|
myAspectFace = new OpenGl_AspectFace (theAspect);
|
||||||
}
|
}
|
||||||
@@ -157,7 +163,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillAr
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
|
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
|
||||||
{
|
{
|
||||||
if (myAspectFace.IsNull())
|
if (myAspectFace == NULL)
|
||||||
{
|
{
|
||||||
SetGroupPrimitivesAspect (theAspect);
|
SetGroupPrimitivesAspect (theAspect);
|
||||||
return;
|
return;
|
||||||
@@ -167,7 +173,7 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(OpenGl_AspectFace) anAspectFace = new OpenGl_AspectFace (theAspect);
|
OpenGl_AspectFace* anAspectFace = new OpenGl_AspectFace (theAspect);
|
||||||
AddElement (anAspectFace);
|
AddElement (anAspectFace);
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
@@ -183,7 +189,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myAspectMarker.IsNull())
|
if (myAspectMarker == NULL)
|
||||||
{
|
{
|
||||||
myAspectMarker = new OpenGl_AspectMarker (theAspMarker);
|
myAspectMarker = new OpenGl_AspectMarker (theAspMarker);
|
||||||
}
|
}
|
||||||
@@ -200,7 +206,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
|
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
|
||||||
{
|
{
|
||||||
if (myAspectMarker.IsNull())
|
if (myAspectMarker == NULL)
|
||||||
{
|
{
|
||||||
SetGroupPrimitivesAspect (theAspMarker);
|
SetGroupPrimitivesAspect (theAspMarker);
|
||||||
return;
|
return;
|
||||||
@@ -210,7 +216,7 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)&
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(OpenGl_AspectMarker) anAspectMarker = new OpenGl_AspectMarker (theAspMarker);
|
OpenGl_AspectMarker* anAspectMarker = new OpenGl_AspectMarker (theAspMarker);
|
||||||
AddElement (anAspectMarker);
|
AddElement (anAspectMarker);
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
@@ -226,7 +232,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myAspectText.IsNull())
|
if (myAspectText == NULL)
|
||||||
{
|
{
|
||||||
myAspectText = new OpenGl_AspectText (theAspText);
|
myAspectText = new OpenGl_AspectText (theAspText);
|
||||||
}
|
}
|
||||||
@@ -243,7 +249,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
|
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
|
||||||
{
|
{
|
||||||
if (myAspectText.IsNull())
|
if (myAspectText == NULL)
|
||||||
{
|
{
|
||||||
SetGroupPrimitivesAspect (theAspText);
|
SetGroupPrimitivesAspect (theAspText);
|
||||||
return;
|
return;
|
||||||
@@ -253,7 +259,7 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& th
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(OpenGl_AspectText) anAspectText = new OpenGl_AspectText (theAspText);
|
OpenGl_AspectText* anAspectText = new OpenGl_AspectText (theAspText);
|
||||||
AddElement (anAspectText);
|
AddElement (anAspectText);
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
@@ -264,25 +270,25 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& th
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Group::SynchronizeAspects()
|
void OpenGl_Group::SynchronizeAspects()
|
||||||
{
|
{
|
||||||
if (!myAspectFace.IsNull())
|
if (myAspectFace != NULL)
|
||||||
{
|
{
|
||||||
myAspectFace->SynchronizeAspects();
|
myAspectFace->SynchronizeAspects();
|
||||||
}
|
}
|
||||||
if (!myAspectLine.IsNull())
|
if (myAspectLine != NULL)
|
||||||
{
|
{
|
||||||
myAspectLine->SynchronizeAspects();
|
myAspectLine->SynchronizeAspects();
|
||||||
}
|
}
|
||||||
if (!myAspectMarker.IsNull())
|
if (myAspectMarker != NULL)
|
||||||
{
|
{
|
||||||
myAspectMarker->SynchronizeAspects();
|
myAspectMarker->SynchronizeAspects();
|
||||||
}
|
}
|
||||||
if (!myAspectText.IsNull())
|
if (myAspectText != NULL)
|
||||||
{
|
{
|
||||||
myAspectText->SynchronizeAspects();
|
myAspectText->SynchronizeAspects();
|
||||||
}
|
}
|
||||||
for (OpenGl_ElementNodes::Iterator anElemIterator(myElements); anElemIterator.More(); anElemIterator.Next())
|
for (OpenGl_ElementNode* aNode = myFirst; aNode != NULL; aNode = aNode->next)
|
||||||
{
|
{
|
||||||
anElemIterator.ChangeValue()->SynchronizeAspects();
|
aNode->elem->SynchronizeAspects();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +311,7 @@ void OpenGl_Group::AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theTy
|
|||||||
OpenGl_Structure* aStruct = GlStruct();
|
OpenGl_Structure* aStruct = GlStruct();
|
||||||
const OpenGl_GraphicDriver* aDriver = aStruct->GlDriver();
|
const OpenGl_GraphicDriver* aDriver = aStruct->GlDriver();
|
||||||
|
|
||||||
Handle(OpenGl_PrimitiveArray) anArray = new OpenGl_PrimitiveArray (aDriver, theType, theIndices, theAttribs, theBounds);
|
OpenGl_PrimitiveArray* anArray = new OpenGl_PrimitiveArray (aDriver, theType, theIndices, theAttribs, theBounds);
|
||||||
AddElement (anArray);
|
AddElement (anArray);
|
||||||
|
|
||||||
Graphic3d_Group::AddPrimitiveArray (theType, theIndices, theAttribs, theBounds, theToEvalMinMax);
|
Graphic3d_Group::AddPrimitiveArray (theType, theIndices, theAttribs, theBounds, theToEvalMinMax);
|
||||||
@@ -335,7 +341,7 @@ void OpenGl_Group::Text (const Standard_CString theTextUtf,
|
|||||||
aParams.HAlign = theHta;
|
aParams.HAlign = theHta;
|
||||||
aParams.VAlign = theVta;
|
aParams.VAlign = theVta;
|
||||||
const OpenGl_Vec3 aPoint (thePoint.X(), thePoint.Y(), thePoint.Z());
|
const OpenGl_Vec3 aPoint (thePoint.X(), thePoint.Y(), thePoint.Z());
|
||||||
Handle(OpenGl_Text) aText = new OpenGl_Text (theTextUtf, aPoint, aParams);
|
OpenGl_Text* aText = new OpenGl_Text (theTextUtf, aPoint, aParams);
|
||||||
AddElement (aText);
|
AddElement (aText);
|
||||||
Graphic3d_Group::Text (theTextUtf, thePoint, theHeight, theAngle,
|
Graphic3d_Group::Text (theTextUtf, thePoint, theHeight, theAngle,
|
||||||
theTp, theHta, theVta, theToEvalMinMax);
|
theTp, theHta, theVta, theToEvalMinMax);
|
||||||
@@ -367,7 +373,7 @@ void OpenGl_Group::Text (const Standard_CString theTextUtf,
|
|||||||
aParams.HAlign = theHTA;
|
aParams.HAlign = theHTA;
|
||||||
aParams.VAlign = theVTA;
|
aParams.VAlign = theVTA;
|
||||||
|
|
||||||
Handle(OpenGl_Text) aText = new OpenGl_Text (theTextUtf, theOrientation, aParams, theHasOwnAnchor != Standard_False);
|
OpenGl_Text* aText = new OpenGl_Text (theTextUtf, theOrientation, aParams, theHasOwnAnchor != Standard_False);
|
||||||
|
|
||||||
AddElement (aText);
|
AddElement (aText);
|
||||||
|
|
||||||
@@ -390,7 +396,7 @@ void OpenGl_Group::Text (const Standard_CString theTextUtf,
|
|||||||
void OpenGl_Group::SetFlippingOptions (const Standard_Boolean theIsEnabled,
|
void OpenGl_Group::SetFlippingOptions (const Standard_Boolean theIsEnabled,
|
||||||
const gp_Ax2& theRefPlane)
|
const gp_Ax2& theRefPlane)
|
||||||
{
|
{
|
||||||
Handle(OpenGl_Flipper) aFlipper = new OpenGl_Flipper (theRefPlane);
|
OpenGl_Flipper* aFlipper = new OpenGl_Flipper (theRefPlane);
|
||||||
aFlipper->SetOptions (theIsEnabled);
|
aFlipper->SetOptions (theIsEnabled);
|
||||||
AddElement (aFlipper);
|
AddElement (aFlipper);
|
||||||
}
|
}
|
||||||
@@ -401,7 +407,7 @@ void OpenGl_Group::SetFlippingOptions (const Standard_Boolean theIsEnabled,
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Group::SetStencilTestOptions (const Standard_Boolean theIsEnabled)
|
void OpenGl_Group::SetStencilTestOptions (const Standard_Boolean theIsEnabled)
|
||||||
{
|
{
|
||||||
Handle(OpenGl_StencilTest) aStencilTest = new OpenGl_StencilTest();
|
OpenGl_StencilTest* aStencilTest = new OpenGl_StencilTest();
|
||||||
aStencilTest->SetOptions (theIsEnabled);
|
aStencilTest->SetOptions (theIsEnabled);
|
||||||
AddElement (aStencilTest);
|
AddElement (aStencilTest);
|
||||||
}
|
}
|
||||||
@@ -410,11 +416,16 @@ void OpenGl_Group::SetStencilTestOptions (const Standard_Boolean theIsEnabled)
|
|||||||
// function : AddElement
|
// function : AddElement
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Group::AddElement (Handle(OpenGl_Element) theElem)
|
void OpenGl_Group::AddElement (OpenGl_Element* theElem)
|
||||||
{
|
{
|
||||||
myElements.Append (theElem);
|
OpenGl_ElementNode *aNode = new OpenGl_ElementNode();
|
||||||
|
|
||||||
if (OpenGl_Raytrace::IsRaytracedElement (theElem))
|
aNode->elem = theElem;
|
||||||
|
aNode->next = NULL;
|
||||||
|
(myLast? myLast->next : myFirst) = aNode;
|
||||||
|
myLast = aNode;
|
||||||
|
|
||||||
|
if (OpenGl_Raytrace::IsRaytracedElement (aNode))
|
||||||
{
|
{
|
||||||
myIsRaytracable = Standard_True;
|
myIsRaytracable = Standard_True;
|
||||||
|
|
||||||
@@ -435,19 +446,19 @@ void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
|||||||
// Setup aspects
|
// Setup aspects
|
||||||
theWorkspace->SetAllowFaceCulling (myIsClosed
|
theWorkspace->SetAllowFaceCulling (myIsClosed
|
||||||
&& !theWorkspace->GetGlContext()->Clipping().IsClippingOrCappingOn());
|
&& !theWorkspace->GetGlContext()->Clipping().IsClippingOrCappingOn());
|
||||||
const Handle(OpenGl_AspectLine)& aBackAspectLine = theWorkspace->AspectLine();
|
const OpenGl_AspectLine* aBackAspectLine = theWorkspace->AspectLine();
|
||||||
const Handle(OpenGl_AspectFace)& aBackAspectFace = theWorkspace->AspectFace();
|
const OpenGl_AspectFace* aBackAspectFace = theWorkspace->AspectFace();
|
||||||
const Handle(OpenGl_AspectMarker)& aBackAspectMarker = theWorkspace->AspectMarker();
|
const OpenGl_AspectMarker* aBackAspectMarker = theWorkspace->AspectMarker();
|
||||||
const Handle(OpenGl_AspectText)& aBackAspectText = theWorkspace->AspectText();
|
const OpenGl_AspectText* aBackAspectText = theWorkspace->AspectText();
|
||||||
const bool isLineSet = !myAspectLine.IsNull() && renderFiltered (theWorkspace, myAspectLine);
|
const bool isLineSet = myAspectLine && renderFiltered (theWorkspace, myAspectLine);
|
||||||
const bool isFaceSet = !myAspectFace.IsNull() && renderFiltered (theWorkspace, myAspectFace);
|
const bool isFaceSet = myAspectFace && renderFiltered (theWorkspace, myAspectFace);
|
||||||
const bool isMarkerSet = !myAspectMarker.IsNull() && renderFiltered (theWorkspace, myAspectMarker);
|
const bool isMarkerSet = myAspectMarker && renderFiltered (theWorkspace, myAspectMarker);
|
||||||
const bool isTextSet = !myAspectText.IsNull() && renderFiltered (theWorkspace, myAspectText);
|
const bool isTextSet = myAspectText && renderFiltered (theWorkspace, myAspectText);
|
||||||
|
|
||||||
// Render group elements
|
// Render group elements
|
||||||
for (OpenGl_ElementNodes::Iterator anElemIterator(myElements); anElemIterator.More(); anElemIterator.Next())
|
for (OpenGl_ElementNode* aNodeIter = myFirst; aNodeIter != NULL; aNodeIter = aNodeIter->next)
|
||||||
{
|
{
|
||||||
renderFiltered (theWorkspace, anElemIterator.Value());
|
renderFiltered (theWorkspace, aNodeIter->elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore aspects
|
// Restore aspects
|
||||||
@@ -488,11 +499,14 @@ void OpenGl_Group::Clear (const Standard_Boolean theToUpdateStructureMgr)
|
|||||||
void OpenGl_Group::Release (const Handle(OpenGl_Context)& theGlCtx)
|
void OpenGl_Group::Release (const Handle(OpenGl_Context)& theGlCtx)
|
||||||
{
|
{
|
||||||
// Delete elements
|
// Delete elements
|
||||||
for (OpenGl_ElementNodes::Iterator anElemIterator(myElements); anElemIterator.More(); anElemIterator.Next())
|
while (myFirst != NULL)
|
||||||
{
|
{
|
||||||
OpenGl_Element::Destroy (theGlCtx.operator->(), anElemIterator.ChangeValue());
|
OpenGl_ElementNode* aNext = myFirst->next;
|
||||||
|
OpenGl_Element::Destroy (theGlCtx.operator->(), myFirst->elem);
|
||||||
|
delete myFirst;
|
||||||
|
myFirst = aNext;
|
||||||
}
|
}
|
||||||
myElements.Clear();
|
myLast = NULL;
|
||||||
|
|
||||||
OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectLine);
|
OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectLine);
|
||||||
OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectFace);
|
OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectFace);
|
||||||
|
@@ -29,7 +29,12 @@
|
|||||||
class OpenGl_Group;
|
class OpenGl_Group;
|
||||||
class OpenGl_Structure;
|
class OpenGl_Structure;
|
||||||
|
|
||||||
typedef NCollection_List<Handle(OpenGl_Element)> OpenGl_ElementNodes;
|
struct OpenGl_ElementNode
|
||||||
|
{
|
||||||
|
OpenGl_Element* elem;
|
||||||
|
OpenGl_ElementNode* next;
|
||||||
|
DEFINE_STANDARD_ALLOC
|
||||||
|
};
|
||||||
|
|
||||||
//! Implementation of low-level graphic group.
|
//! Implementation of low-level graphic group.
|
||||||
class OpenGl_Group : public Graphic3d_Group
|
class OpenGl_Group : public Graphic3d_Group
|
||||||
@@ -45,9 +50,9 @@ public:
|
|||||||
//! Return line aspect.
|
//! Return line aspect.
|
||||||
virtual Handle(Graphic3d_AspectLine3d) LineAspect() const Standard_OVERRIDE
|
virtual Handle(Graphic3d_AspectLine3d) LineAspect() const Standard_OVERRIDE
|
||||||
{
|
{
|
||||||
return !myAspectLine.IsNull()
|
return myAspectLine != NULL
|
||||||
? myAspectLine->Aspect()
|
? myAspectLine->Aspect()
|
||||||
: Handle(Graphic3d_AspectLine3d)();
|
: Handle(Graphic3d_AspectLine3d)();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Update line aspect.
|
//! Update line aspect.
|
||||||
@@ -59,9 +64,9 @@ public:
|
|||||||
//! Return marker aspect.
|
//! Return marker aspect.
|
||||||
virtual Handle(Graphic3d_AspectMarker3d) MarkerAspect() const Standard_OVERRIDE
|
virtual Handle(Graphic3d_AspectMarker3d) MarkerAspect() const Standard_OVERRIDE
|
||||||
{
|
{
|
||||||
return !myAspectMarker.IsNull()
|
return myAspectMarker != NULL
|
||||||
? myAspectMarker->Aspect()
|
? myAspectMarker->Aspect()
|
||||||
: Handle(Graphic3d_AspectMarker3d)();
|
: Handle(Graphic3d_AspectMarker3d)();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Update marker aspect.
|
//! Update marker aspect.
|
||||||
@@ -73,7 +78,7 @@ public:
|
|||||||
//! Return fill area aspect.
|
//! Return fill area aspect.
|
||||||
virtual Handle(Graphic3d_AspectFillArea3d) FillAreaAspect() const Standard_OVERRIDE
|
virtual Handle(Graphic3d_AspectFillArea3d) FillAreaAspect() const Standard_OVERRIDE
|
||||||
{
|
{
|
||||||
return !myAspectFace.IsNull()
|
return myAspectFace != NULL
|
||||||
? myAspectFace->Aspect()
|
? myAspectFace->Aspect()
|
||||||
: Handle(Graphic3d_AspectFillArea3d)();
|
: Handle(Graphic3d_AspectFillArea3d)();
|
||||||
}
|
}
|
||||||
@@ -87,7 +92,7 @@ public:
|
|||||||
//! Return marker aspect.
|
//! Return marker aspect.
|
||||||
virtual Handle(Graphic3d_AspectText3d) TextAspect() const Standard_OVERRIDE
|
virtual Handle(Graphic3d_AspectText3d) TextAspect() const Standard_OVERRIDE
|
||||||
{
|
{
|
||||||
return !myAspectText.IsNull()
|
return myAspectText != NULL
|
||||||
? myAspectText->Aspect()
|
? myAspectText->Aspect()
|
||||||
: Handle(Graphic3d_AspectText3d)();
|
: Handle(Graphic3d_AspectText3d)();
|
||||||
}
|
}
|
||||||
@@ -140,16 +145,16 @@ public:
|
|||||||
|
|
||||||
OpenGl_Structure* GlStruct() const { return (OpenGl_Structure* )(myStructure->CStructure().operator->()); }
|
OpenGl_Structure* GlStruct() const { return (OpenGl_Structure* )(myStructure->CStructure().operator->()); }
|
||||||
|
|
||||||
Standard_EXPORT void AddElement (Handle(OpenGl_Element) theElem);
|
Standard_EXPORT void AddElement (OpenGl_Element* theElem);
|
||||||
|
|
||||||
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||||
Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)& theGlCtx);
|
Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)& theGlCtx);
|
||||||
|
|
||||||
//! Returns OpenGl elements of the group
|
//! Returns first OpenGL element node of the group.
|
||||||
const OpenGl_ElementNodes& GetElements() const { return myElements; }
|
const OpenGl_ElementNode* FirstNode() const { return myFirst; }
|
||||||
|
|
||||||
//! Returns OpenGL face aspect.
|
//! Returns OpenGL face aspect.
|
||||||
const Handle(OpenGl_AspectFace)& AspectFace() const { return myAspectFace; }
|
const OpenGl_AspectFace* AspectFace() const { return myAspectFace; }
|
||||||
|
|
||||||
//! Is the group ray-tracable (contains ray-tracable elements)?
|
//! Is the group ray-tracable (contains ray-tracable elements)?
|
||||||
Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
|
Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
|
||||||
@@ -160,12 +165,13 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Handle(OpenGl_AspectLine) myAspectLine;
|
OpenGl_AspectLine* myAspectLine;
|
||||||
Handle(OpenGl_AspectFace) myAspectFace;
|
OpenGl_AspectFace* myAspectFace;
|
||||||
Handle(OpenGl_AspectMarker) myAspectMarker;
|
OpenGl_AspectMarker* myAspectMarker;
|
||||||
Handle(OpenGl_AspectText) myAspectText;
|
OpenGl_AspectText* myAspectText;
|
||||||
|
|
||||||
OpenGl_ElementNodes myElements;
|
OpenGl_ElementNode* myFirst;
|
||||||
|
OpenGl_ElementNode* myLast;
|
||||||
|
|
||||||
Standard_Boolean myIsRaytracable;
|
Standard_Boolean myIsRaytracable;
|
||||||
|
|
||||||
|
@@ -109,7 +109,11 @@ int OpenGl_LineAttributes::SetTypeOfHatch (const OpenGl_Context* t
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#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);
|
theGlCtx->core11->glCallList ((GLuint)aGpuListId);
|
||||||
|
|
||||||
@@ -146,7 +150,11 @@ bool OpenGl_LineAttributes::SetEnabled (const OpenGl_Context* theGlCtx,
|
|||||||
const bool anOldIsEnabled = myIsEnabled;
|
const bool anOldIsEnabled = myIsEnabled;
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
if (theToEnable)
|
if (theGlCtx->core11 == NULL)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (theToEnable)
|
||||||
{
|
{
|
||||||
if (myTypeOfHatch != 0)
|
if (myTypeOfHatch != 0)
|
||||||
{
|
{
|
||||||
|
@@ -50,6 +50,9 @@ public:
|
|||||||
//! Alpha cutoff value.
|
//! Alpha cutoff value.
|
||||||
float AlphaCutoff() const { return myAlphaCutoff; }
|
float AlphaCutoff() const { return myAlphaCutoff; }
|
||||||
|
|
||||||
|
//! Return TRUE if alpha test should be enabled.
|
||||||
|
bool HasAlphaCutoff() const { return myAlphaCutoff <= 1.0f; }
|
||||||
|
|
||||||
//! Distinguish front/back flag.
|
//! Distinguish front/back flag.
|
||||||
bool ToDistinguish() const { return myToDistinguish; }
|
bool ToDistinguish() const { return myToDistinguish; }
|
||||||
|
|
||||||
|
@@ -13,13 +13,12 @@
|
|||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
#include <OpenGl_PrimitiveArray.hxx>
|
|
||||||
|
|
||||||
#include <OpenGl_AspectFace.hxx>
|
#include <OpenGl_AspectFace.hxx>
|
||||||
#include <OpenGl_Context.hxx>
|
#include <OpenGl_Context.hxx>
|
||||||
#include <OpenGl_GraphicDriver.hxx>
|
#include <OpenGl_GraphicDriver.hxx>
|
||||||
#include <OpenGl_IndexBuffer.hxx>
|
#include <OpenGl_IndexBuffer.hxx>
|
||||||
#include <OpenGl_PointSprite.hxx>
|
#include <OpenGl_PointSprite.hxx>
|
||||||
|
#include <OpenGl_PrimitiveArray.hxx>
|
||||||
#include <OpenGl_Sampler.hxx>
|
#include <OpenGl_Sampler.hxx>
|
||||||
#include <OpenGl_ShaderManager.hxx>
|
#include <OpenGl_ShaderManager.hxx>
|
||||||
#include <OpenGl_ShaderProgram.hxx>
|
#include <OpenGl_ShaderProgram.hxx>
|
||||||
@@ -29,8 +28,6 @@
|
|||||||
#include <Graphic3d_TextureParams.hxx>
|
#include <Graphic3d_TextureParams.hxx>
|
||||||
#include <NCollection_AlignedAllocator.hxx>
|
#include <NCollection_AlignedAllocator.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_PrimitiveArray, OpenGl_Element)
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
//! Convert data type to GL info
|
//! Convert data type to GL info
|
||||||
@@ -505,13 +502,10 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeCo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Handle(OpenGl_AspectLine) anAspectLineOld = theWorkspace->AspectLine();
|
const OpenGl_AspectLine* anAspectLineOld = theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge());
|
||||||
theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge());
|
const OpenGl_AspectLine* anAspect = theWorkspace->ApplyAspectLine();
|
||||||
|
|
||||||
const Handle(OpenGl_AspectLine)& anAspect = theWorkspace->ApplyAspectLine();
|
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
|
const Standard_Integer aPolyModeOld = aGlContext->SetPolygonMode (GL_LINE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (aGlContext->core20fwd != NULL)
|
if (aGlContext->core20fwd != NULL)
|
||||||
@@ -585,6 +579,9 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeCo
|
|||||||
|
|
||||||
// restore line context
|
// restore line context
|
||||||
theWorkspace->SetAspectLine (anAspectLineOld);
|
theWorkspace->SetAspectLine (anAspectLineOld);
|
||||||
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
|
aGlContext->SetPolygonMode (aPolyModeOld);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -593,8 +590,8 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeCo
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const
|
void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||||
{
|
{
|
||||||
const Handle(OpenGl_AspectMarker)& anAspectMarker = theWorkspace->ApplyAspectMarker();
|
const OpenGl_AspectMarker* anAspectMarker = theWorkspace->ApplyAspectMarker();
|
||||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||||
const GLenum aDrawMode = !aCtx->ActiveProgram().IsNull()
|
const GLenum aDrawMode = !aCtx->ActiveProgram().IsNull()
|
||||||
&& aCtx->ActiveProgram()->HasTessellationStage()
|
&& aCtx->ActiveProgram()->HasTessellationStage()
|
||||||
? GL_PATCHES
|
? GL_PATCHES
|
||||||
@@ -770,9 +767,9 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Handle(OpenGl_AspectFace)& anAspectFace = theWorkspace->ApplyAspectFace();
|
const OpenGl_AspectFace* anAspectFace = theWorkspace->ApplyAspectFace();
|
||||||
const Handle(OpenGl_AspectLine)& anAspectLine = theWorkspace->ApplyAspectLine();
|
const OpenGl_AspectLine* anAspectLine = theWorkspace->ApplyAspectLine();
|
||||||
const Handle(OpenGl_AspectMarker)& anAspectMarker = myDrawMode == GL_POINTS
|
const OpenGl_AspectMarker* anAspectMarker = myDrawMode == GL_POINTS
|
||||||
? theWorkspace->ApplyAspectMarker()
|
? theWorkspace->ApplyAspectMarker()
|
||||||
: theWorkspace->AspectMarker();
|
: theWorkspace->AspectMarker();
|
||||||
|
|
||||||
@@ -806,9 +803,34 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
|||||||
// Temporarily disable environment mapping
|
// Temporarily disable environment mapping
|
||||||
Handle(OpenGl_TextureSet) aTextureBack;
|
Handle(OpenGl_TextureSet) aTextureBack;
|
||||||
bool toDrawArray = true;
|
bool toDrawArray = true;
|
||||||
|
int toDrawInteriorEdges = 0; // 0 - no edges, 1 - glsl edges, 2 - polygonMode
|
||||||
if (myDrawMode > GL_LINE_STRIP)
|
if (myDrawMode > GL_LINE_STRIP)
|
||||||
{
|
{
|
||||||
toDrawArray = anAspectFace->Aspect()->InteriorStyle() != Aspect_IS_EMPTY;
|
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)
|
else if (myDrawMode <= GL_LINE_STRIP)
|
||||||
{
|
{
|
||||||
@@ -872,10 +894,16 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
|||||||
const Standard_Boolean toEnableEnvMap = (!aTextures.IsNull() && (aTextures == theWorkspace->EnvironmentTexture()));
|
const Standard_Boolean toEnableEnvMap = (!aTextures.IsNull() && (aTextures == theWorkspace->EnvironmentTexture()));
|
||||||
aCtx->ShaderManager()->BindFaceProgram (aTextures,
|
aCtx->ShaderManager()->BindFaceProgram (aTextures,
|
||||||
aShadingModel,
|
aShadingModel,
|
||||||
anAspectFace->Aspect()->AlphaMode(),
|
aCtx->ShaderManager()->MaterialState().HasAlphaCutoff() ? Graphic3d_AlphaMode_Mask : Graphic3d_AlphaMode_Opaque,
|
||||||
|
toDrawInteriorEdges == 1 ? anAspectFace->Aspect()->InteriorStyle() : Aspect_IS_SOLID,
|
||||||
hasVertColor,
|
hasVertColor,
|
||||||
toEnableEnvMap,
|
toEnableEnvMap,
|
||||||
|
toDrawInteriorEdges == 1,
|
||||||
anAspectFace->ShaderProgramRes (aCtx));
|
anAspectFace->ShaderProgramRes (aCtx));
|
||||||
|
if (toDrawInteriorEdges == 1)
|
||||||
|
{
|
||||||
|
aCtx->ShaderManager()->PushInteriorState (aCtx->ActiveProgram(), anAspectFace->Aspect());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -931,24 +959,21 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
|||||||
{
|
{
|
||||||
aCtx->BindTextures (aTextureBack);
|
aCtx->BindTextures (aTextureBack);
|
||||||
}
|
}
|
||||||
else
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
|
else if (toDrawInteriorEdges == 2)
|
||||||
{
|
{
|
||||||
if (anAspectFace->Aspect()->ToDrawEdges()
|
if (anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_HOLLOW
|
||||||
|| anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_HIDDENLINE)
|
&& anAspectFace->Aspect()->EdgeLineType() == Aspect_TOL_SOLID)
|
||||||
|
{
|
||||||
|
aCtx->SetPolygonMode (GL_FILL);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
const OpenGl_Vec4& anEdgeColor = theWorkspace->EdgeColor();
|
const OpenGl_Vec4& anEdgeColor = theWorkspace->EdgeColor();
|
||||||
drawEdges (anEdgeColor, theWorkspace);
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -1046,7 +1071,7 @@ Standard_Boolean OpenGl_PrimitiveArray::processIndices (const Handle(OpenGl_Cont
|
|||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myAttribs->NbElements > IntegerLast()/*std::numeric_limits<GLushort>::max()*/)
|
if (myAttribs->NbElements > std::numeric_limits<GLushort>::max())
|
||||||
{
|
{
|
||||||
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (new NCollection_AlignedAllocator (16));
|
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (new NCollection_AlignedAllocator (16));
|
||||||
if (!anAttribs->Init (myIndices->NbElements, myAttribs->AttributesArray(), myAttribs->NbAttributes))
|
if (!anAttribs->Init (myIndices->NbElements, myAttribs->AttributesArray(), myAttribs->NbAttributes))
|
||||||
|
@@ -31,7 +31,6 @@ class OpenGl_GraphicDriver;
|
|||||||
//! Class for rendering of arbitrary primitive array.
|
//! Class for rendering of arbitrary primitive array.
|
||||||
class OpenGl_PrimitiveArray : public OpenGl_Element
|
class OpenGl_PrimitiveArray : public OpenGl_Element
|
||||||
{
|
{
|
||||||
DEFINE_STANDARD_RTTIEXT(OpenGl_PrimitiveArray, OpenGl_Element)
|
|
||||||
public:
|
public:
|
||||||
//! OpenGL does not provide a constant for "none" draw mode.
|
//! OpenGL does not provide a constant for "none" draw mode.
|
||||||
//! So we define our own one that does not conflict with GL constants and utilizes common GL invalid value.
|
//! So we define our own one that does not conflict with GL constants and utilizes common GL invalid value.
|
||||||
|
@@ -593,10 +593,21 @@ namespace OpenGl_Raytrace
|
|||||||
// function : IsRaytracedElement
|
// function : IsRaytracedElement
|
||||||
// purpose : Checks to see if the element contains ray-trace geometry
|
// purpose : Checks to see if the element contains ray-trace geometry
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean IsRaytracedElement (const Handle(OpenGl_Element) theElement)
|
Standard_Boolean IsRaytracedElement (const OpenGl_ElementNode* theNode)
|
||||||
{
|
{
|
||||||
Handle(OpenGl_PrimitiveArray) anArray = Handle(OpenGl_PrimitiveArray)::DownCast (theElement);
|
OpenGl_PrimitiveArray* anArray = dynamic_cast<OpenGl_PrimitiveArray*> (theNode->elem);
|
||||||
return !anArray.IsNull()
|
return anArray != NULL
|
||||||
|
&& anArray->DrawMode() >= GL_TRIANGLES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : IsRaytracedElement
|
||||||
|
// purpose : Checks to see if the element contains ray-trace geometry
|
||||||
|
// =======================================================================
|
||||||
|
Standard_Boolean IsRaytracedElement (const OpenGl_Element* theElement)
|
||||||
|
{
|
||||||
|
const OpenGl_PrimitiveArray* anArray = dynamic_cast<const OpenGl_PrimitiveArray*> (theElement);
|
||||||
|
return anArray != NULL
|
||||||
&& anArray->DrawMode() >= GL_TRIANGLES;
|
&& anArray->DrawMode() >= GL_TRIANGLES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -606,9 +617,9 @@ namespace OpenGl_Raytrace
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean IsRaytracedGroup (const OpenGl_Group* theGroup)
|
Standard_Boolean IsRaytracedGroup (const OpenGl_Group* theGroup)
|
||||||
{
|
{
|
||||||
for (OpenGl_ElementNodes::Iterator anElemIterator (theGroup->GetElements()); anElemIterator.More(); anElemIterator.Next())
|
for (const OpenGl_ElementNode* aNode = theGroup->FirstNode(); aNode != NULL; aNode = aNode->next)
|
||||||
{
|
{
|
||||||
if (IsRaytracedElement (anElemIterator.Value()))
|
if (IsRaytracedElement (aNode))
|
||||||
{
|
{
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
@@ -36,7 +36,10 @@ namespace OpenGl_Raytrace
|
|||||||
Standard_Boolean IsRaytracedGroup (const OpenGl_Group* theGroup);
|
Standard_Boolean IsRaytracedGroup (const OpenGl_Group* theGroup);
|
||||||
|
|
||||||
//! Checks to see if the element contains ray-trace geometry.
|
//! Checks to see if the element contains ray-trace geometry.
|
||||||
Standard_Boolean IsRaytracedElement (const Handle(OpenGl_Element) theElement);
|
Standard_Boolean IsRaytracedElement (const OpenGl_ElementNode* theNode);
|
||||||
|
|
||||||
|
//! Checks to see if the element contains ray-trace geometry.
|
||||||
|
Standard_Boolean IsRaytracedElement (const OpenGl_Element* theElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Stores properties of surface material.
|
//! Stores properties of surface material.
|
||||||
|
@@ -23,20 +23,22 @@
|
|||||||
//! Standard GLSL program combination bits.
|
//! Standard GLSL program combination bits.
|
||||||
enum OpenGl_ProgramOptions
|
enum OpenGl_ProgramOptions
|
||||||
{
|
{
|
||||||
OpenGl_PO_Point = 0x001, //!< point marker
|
OpenGl_PO_Point = 0x0001, //!< point marker
|
||||||
OpenGl_PO_VertColor = 0x002, //!< per-vertex color
|
OpenGl_PO_VertColor = 0x0002, //!< per-vertex color
|
||||||
OpenGl_PO_TextureRGB = 0x004, //!< handle RGB texturing
|
OpenGl_PO_TextureRGB = 0x0004, //!< handle RGB texturing
|
||||||
OpenGl_PO_TextureA = 0x008, //!< handle Alpha texturing
|
OpenGl_PO_TextureA = 0x0008, //!< handle Alpha texturing
|
||||||
OpenGl_PO_TextureEnv = 0x010, //!< handle environment map
|
OpenGl_PO_TextureEnv = 0x0010, //!< handle environment map
|
||||||
OpenGl_PO_StippleLine = 0x020, //!< stipple line
|
OpenGl_PO_StippleLine = 0x0020, //!< stipple line
|
||||||
OpenGl_PO_ClipPlanes1 = 0x040, //!< handle 1 clipping plane
|
OpenGl_PO_ClipPlanes1 = 0x0040, //!< handle 1 clipping plane
|
||||||
OpenGl_PO_ClipPlanes2 = 0x080, //!< handle 2 clipping planes
|
OpenGl_PO_ClipPlanes2 = 0x0080, //!< handle 2 clipping planes
|
||||||
//OpenGl_PO_ClipPlanes3 = OpenGl_PO_ClipPlanes1|OpenGl_PO_ClipPlanes2, //!< handle 3 clipping planes - not implemented
|
OpenGl_PO_ClipPlanesN = OpenGl_PO_ClipPlanes1|OpenGl_PO_ClipPlanes2, //!< handle N clipping planes
|
||||||
OpenGl_PO_ClipPlanesN = 0x100, //!< handle N clipping planes
|
OpenGl_PO_ClipChains = 0x0100, //!< handle chains of clipping planes
|
||||||
OpenGl_PO_ClipChains = 0x200, //!< handle chains of clipping planes
|
OpenGl_PO_MeshEdges = 0x0200, //!< draw mesh edges (wireframe)
|
||||||
OpenGl_PO_AlphaTest = 0x400, //!< discard fragment by alpha test (defined by cutoff value)
|
OpenGl_PO_AlphaTest = 0x0400, //!< discard fragment by alpha test (defined by cutoff value)
|
||||||
OpenGl_PO_WriteOit = 0x800, //!< write coverage buffer for Blended Order-Independent Transparency
|
OpenGl_PO_WriteOit = 0x0800, //!< write coverage buffer for Blended Order-Independent Transparency
|
||||||
OpenGl_PO_NB = 0x1000 //!< overall number of combinations
|
//
|
||||||
|
OpenGl_PO_NB = 0x1000, //!< overall number of combinations
|
||||||
|
OpenGl_PO_NeedsGeomShader = OpenGl_PO_MeshEdges,
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Alias to programs array of predefined length
|
//! Alias to programs array of predefined length
|
||||||
|
@@ -281,6 +281,19 @@ EOL" {"
|
|||||||
EOL" discard;"
|
EOL" discard;"
|
||||||
EOL" }";
|
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)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
|
|
||||||
static const GLfloat THE_DEFAULT_AMBIENT[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
myContext->SetSampleAlphaToCoverage (false);
|
||||||
if (myMaterialState.AlphaCutoff() < ShortRealLast())
|
if (myMaterialState.AlphaCutoff() < ShortRealLast())
|
||||||
{
|
{
|
||||||
glAlphaFunc (GL_GEQUAL, myMaterialState.AlphaCutoff());
|
glAlphaFunc (GL_GEQUAL, myMaterialState.AlphaCutoff());
|
||||||
@@ -1158,6 +1172,7 @@ void OpenGl_ShaderManager::PushMaterialState (const Handle(OpenGl_ShaderProgram)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
myContext->SetSampleAlphaToCoverage (myMaterialState.HasAlphaCutoff());
|
||||||
theProgram->SetUniform (myContext,
|
theProgram->SetUniform (myContext,
|
||||||
theProgram->GetStateLocation (OpenGl_OCCT_ALPHA_CUTOFF),
|
theProgram->GetStateLocation (OpenGl_OCCT_ALPHA_CUTOFF),
|
||||||
myMaterialState.AlphaCutoff());
|
myMaterialState.AlphaCutoff());
|
||||||
@@ -1168,15 +1183,12 @@ void OpenGl_ShaderManager::PushMaterialState (const Handle(OpenGl_ShaderProgram)
|
|||||||
theProgram->GetStateLocation (OpenGl_OCCT_DISTINGUISH_MODE),
|
theProgram->GetStateLocation (OpenGl_OCCT_DISTINGUISH_MODE),
|
||||||
myMaterialState.ToDistinguish() ? 1 : 0);
|
myMaterialState.ToDistinguish() ? 1 : 0);
|
||||||
|
|
||||||
const GLint aLocFront = theProgram->GetStateLocation (OpenGl_OCCT_FRONT_MATERIAL);
|
if (const OpenGl_ShaderUniformLocation aLocFront = theProgram->GetStateLocation (OpenGl_OCCT_FRONT_MATERIAL))
|
||||||
if (aLocFront != OpenGl_ShaderProgram::INVALID_LOCATION)
|
|
||||||
{
|
{
|
||||||
theProgram->SetUniform (myContext, aLocFront, OpenGl_Material::NbOfVec4(),
|
theProgram->SetUniform (myContext, aLocFront, OpenGl_Material::NbOfVec4(),
|
||||||
aFrontMat.Packed());
|
aFrontMat.Packed());
|
||||||
}
|
}
|
||||||
|
if (const OpenGl_ShaderUniformLocation aLocBack = theProgram->GetStateLocation (OpenGl_OCCT_BACK_MATERIAL))
|
||||||
const GLint aLocBack = theProgram->GetStateLocation (OpenGl_OCCT_BACK_MATERIAL);
|
|
||||||
if (aLocBack != OpenGl_ShaderProgram::INVALID_LOCATION)
|
|
||||||
{
|
{
|
||||||
theProgram->SetUniform (myContext, aLocBack, OpenGl_Material::NbOfVec4(),
|
theProgram->SetUniform (myContext, aLocBack, OpenGl_Material::NbOfVec4(),
|
||||||
aBackMat.Packed());
|
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
|
// function : PushState
|
||||||
// purpose : Pushes state of OCCT graphics parameters to the program
|
// purpose : Pushes state of OCCT graphics parameters to the program
|
||||||
@@ -1264,19 +1315,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFont()
|
|||||||
EOL"}";
|
EOL"}";
|
||||||
|
|
||||||
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
defaultGlslVersion (aProgramSrc, 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
|
|
||||||
aProgramSrc->SetNbLightsMax (0);
|
aProgramSrc->SetNbLightsMax (0);
|
||||||
aProgramSrc->SetNbClipPlanesMax (0);
|
aProgramSrc->SetNbClipPlanesMax (0);
|
||||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
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
|
// function : prepareStdProgramUnlit
|
||||||
// purpose :
|
// purpose :
|
||||||
@@ -1490,11 +1687,12 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
|
|||||||
const Standard_Integer theBits)
|
const Standard_Integer theBits)
|
||||||
{
|
{
|
||||||
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
||||||
TCollection_AsciiString aSrcVert, aSrcVertExtraMain, aSrcVertExtraFunc, aSrcGetAlpha;
|
TCollection_AsciiString aSrcVert, aSrcVertExtraMain, aSrcVertExtraFunc, aSrcGetAlpha, aSrcVertEndMain;
|
||||||
TCollection_AsciiString aSrcFrag, aSrcFragExtraMain, aSrcFragWriteOit;
|
TCollection_AsciiString aSrcFrag, aSrcFragExtraMain;
|
||||||
TCollection_AsciiString aSrcFragGetColor = EOL"vec4 getColor(void) { return occColor; }";
|
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;
|
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
|
||||||
|
|
||||||
if ((theBits & OpenGl_PO_Point) != 0)
|
if ((theBits & OpenGl_PO_Point) != 0)
|
||||||
{
|
{
|
||||||
#if defined(GL_ES_VERSION_2_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" PositionWorld = occModelWorldMatrix * occVertex;"
|
||||||
EOL" Position = occWorldViewMatrix * PositionWorld;";
|
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;
|
aNbClipPlanes = 1;
|
||||||
aSrcFragExtraMain += THE_FRAG_CLIP_PLANES_1;
|
aSrcFragExtraMain += THE_FRAG_CLIP_PLANES_1;
|
||||||
@@ -1590,53 +1795,20 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
|
|||||||
? THE_FRAG_CLIP_CHAINS_2
|
? THE_FRAG_CLIP_CHAINS_2
|
||||||
: THE_FRAG_CLIP_PLANES_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)
|
if ((theBits & OpenGl_PO_WriteOit) != 0)
|
||||||
{
|
{
|
||||||
aProgramSrc->SetNbFragmentOutputs (2);
|
aProgramSrc->SetNbFragmentOutputs (2);
|
||||||
aProgramSrc->SetWeightOitOutput (true);
|
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)
|
if ((theBits & OpenGl_PO_StippleLine) != 0)
|
||||||
{
|
{
|
||||||
bool hasGlslBitOps = false;
|
const Standard_Integer aBits = defaultGlslVersion (aProgramSrc, theBits);
|
||||||
#if defined(GL_ES_VERSION_2_0)
|
if ((aBits & OpenGl_PO_StippleLine) != 0)
|
||||||
if (myContext->IsGlGreaterEqual (3, 0))
|
|
||||||
{
|
{
|
||||||
aProgramSrc->SetHeader ("#version 300 es");
|
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("int uPattern", Graphic3d_TOS_FRAGMENT));
|
||||||
hasGlslBitOps = true;
|
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("float uFactor", Graphic3d_TOS_FRAGMENT));
|
||||||
}
|
|
||||||
#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)
|
|
||||||
{
|
|
||||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("int uPattern;", Graphic3d_TOS_FRAGMENT));
|
|
||||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("float uFactor;", Graphic3d_TOS_FRAGMENT));
|
|
||||||
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec2 ScreenSpaceCoord", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
|
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec2 ScreenSpaceCoord", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
|
||||||
aSrcVertEndMain =
|
aSrcVertEndMain =
|
||||||
EOL" ScreenSpaceCoord = gl_Position.xy / gl_Position.w;";
|
EOL" ScreenSpaceCoord = gl_Position.xy / gl_Position.w;";
|
||||||
@@ -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" float aRotatePoint = gl_FragCoord.x * sin (anAngle) + gl_FragCoord.y * cos (anAngle);"
|
||||||
EOL" uint aBit = uint (floor (aRotatePoint / uFactor + 0.5)) & 15U;"
|
EOL" uint aBit = uint (floor (aRotatePoint / uFactor + 0.5)) & 15U;"
|
||||||
EOL" if ((uint (uPattern) & (1U << aBit)) == 0U) discard;"
|
EOL" if ((uint (uPattern) & (1U << aBit)) == 0U) discard;"
|
||||||
EOL" vec4 aColor = getColor();"
|
EOL" vec4 aColor = getFinalColor();"
|
||||||
EOL" if (aColor.a <= 0.1) discard;"
|
EOL" if (aColor.a <= 0.1) discard;"
|
||||||
EOL" occSetFragColor (aColor);";
|
EOL" occSetFragColor (aColor);";
|
||||||
}
|
}
|
||||||
@@ -1664,6 +1836,11 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
|
|||||||
+ aSrcVertEndMain
|
+ aSrcVertEndMain
|
||||||
+ EOL"}";
|
+ EOL"}";
|
||||||
|
|
||||||
|
TCollection_AsciiString aSrcGeom = prepareGeomMainSrc (aUniforms, aStageInOuts, theBits);
|
||||||
|
aSrcFragGetColor += (theBits & OpenGl_PO_MeshEdges) != 0
|
||||||
|
? THE_FRAG_WIREFRAME_COLOR
|
||||||
|
: EOL"#define getFinalColor getColor";
|
||||||
|
|
||||||
aSrcFrag =
|
aSrcFrag =
|
||||||
aSrcFragGetColor
|
aSrcFragGetColor
|
||||||
+ aSrcGetAlpha
|
+ aSrcGetAlpha
|
||||||
@@ -1671,28 +1848,16 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
|
|||||||
EOL"{"
|
EOL"{"
|
||||||
+ aSrcFragExtraMain
|
+ aSrcFragExtraMain
|
||||||
+ aSrcFragMainGetColor
|
+ aSrcFragMainGetColor
|
||||||
+ aSrcFragWriteOit
|
|
||||||
+ EOL"}";
|
+ EOL"}";
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
defaultGlslVersion (aProgramSrc, theBits);
|
||||||
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
|
|
||||||
aProgramSrc->SetNbLightsMax (0);
|
aProgramSrc->SetNbLightsMax (0);
|
||||||
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
|
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
|
||||||
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
|
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
|
||||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
const Standard_Integer aNbGeomInputVerts = !aSrcGeom.IsEmpty() ? 3 : 0;
|
||||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
|
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;
|
TCollection_AsciiString aKey;
|
||||||
if (!Create (aProgramSrc, aKey, theProgram))
|
if (!Create (aProgramSrc, aKey, theProgram))
|
||||||
{
|
{
|
||||||
@@ -1881,7 +2046,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
|
|||||||
{
|
{
|
||||||
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
||||||
TCollection_AsciiString aSrcVert, aSrcVertColor, aSrcVertExtraMain;
|
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; }";
|
TCollection_AsciiString aSrcFragGetColor = EOL"vec4 getColor(void) { return gl_FrontFacing ? FrontColor : BackColor; }";
|
||||||
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
|
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
|
||||||
|
|
||||||
@@ -1934,7 +2099,14 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
|
|||||||
EOL" PositionWorld = aPositionWorld;"
|
EOL" PositionWorld = aPositionWorld;"
|
||||||
EOL" Position = aPosition;";
|
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;
|
aNbClipPlanes = 1;
|
||||||
aSrcFragExtraMain += THE_FRAG_CLIP_PLANES_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_CHAINS_2
|
||||||
: THE_FRAG_CLIP_PLANES_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)
|
if ((theBits & OpenGl_PO_WriteOit) != 0)
|
||||||
{
|
{
|
||||||
aProgramSrc->SetNbFragmentOutputs (2);
|
aProgramSrc->SetNbFragmentOutputs (2);
|
||||||
aProgramSrc->SetWeightOitOutput (true);
|
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));
|
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" gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex;"
|
||||||
EOL"}";
|
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()
|
aSrcFrag = TCollection_AsciiString()
|
||||||
+ aSrcFragGetColor
|
+ aSrcFragGetColor
|
||||||
+ EOL"void main()"
|
+ EOL"void main()"
|
||||||
EOL"{"
|
EOL"{"
|
||||||
+ aSrcFragExtraMain
|
+ aSrcFragExtraMain
|
||||||
+ EOL" occSetFragColor (getColor());"
|
+ EOL" occSetFragColor (getFinalColor());"
|
||||||
+ aSrcFragWriteOit
|
|
||||||
+ EOL"}";
|
+ EOL"}";
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
defaultGlslVersion (aProgramSrc, theBits);
|
||||||
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
|
|
||||||
aProgramSrc->SetNbLightsMax (aNbLights);
|
aProgramSrc->SetNbLightsMax (aNbLights);
|
||||||
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
|
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
|
||||||
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
|
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
|
||||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
const Standard_Integer aNbGeomInputVerts = !aSrcGeom.IsEmpty() ? 3 : 0;
|
||||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
|
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;
|
TCollection_AsciiString aKey;
|
||||||
if (!Create (aProgramSrc, aKey, theProgram))
|
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");
|
"Warning: applied workaround for flat shading normal computation using dFdx/dFdy on Adreno");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
||||||
TCollection_AsciiString aSrcVert, aSrcVertExtraFunc, aSrcVertExtraMain;
|
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 "; }";
|
TCollection_AsciiString aSrcFragGetColor = EOL"vec4 getColor(void) { return " thePhongCompLight "; }";
|
||||||
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
|
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
|
||||||
if ((theBits & OpenGl_PO_Point) != 0)
|
if ((theBits & OpenGl_PO_Point) != 0)
|
||||||
@@ -2103,7 +2255,14 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
|
|||||||
int aNbClipPlanes = 0;
|
int aNbClipPlanes = 0;
|
||||||
if ((theBits & OpenGl_PO_ClipPlanesN) != 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;
|
aNbClipPlanes = 1;
|
||||||
aSrcFragExtraMain += THE_FRAG_CLIP_PLANES_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_CHAINS_2
|
||||||
: THE_FRAG_CLIP_PLANES_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)
|
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" gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex;"
|
||||||
EOL"}";
|
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;
|
Standard_Integer aNbLights = 0;
|
||||||
const TCollection_AsciiString aLights = stdComputeLighting (aNbLights, (theBits & OpenGl_PO_VertColor) != 0);
|
const TCollection_AsciiString aLights = stdComputeLighting (aNbLights, (theBits & OpenGl_PO_VertColor) != 0);
|
||||||
aSrcFrag = TCollection_AsciiString()
|
aSrcFrag = TCollection_AsciiString()
|
||||||
@@ -2170,39 +2327,17 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
|
|||||||
EOL"void main()"
|
EOL"void main()"
|
||||||
EOL"{"
|
EOL"{"
|
||||||
+ aSrcFragExtraMain
|
+ aSrcFragExtraMain
|
||||||
+ EOL" occSetFragColor (getColor());"
|
+ EOL" occSetFragColor (getFinalColor());"
|
||||||
+ aSrcFragWriteOit
|
|
||||||
+ EOL"}";
|
+ EOL"}";
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
defaultGlslVersion (aProgramSrc, theBits, isFlatNormal);
|
||||||
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
|
|
||||||
aProgramSrc->SetNbLightsMax (aNbLights);
|
aProgramSrc->SetNbLightsMax (aNbLights);
|
||||||
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
|
aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
|
||||||
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
|
aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
|
||||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
const Standard_Integer aNbGeomInputVerts = !aSrcGeom.IsEmpty() ? 3 : 0;
|
||||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
|
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;
|
TCollection_AsciiString aKey;
|
||||||
if (!Create (aProgramSrc, aKey, theProgram))
|
if (!Create (aProgramSrc, aKey, theProgram))
|
||||||
{
|
{
|
||||||
@@ -2379,20 +2514,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramStereo (Handle(OpenGl_Sh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
defaultGlslVersion (aProgramSrc, 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
|
|
||||||
|
|
||||||
aProgramSrc->SetNbLightsMax (0);
|
aProgramSrc->SetNbLightsMax (0);
|
||||||
aProgramSrc->SetNbClipPlanesMax (0);
|
aProgramSrc->SetNbClipPlanesMax (0);
|
||||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
||||||
@@ -2437,20 +2559,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramBoundBox()
|
|||||||
EOL" occSetFragColor (occColor);"
|
EOL" occSetFragColor (occColor);"
|
||||||
EOL"}";
|
EOL"}";
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
defaultGlslVersion (aProgramSrc, 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
|
|
||||||
|
|
||||||
aProgramSrc->SetNbLightsMax (0);
|
aProgramSrc->SetNbLightsMax (0);
|
||||||
aProgramSrc->SetNbClipPlanesMax (0);
|
aProgramSrc->SetNbClipPlanesMax (0);
|
||||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
||||||
|
@@ -84,10 +84,23 @@ public:
|
|||||||
|
|
||||||
//! Bind program for filled primitives rendering
|
//! Bind program for filled primitives rendering
|
||||||
Standard_Boolean BindFaceProgram (const Handle(OpenGl_TextureSet)& theTextures,
|
Standard_Boolean BindFaceProgram (const Handle(OpenGl_TextureSet)& theTextures,
|
||||||
const Graphic3d_TypeOfShadingModel theShadingModel,
|
Graphic3d_TypeOfShadingModel theShadingModel,
|
||||||
const Graphic3d_AlphaMode theAlphaMode,
|
Graphic3d_AlphaMode theAlphaMode,
|
||||||
const Standard_Boolean theHasVertColor,
|
Standard_Boolean theHasVertColor,
|
||||||
const Standard_Boolean theEnableEnvMap,
|
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)
|
const Handle(OpenGl_ShaderProgram)& theCustomProgram)
|
||||||
{
|
{
|
||||||
if (!theCustomProgram.IsNull()
|
if (!theCustomProgram.IsNull()
|
||||||
@@ -100,7 +113,7 @@ public:
|
|||||||
&& (theTextures.IsNull() || theTextures->IsModulate())
|
&& (theTextures.IsNull() || theTextures->IsModulate())
|
||||||
? theShadingModel
|
? theShadingModel
|
||||||
: Graphic3d_TOSM_UNLIT;
|
: 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);
|
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (aShadeModelOnFace, aBits);
|
||||||
return bindProgramWithState (aProgram);
|
return bindProgramWithState (aProgram);
|
||||||
}
|
}
|
||||||
@@ -119,7 +132,7 @@ public:
|
|||||||
return bindProgramWithState (theCustomProgram);
|
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)
|
if (theLineType != Aspect_TOL_SOLID)
|
||||||
{
|
{
|
||||||
aBits |= OpenGl_PO_StippleLine;
|
aBits |= OpenGl_PO_StippleLine;
|
||||||
@@ -142,7 +155,7 @@ public:
|
|||||||
return bindProgramWithState (theCustomProgram);
|
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);
|
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theShadingModel, aBits);
|
||||||
return bindProgramWithState (aProgram);
|
return bindProgramWithState (aProgram);
|
||||||
}
|
}
|
||||||
@@ -301,6 +314,12 @@ public:
|
|||||||
//! Pushes current state of material to specified program.
|
//! Pushes current state of material to specified program.
|
||||||
void PushMaterialState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
|
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:
|
public:
|
||||||
|
|
||||||
//! Returns state of OIT uniforms.
|
//! Returns state of OIT uniforms.
|
||||||
@@ -411,12 +430,43 @@ public:
|
|||||||
|
|
||||||
protected:
|
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.
|
//! Define program bits.
|
||||||
Standard_Integer getProgramBits (const Handle(OpenGl_TextureSet)& theTextures,
|
Standard_Integer getProgramBits (const Handle(OpenGl_TextureSet)& theTextures,
|
||||||
Graphic3d_AlphaMode theAlphaMode,
|
Graphic3d_AlphaMode theAlphaMode,
|
||||||
|
Aspect_InteriorStyle theInteriorStyle,
|
||||||
Standard_Boolean theHasVertColor,
|
Standard_Boolean theHasVertColor,
|
||||||
Standard_Boolean theEnableEnvMap)
|
Standard_Boolean theEnableEnvMap,
|
||||||
|
Standard_Boolean theEnableMeshEdges) const
|
||||||
{
|
{
|
||||||
Standard_Integer aBits = 0;
|
Standard_Integer aBits = 0;
|
||||||
if (theAlphaMode == Graphic3d_AlphaMode_Mask)
|
if (theAlphaMode == Graphic3d_AlphaMode_Mask)
|
||||||
@@ -424,22 +474,14 @@ protected:
|
|||||||
aBits |= OpenGl_PO_AlphaTest;
|
aBits |= OpenGl_PO_AlphaTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Standard_Integer aNbPlanes = myContext->Clipping().NbClippingOrCappingOn();
|
aBits |= getClipPlaneBits();
|
||||||
if (aNbPlanes > 0)
|
if (theEnableMeshEdges
|
||||||
|
&& myContext->hasGeometryStage != OpenGl_FeatureNotAvailable)
|
||||||
{
|
{
|
||||||
aBits |= OpenGl_PO_ClipPlanesN;
|
aBits |= OpenGl_PO_MeshEdges;
|
||||||
if (myContext->Clipping().HasClippingChains())
|
if (theInteriorStyle == Aspect_IS_HOLLOW)
|
||||||
{
|
{
|
||||||
aBits |= OpenGl_PO_ClipChains;
|
aBits |= OpenGl_PO_AlphaTest;
|
||||||
}
|
|
||||||
|
|
||||||
if (aNbPlanes == 1)
|
|
||||||
{
|
|
||||||
aBits |= OpenGl_PO_ClipPlanes1;
|
|
||||||
}
|
|
||||||
else if (aNbPlanes == 2)
|
|
||||||
{
|
|
||||||
aBits |= OpenGl_PO_ClipPlanes2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,7 +496,8 @@ protected:
|
|||||||
{
|
{
|
||||||
aBits |= theTextures->First()->IsAlpha() ? OpenGl_PO_TextureA : OpenGl_PO_TextureRGB;
|
aBits |= theTextures->First()->IsAlpha() ? OpenGl_PO_TextureA : OpenGl_PO_TextureRGB;
|
||||||
}
|
}
|
||||||
if (theHasVertColor)
|
if (theHasVertColor
|
||||||
|
&& theInteriorStyle != Aspect_IS_HIDDENLINE)
|
||||||
{
|
{
|
||||||
aBits |= OpenGl_PO_VertColor;
|
aBits |= OpenGl_PO_VertColor;
|
||||||
}
|
}
|
||||||
@@ -555,6 +598,16 @@ protected:
|
|||||||
//! Prepare standard GLSL program for bounding box.
|
//! Prepare standard GLSL program for bounding box.
|
||||||
Standard_EXPORT Standard_Boolean prepareStdProgramBoundBox();
|
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:
|
protected:
|
||||||
|
|
||||||
//! Packed properties of light source
|
//! Packed properties of light source
|
||||||
|
@@ -14,11 +14,13 @@
|
|||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
#include <Graphic3d_ShaderObject.hxx>
|
#include <Graphic3d_ShaderObject.hxx>
|
||||||
|
|
||||||
#include <OpenGl_Context.hxx>
|
#include <OpenGl_Context.hxx>
|
||||||
#include <OpenGl_ShaderObject.hxx>
|
#include <OpenGl_ShaderObject.hxx>
|
||||||
#include <OSD_Path.hxx>
|
#include <OSD_Path.hxx>
|
||||||
#include <Standard_Assert.hxx>
|
#include <Standard_Assert.hxx>
|
||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
|
#include <TCollection_ExtendedString.hxx>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <malloc.h> // for alloca()
|
#include <malloc.h> // for alloca()
|
||||||
@@ -26,6 +28,24 @@
|
|||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_ShaderObject,OpenGl_Resource)
|
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_ShaderObject,OpenGl_Resource)
|
||||||
|
|
||||||
|
//! Puts line numbers to the output of GLSL program source code.
|
||||||
|
static TCollection_AsciiString putLineNumbers (const TCollection_AsciiString& theSource)
|
||||||
|
{
|
||||||
|
std::stringstream aStream;
|
||||||
|
theSource.Print (aStream);
|
||||||
|
std::string aLine;
|
||||||
|
Standard_Integer aLineNumber = 1;
|
||||||
|
TCollection_AsciiString aResultSource;
|
||||||
|
while (std::getline (aStream, aLine))
|
||||||
|
{
|
||||||
|
TCollection_AsciiString anAsciiString = TCollection_AsciiString (aLine.c_str());
|
||||||
|
anAsciiString.Prepend (TCollection_AsciiString ("\n") + TCollection_AsciiString (aLineNumber) + ": ");
|
||||||
|
aResultSource += anAsciiString;
|
||||||
|
aLineNumber++;
|
||||||
|
}
|
||||||
|
return aResultSource;
|
||||||
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : CreateFromSource
|
// function : CreateFromSource
|
||||||
// purpose :
|
// purpose :
|
||||||
@@ -38,6 +58,11 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
|
|||||||
const TCollection_AsciiString& theOutName,
|
const TCollection_AsciiString& theOutName,
|
||||||
Standard_Integer theNbGeomInputVerts)
|
Standard_Integer theNbGeomInputVerts)
|
||||||
{
|
{
|
||||||
|
if (theSource.IsEmpty())
|
||||||
|
{
|
||||||
|
return Handle(Graphic3d_ShaderObject)();
|
||||||
|
}
|
||||||
|
|
||||||
TCollection_AsciiString aSrcUniforms, aSrcInOuts, aSrcInStructs, aSrcOutStructs;
|
TCollection_AsciiString aSrcUniforms, aSrcInOuts, aSrcInStructs, aSrcOutStructs;
|
||||||
for (ShaderVariableList::Iterator anUniformIter (theUniforms); anUniformIter.More(); anUniformIter.Next())
|
for (ShaderVariableList::Iterator anUniformIter (theUniforms); anUniformIter.More(); anUniformIter.Next())
|
||||||
{
|
{
|
||||||
@@ -70,12 +95,15 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
|
|||||||
const Standard_Boolean hasGeomStage = theNbGeomInputVerts > 0
|
const Standard_Boolean hasGeomStage = theNbGeomInputVerts > 0
|
||||||
&& aStageLower < Graphic3d_TOS_GEOMETRY
|
&& aStageLower < Graphic3d_TOS_GEOMETRY
|
||||||
&& aStageUpper >= Graphic3d_TOS_GEOMETRY;
|
&& aStageUpper >= Graphic3d_TOS_GEOMETRY;
|
||||||
|
const Standard_Boolean isAllStagesVar = aStageLower == Graphic3d_TOS_VERTEX
|
||||||
|
&& aStageUpper == Graphic3d_TOS_FRAGMENT;
|
||||||
if (hasGeomStage
|
if (hasGeomStage
|
||||||
|| !theInName.IsEmpty()
|
|| !theInName.IsEmpty()
|
||||||
|| !theOutName.IsEmpty())
|
|| !theOutName.IsEmpty())
|
||||||
{
|
{
|
||||||
if (aSrcInStructs.IsEmpty()
|
if (aSrcInStructs.IsEmpty()
|
||||||
&& aSrcOutStructs.IsEmpty())
|
&& aSrcOutStructs.IsEmpty()
|
||||||
|
&& isAllStagesVar)
|
||||||
{
|
{
|
||||||
if (theType == aStageLower)
|
if (theType == aStageLower)
|
||||||
{
|
{
|
||||||
@@ -93,8 +121,9 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aSrcInStructs.IsEmpty()
|
if (isAllStagesVar
|
||||||
|| !aSrcOutStructs.IsEmpty())
|
&& (!aSrcInStructs.IsEmpty()
|
||||||
|
|| !aSrcOutStructs.IsEmpty()))
|
||||||
{
|
{
|
||||||
if (!aSrcInStructs.IsEmpty())
|
if (!aSrcInStructs.IsEmpty())
|
||||||
{
|
{
|
||||||
@@ -118,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()
|
if (!aSrcInStructs.IsEmpty()
|
||||||
&& theType == Graphic3d_TOS_GEOMETRY)
|
&& theType == Graphic3d_TOS_GEOMETRY)
|
||||||
{
|
{
|
||||||
@@ -133,10 +168,10 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
|
|||||||
}
|
}
|
||||||
aSrcInStructs += ";";
|
aSrcInStructs += ";";
|
||||||
}
|
}
|
||||||
else if (!aSrcOutStructs.IsEmpty())
|
if (!aSrcOutStructs.IsEmpty())
|
||||||
{
|
{
|
||||||
aSrcOutStructs += "\n}";
|
aSrcOutStructs += "\n}";
|
||||||
if (!theInName.IsEmpty())
|
if (!theOutName.IsEmpty())
|
||||||
{
|
{
|
||||||
aSrcOutStructs += " ";
|
aSrcOutStructs += " ";
|
||||||
aSrcOutStructs += theOutName;
|
aSrcOutStructs += theOutName;
|
||||||
@@ -168,6 +203,63 @@ OpenGl_ShaderObject::~OpenGl_ShaderObject()
|
|||||||
Release (NULL);
|
Release (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : LoadAndCompile
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
Standard_Boolean OpenGl_ShaderObject::LoadAndCompile (const Handle(OpenGl_Context)& theCtx,
|
||||||
|
const TCollection_AsciiString& theSource,
|
||||||
|
bool theIsVerbose,
|
||||||
|
bool theToPrintSource)
|
||||||
|
{
|
||||||
|
if (!theIsVerbose)
|
||||||
|
{
|
||||||
|
return LoadSource (theCtx, theSource)
|
||||||
|
&& Compile (theCtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!LoadSource (theCtx, theSource))
|
||||||
|
{
|
||||||
|
if (theToPrintSource)
|
||||||
|
{
|
||||||
|
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, theSource);
|
||||||
|
}
|
||||||
|
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, "Error! Failed to set shader source");
|
||||||
|
Release (theCtx.operator->());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Compile (theCtx))
|
||||||
|
{
|
||||||
|
if (theToPrintSource)
|
||||||
|
{
|
||||||
|
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, putLineNumbers (theSource));
|
||||||
|
}
|
||||||
|
TCollection_AsciiString aLog;
|
||||||
|
FetchInfoLog (theCtx, aLog);
|
||||||
|
if (aLog.IsEmpty())
|
||||||
|
{
|
||||||
|
aLog = "Compilation log is empty.";
|
||||||
|
}
|
||||||
|
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||||
|
TCollection_AsciiString ("Failed to compile shader object. Compilation log:\n") + aLog);
|
||||||
|
Release (theCtx.operator->());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (theCtx->caps->glslWarnings)
|
||||||
|
{
|
||||||
|
TCollection_AsciiString aLog;
|
||||||
|
FetchInfoLog (theCtx, aLog);
|
||||||
|
if (!aLog.IsEmpty()
|
||||||
|
&& !aLog.IsEqual ("No errors.\n"))
|
||||||
|
{
|
||||||
|
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_LOW,
|
||||||
|
TCollection_AsciiString ("Shader compilation log:\n") + aLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : LoadSource
|
// function : LoadSource
|
||||||
// purpose : Loads shader source code
|
// purpose : Loads shader source code
|
||||||
|
@@ -85,6 +85,16 @@ public:
|
|||||||
//! Compiles the shader object.
|
//! Compiles the shader object.
|
||||||
Standard_EXPORT Standard_Boolean Compile (const Handle(OpenGl_Context)& theCtx);
|
Standard_EXPORT Standard_Boolean Compile (const Handle(OpenGl_Context)& theCtx);
|
||||||
|
|
||||||
|
//! Wrapper for compiling shader object with verbose printing on error.
|
||||||
|
//! @param theCtx bound OpenGL context
|
||||||
|
//! @param theSource source code to load
|
||||||
|
//! @param theIsVerbose flag to print log on error
|
||||||
|
//! @param theToPrintSource flag to print source code on error
|
||||||
|
Standard_EXPORT Standard_Boolean LoadAndCompile (const Handle(OpenGl_Context)& theCtx,
|
||||||
|
const TCollection_AsciiString& theSource,
|
||||||
|
bool theIsVerbose = true,
|
||||||
|
bool theToPrintSource = true);
|
||||||
|
|
||||||
//! Fetches information log of the last compile operation.
|
//! Fetches information log of the last compile operation.
|
||||||
Standard_EXPORT Standard_Boolean FetchInfoLog (const Handle(OpenGl_Context)& theCtx,
|
Standard_EXPORT Standard_Boolean FetchInfoLog (const Handle(OpenGl_Context)& theCtx,
|
||||||
TCollection_AsciiString& theLog);
|
TCollection_AsciiString& theLog);
|
||||||
|
@@ -75,7 +75,13 @@ Standard_CString OpenGl_ShaderProgram::PredefinedKeywords[] =
|
|||||||
"occOitDepthFactor", // OpenGl_OCCT_OIT_DEPTH_FACTOR
|
"occOitDepthFactor", // OpenGl_OCCT_OIT_DEPTH_FACTOR
|
||||||
|
|
||||||
"occTexTrsf2d", // OpenGl_OCCT_TEXTURE_TRSF2D
|
"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
|
namespace
|
||||||
@@ -159,28 +165,6 @@ OpenGl_ShaderProgram::OpenGl_ShaderProgram (const Handle(Graphic3d_ShaderProgram
|
|||||||
myHasTessShader (false)
|
myHasTessShader (false)
|
||||||
{
|
{
|
||||||
memset (myCurrentState, 0, sizeof (myCurrentState));
|
memset (myCurrentState, 0, sizeof (myCurrentState));
|
||||||
for (GLint aVar = 0; aVar < OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES; ++aVar)
|
|
||||||
{
|
|
||||||
myStateLocations[aVar] = INVALID_LOCATION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Puts line numbers to the output of GLSL program source code.
|
|
||||||
static TCollection_AsciiString putLineNumbers (const TCollection_AsciiString& theSource)
|
|
||||||
{
|
|
||||||
std::stringstream aStream;
|
|
||||||
theSource.Print (aStream);
|
|
||||||
std::string aLine;
|
|
||||||
Standard_Integer aLineNumber = 1;
|
|
||||||
TCollection_AsciiString aResultSource;
|
|
||||||
while (std::getline (aStream, aLine))
|
|
||||||
{
|
|
||||||
TCollection_AsciiString anAsciiString = TCollection_AsciiString (aLine.c_str());
|
|
||||||
anAsciiString.Prepend (TCollection_AsciiString ("\n") + TCollection_AsciiString (aLineNumber) + ": ");
|
|
||||||
aResultSource += anAsciiString;
|
|
||||||
aLineNumber++;
|
|
||||||
}
|
|
||||||
return aResultSource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -209,13 +193,12 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
|||||||
|
|
||||||
// detect the minimum GLSL version required for defined Shader Objects
|
// detect the minimum GLSL version required for defined Shader Objects
|
||||||
#if defined(GL_ES_VERSION_2_0)
|
#if defined(GL_ES_VERSION_2_0)
|
||||||
if (myHasTessShader
|
if (myHasTessShader)
|
||||||
|| (aShaderMask & Graphic3d_TOS_GEOMETRY) != 0)
|
|
||||||
{
|
{
|
||||||
if (!theCtx->IsGlGreaterEqual (3, 2))
|
if (!theCtx->IsGlGreaterEqual (3, 2))
|
||||||
{
|
{
|
||||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
else if (aHeaderVer.IsEmpty())
|
else if (aHeaderVer.IsEmpty())
|
||||||
@@ -223,6 +206,34 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
|||||||
aHeaderVer = "#version 320 es";
|
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)
|
else if ((aShaderMask & Graphic3d_TOS_COMPUTE) != 0)
|
||||||
{
|
{
|
||||||
if (!theCtx->IsGlGreaterEqual (3, 1))
|
if (!theCtx->IsGlGreaterEqual (3, 1))
|
||||||
@@ -349,6 +360,13 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
|||||||
}
|
}
|
||||||
#endif
|
#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;
|
TCollection_AsciiString aPrecisionHeader;
|
||||||
if (anIter.Value()->Type() == Graphic3d_TOS_FRAGMENT)
|
if (anIter.Value()->Type() == Graphic3d_TOS_FRAGMENT)
|
||||||
@@ -389,40 +407,11 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
|||||||
+ Shaders_Declarations_glsl // common declarations (global constants and Vertex Shader inputs)
|
+ Shaders_Declarations_glsl // common declarations (global constants and Vertex Shader inputs)
|
||||||
+ Shaders_DeclarationsImpl_glsl
|
+ Shaders_DeclarationsImpl_glsl
|
||||||
+ anIter.Value()->Source(); // the source code itself (defining main() function)
|
+ anIter.Value()->Source(); // the source code itself (defining main() function)
|
||||||
if (!aShader->LoadSource (theCtx, aSource))
|
if (!aShader->LoadAndCompile (theCtx, aSource))
|
||||||
{
|
{
|
||||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aSource);
|
|
||||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, "Error! Failed to set shader source");
|
|
||||||
aShader->Release (theCtx.operator->());
|
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aShader->Compile (theCtx))
|
|
||||||
{
|
|
||||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, putLineNumbers (aSource));
|
|
||||||
TCollection_AsciiString aLog;
|
|
||||||
aShader->FetchInfoLog (theCtx, aLog);
|
|
||||||
if (aLog.IsEmpty())
|
|
||||||
{
|
|
||||||
aLog = "Compilation log is empty.";
|
|
||||||
}
|
|
||||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
|
||||||
TCollection_ExtendedString ("Failed to compile shader object. Compilation log:\n") + aLog);
|
|
||||||
aShader->Release (theCtx.operator->());
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
else if (theCtx->caps->glslWarnings)
|
|
||||||
{
|
|
||||||
TCollection_AsciiString aLog;
|
|
||||||
aShader->FetchInfoLog (theCtx, aLog);
|
|
||||||
if (!aLog.IsEmpty()
|
|
||||||
&& !aLog.IsEqual ("No errors.\n"))
|
|
||||||
{
|
|
||||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_LOW,
|
|
||||||
TCollection_ExtendedString ("Shader compilation log:\n") + aLog);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theCtx->caps->glslDumpLevel)
|
if (theCtx->caps->glslDumpLevel)
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aShaderTypeMsg;
|
TCollection_AsciiString aShaderTypeMsg;
|
||||||
@@ -475,44 +464,19 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
|||||||
|
|
||||||
if (!Link (theCtx))
|
if (!Link (theCtx))
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aLog;
|
|
||||||
FetchInfoLog (theCtx, aLog);
|
|
||||||
if (aLog.IsEmpty())
|
|
||||||
{
|
|
||||||
aLog = "Linker log is empty.";
|
|
||||||
}
|
|
||||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
|
||||||
TCollection_ExtendedString ("Failed to link program object! Linker log:\n") + aLog);
|
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
else if (theCtx->caps->glslWarnings)
|
|
||||||
{
|
|
||||||
TCollection_AsciiString aLog;
|
|
||||||
FetchInfoLog (theCtx, aLog);
|
|
||||||
if (!aLog.IsEmpty()
|
|
||||||
&& !aLog.IsEqual ("No errors.\n"))
|
|
||||||
{
|
|
||||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_LOW,
|
|
||||||
TCollection_ExtendedString ("GLSL linker log:\n") + aLog);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set uniform defaults
|
// set uniform defaults
|
||||||
const Handle(OpenGl_ShaderProgram)& anOldProgram = theCtx->ActiveProgram();
|
const Handle(OpenGl_ShaderProgram)& anOldProgram = theCtx->ActiveProgram();
|
||||||
theCtx->core20fwd->glUseProgram (myProgramID);
|
theCtx->core20fwd->glUseProgram (myProgramID);
|
||||||
|
if (const OpenGl_ShaderUniformLocation aLocTexEnable = GetStateLocation (OpenGl_OCCT_TEXTURE_ENABLE))
|
||||||
{
|
{
|
||||||
const GLint aLocTexEnable = GetStateLocation (OpenGl_OCCT_TEXTURE_ENABLE);
|
SetUniform (theCtx, aLocTexEnable, 0); // Off
|
||||||
if (aLocTexEnable != INVALID_LOCATION)
|
|
||||||
{
|
|
||||||
SetUniform (theCtx, aLocTexEnable, 0); // Off
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (const OpenGl_ShaderUniformLocation aLocSampler = GetUniformLocation (theCtx, "occActiveSampler"))
|
||||||
{
|
{
|
||||||
const GLint aLocSampler = GetUniformLocation (theCtx, "occActiveSampler");
|
SetUniform (theCtx, aLocSampler, GLint(Graphic3d_TextureUnit_0));
|
||||||
if (aLocSampler != INVALID_LOCATION)
|
|
||||||
{
|
|
||||||
SetUniform (theCtx, aLocSampler, GLint(Graphic3d_TextureUnit_0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const TCollection_AsciiString aSamplerNamePrefix ("occSampler");
|
const TCollection_AsciiString aSamplerNamePrefix ("occSampler");
|
||||||
@@ -520,8 +484,7 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
|||||||
for (GLint aUnitIter = 0; aUnitIter < aNbUnitsMax; ++aUnitIter)
|
for (GLint aUnitIter = 0; aUnitIter < aNbUnitsMax; ++aUnitIter)
|
||||||
{
|
{
|
||||||
const TCollection_AsciiString aName = aSamplerNamePrefix + aUnitIter;
|
const TCollection_AsciiString aName = aSamplerNamePrefix + aUnitIter;
|
||||||
const GLint aLocSampler = GetUniformLocation (theCtx, aName.ToCString());
|
if (const OpenGl_ShaderUniformLocation aLocSampler = GetUniformLocation (theCtx, aName.ToCString()))
|
||||||
if (aLocSampler != INVALID_LOCATION)
|
|
||||||
{
|
{
|
||||||
SetUniform (theCtx, aLocSampler, aUnitIter);
|
SetUniform (theCtx, aLocSampler, aUnitIter);
|
||||||
}
|
}
|
||||||
@@ -603,7 +566,7 @@ Standard_Boolean OpenGl_ShaderProgram::DetachShader (const Handle(OpenGl_Context
|
|||||||
// function : Link
|
// function : Link
|
||||||
// purpose : Links the program object
|
// purpose : Links the program object
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean OpenGl_ShaderProgram::Link (const Handle(OpenGl_Context)& theCtx)
|
Standard_Boolean OpenGl_ShaderProgram::link (const Handle(OpenGl_Context)& theCtx)
|
||||||
{
|
{
|
||||||
if (myProgramID == NO_PROGRAM)
|
if (myProgramID == NO_PROGRAM)
|
||||||
{
|
{
|
||||||
@@ -625,6 +588,44 @@ Standard_Boolean OpenGl_ShaderProgram::Link (const Handle(OpenGl_Context)& theCt
|
|||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : Link
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
Standard_Boolean OpenGl_ShaderProgram::Link (const Handle(OpenGl_Context)& theCtx,
|
||||||
|
bool theIsVerbose)
|
||||||
|
{
|
||||||
|
if (!theIsVerbose)
|
||||||
|
{
|
||||||
|
return link (theCtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!link (theCtx))
|
||||||
|
{
|
||||||
|
TCollection_AsciiString aLog;
|
||||||
|
FetchInfoLog (theCtx, aLog);
|
||||||
|
if (aLog.IsEmpty())
|
||||||
|
{
|
||||||
|
aLog = "Linker log is empty.";
|
||||||
|
}
|
||||||
|
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||||
|
TCollection_AsciiString ("Failed to link program object! Linker log:\n") + aLog);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (theCtx->caps->glslWarnings)
|
||||||
|
{
|
||||||
|
TCollection_AsciiString aLog;
|
||||||
|
FetchInfoLog (theCtx, aLog);
|
||||||
|
if (!aLog.IsEmpty()
|
||||||
|
&& !aLog.IsEqual ("No errors.\n"))
|
||||||
|
{
|
||||||
|
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_LOW,
|
||||||
|
TCollection_AsciiString ("GLSL linker log:\n") + aLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : FetchInfoLog
|
// function : FetchInfoLog
|
||||||
// purpose : Fetches information log of the last link operation
|
// purpose : Fetches information log of the last link operation
|
||||||
@@ -673,12 +674,12 @@ Standard_Boolean OpenGl_ShaderProgram::ApplyVariables(const Handle(OpenGl_Contex
|
|||||||
// function : GetUniformLocation
|
// function : GetUniformLocation
|
||||||
// purpose : Returns location (index) of the specific uniform variable
|
// purpose : Returns location (index) of the specific uniform variable
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
GLint OpenGl_ShaderProgram::GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
|
OpenGl_ShaderUniformLocation OpenGl_ShaderProgram::GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
|
||||||
const GLchar* theName) const
|
const GLchar* theName) const
|
||||||
{
|
{
|
||||||
return myProgramID != NO_PROGRAM
|
return OpenGl_ShaderUniformLocation (myProgramID != NO_PROGRAM
|
||||||
? theCtx->core20fwd->glGetUniformLocation (myProgramID, theName)
|
? theCtx->core20fwd->glGetUniformLocation (myProgramID, theName)
|
||||||
: INVALID_LOCATION;
|
: INVALID_LOCATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -693,19 +694,6 @@ GLint OpenGl_ShaderProgram::GetAttributeLocation (const Handle(OpenGl_Context)&
|
|||||||
: INVALID_LOCATION;
|
: 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
|
// function : GetUniform
|
||||||
// purpose : Returns the value of the integer uniform variable
|
// purpose : Returns the value of the integer uniform variable
|
||||||
|
@@ -75,6 +75,13 @@ enum OpenGl_StateVariable
|
|||||||
OpenGl_OCCT_TEXTURE_TRSF2D,
|
OpenGl_OCCT_TEXTURE_TRSF2D,
|
||||||
OpenGl_OCCT_POINT_SIZE,
|
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)
|
// DON'T MODIFY THIS ITEM (insert new items before it)
|
||||||
OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES
|
OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES
|
||||||
};
|
};
|
||||||
@@ -133,6 +140,34 @@ enum OpenGl_UniformStateType
|
|||||||
OpenGl_UniformStateType_NB
|
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.
|
//! Wrapper for OpenGL program object.
|
||||||
class OpenGl_ShaderProgram : public OpenGl_NamedResource
|
class OpenGl_ShaderProgram : public OpenGl_NamedResource
|
||||||
{
|
{
|
||||||
@@ -150,6 +185,12 @@ public:
|
|||||||
//! List of pre-defined OCCT state uniform variables.
|
//! List of pre-defined OCCT state uniform variables.
|
||||||
static Standard_CString PredefinedKeywords[OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES];
|
static Standard_CString PredefinedKeywords[OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES];
|
||||||
|
|
||||||
|
//! Wrapper for compiling shader object with verbose printing on error.
|
||||||
|
Standard_EXPORT static bool compileShaderVerbose (const Handle(OpenGl_Context)& theCtx,
|
||||||
|
const Handle(OpenGl_ShaderObject)& theShader,
|
||||||
|
const TCollection_AsciiString& theSource,
|
||||||
|
bool theToPrintSource = true);
|
||||||
|
|
||||||
//! Creates uninitialized shader program.
|
//! Creates uninitialized shader program.
|
||||||
//!
|
//!
|
||||||
//! WARNING! This constructor is not intended to be called anywhere but from OpenGl_ShaderManager::Create().
|
//! WARNING! This constructor is not intended to be called anywhere but from OpenGl_ShaderManager::Create().
|
||||||
@@ -194,7 +235,10 @@ public:
|
|||||||
const Graphic3d_ShaderObjectList& theShaders);
|
const Graphic3d_ShaderObjectList& theShaders);
|
||||||
|
|
||||||
//! Links the program object.
|
//! Links the program object.
|
||||||
Standard_EXPORT Standard_Boolean Link (const Handle(OpenGl_Context)& theCtx);
|
//! @param theCtx bound OpenGL context
|
||||||
|
//! @param theIsVerbose flag to print log on error
|
||||||
|
Standard_EXPORT Standard_Boolean Link (const Handle(OpenGl_Context)& theCtx,
|
||||||
|
bool theIsVerbose = true);
|
||||||
|
|
||||||
//! Fetches information log of the last link operation.
|
//! Fetches information log of the last link operation.
|
||||||
Standard_EXPORT Standard_Boolean FetchInfoLog (const Handle(OpenGl_Context)& theCtx,
|
Standard_EXPORT Standard_Boolean FetchInfoLog (const Handle(OpenGl_Context)& theCtx,
|
||||||
@@ -261,15 +305,15 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//! Returns location of the specific uniform variable.
|
//! Returns location of the specific uniform variable.
|
||||||
Standard_EXPORT GLint GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
|
Standard_EXPORT OpenGl_ShaderUniformLocation GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
|
||||||
const GLchar* theName) const;
|
const GLchar* theName) const;
|
||||||
|
|
||||||
//! Returns index of the generic vertex attribute by variable name.
|
//! Returns index of the generic vertex attribute by variable name.
|
||||||
Standard_EXPORT GLint GetAttributeLocation (const Handle(OpenGl_Context)& theCtx,
|
Standard_EXPORT GLint GetAttributeLocation (const Handle(OpenGl_Context)& theCtx,
|
||||||
const GLchar* theName) const;
|
const GLchar* theName) const;
|
||||||
|
|
||||||
//! Returns location of the OCCT state uniform variable.
|
//! 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:
|
public:
|
||||||
|
|
||||||
@@ -573,6 +617,9 @@ protected:
|
|||||||
return --myShareCount == 0;
|
return --myShareCount == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Links the program object.
|
||||||
|
Standard_EXPORT Standard_Boolean link (const Handle(OpenGl_Context)& theCtx);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
GLuint myProgramID; //!< Handle of OpenGL shader program
|
GLuint myProgramID; //!< Handle of OpenGL shader program
|
||||||
@@ -591,7 +638,7 @@ protected:
|
|||||||
Standard_Size myCurrentState[OpenGl_UniformStateType_NB]; //!< defines last modification for variables of each state type
|
Standard_Size myCurrentState[OpenGl_UniformStateType_NB]; //!< defines last modification for variables of each state type
|
||||||
|
|
||||||
//! Stores locations of OCCT state uniform variables.
|
//! Stores locations of OCCT state uniform variables.
|
||||||
GLint myStateLocations[OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES];
|
OpenGl_ShaderUniformLocation myStateLocations[OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
#include <OpenGl_GlCore11.hxx>
|
#include <OpenGl_GlCore11.hxx>
|
||||||
#include <OpenGl_StencilTest.hxx>
|
#include <OpenGl_StencilTest.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_StencilTest, OpenGl_Element)
|
|
||||||
|
|
||||||
OpenGl_StencilTest::OpenGl_StencilTest()
|
OpenGl_StencilTest::OpenGl_StencilTest()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
class OpenGl_StencilTest : public OpenGl_Element
|
class OpenGl_StencilTest : public OpenGl_Element
|
||||||
{
|
{
|
||||||
DEFINE_STANDARD_RTTIEXT(OpenGl_StencilTest, OpenGl_Element)
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
|
@@ -460,10 +460,10 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
|
|||||||
aCtx->ApplyModelViewMatrix();
|
aCtx->ApplyModelViewMatrix();
|
||||||
|
|
||||||
// remember aspects
|
// remember aspects
|
||||||
const Handle(OpenGl_AspectLine)& aPrevAspectLine = theWorkspace->AspectLine();
|
const OpenGl_AspectLine* aPrevAspectLine = theWorkspace->AspectLine();
|
||||||
const Handle(OpenGl_AspectFace)& aPrevAspectFace = theWorkspace->AspectFace();
|
const OpenGl_AspectFace* aPrevAspectFace = theWorkspace->AspectFace();
|
||||||
const Handle(OpenGl_AspectMarker)& aPrevAspectMarker = theWorkspace->AspectMarker();
|
const OpenGl_AspectMarker* aPrevAspectMarker = theWorkspace->AspectMarker();
|
||||||
const Handle(OpenGl_AspectText)& aPrevAspectText = theWorkspace->AspectText();
|
const OpenGl_AspectText* aPrevAspectText = theWorkspace->AspectText();
|
||||||
|
|
||||||
// Apply correction for mirror transform
|
// Apply correction for mirror transform
|
||||||
if (myIsMirrored)
|
if (myIsMirrored)
|
||||||
|
@@ -29,8 +29,6 @@
|
|||||||
#include <Graphic3d_TransformUtils.hxx>
|
#include <Graphic3d_TransformUtils.hxx>
|
||||||
#include <TCollection_HAsciiString.hxx>
|
#include <TCollection_HAsciiString.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Text, OpenGl_Element)
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
static const GLdouble THE_IDENTITY_MATRIX[16] =
|
static const GLdouble THE_IDENTITY_MATRIX[16] =
|
||||||
@@ -289,7 +287,7 @@ void OpenGl_Text::Release (OpenGl_Context* theCtx)
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
|
void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
|
||||||
const NCollection_String& theText,
|
const NCollection_String& theText,
|
||||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
const OpenGl_AspectText& theTextAspect,
|
||||||
const OpenGl_TextParam& theParams,
|
const OpenGl_TextParam& theParams,
|
||||||
const unsigned int theResolution,
|
const unsigned int theResolution,
|
||||||
Standard_ShortReal& theWidth,
|
Standard_ShortReal& theWidth,
|
||||||
@@ -355,10 +353,10 @@ void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||||
{
|
{
|
||||||
theWorkspace->SetAspectFace (theWorkspace->FontFaceAspect());
|
theWorkspace->SetAspectFace (&theWorkspace->FontFaceAspect());
|
||||||
theWorkspace->ApplyAspectFace();
|
theWorkspace->ApplyAspectFace();
|
||||||
const Handle(OpenGl_AspectText)& aTextAspect = theWorkspace->ApplyAspectText();
|
const OpenGl_AspectText* aTextAspect = theWorkspace->ApplyAspectText();
|
||||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||||
const Handle(OpenGl_TextureSet) aPrevTexture = aCtx->BindTextures (Handle(OpenGl_TextureSet)());
|
const Handle(OpenGl_TextureSet) aPrevTexture = aCtx->BindTextures (Handle(OpenGl_TextureSet)());
|
||||||
|
|
||||||
// Bind custom shader program or generate default version
|
// Bind custom shader program or generate default version
|
||||||
@@ -369,7 +367,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
|||||||
|
|
||||||
// use highlight color or colors from aspect
|
// use highlight color or colors from aspect
|
||||||
render (aCtx,
|
render (aCtx,
|
||||||
aTextAspect,
|
*aTextAspect,
|
||||||
theWorkspace->TextColor(),
|
theWorkspace->TextColor(),
|
||||||
theWorkspace->TextSubtitleColor(),
|
theWorkspace->TextSubtitleColor(),
|
||||||
aCtx->Resolution());
|
aCtx->Resolution());
|
||||||
@@ -392,13 +390,25 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
|||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
|
void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
const OpenGl_AspectText& theTextAspect,
|
||||||
const unsigned int theResolution) const
|
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,
|
render (theCtx, theTextAspect,
|
||||||
theTextAspect->Aspect()->ColorRGBA(),
|
theTextAspect.Aspect()->ColorRGBA(),
|
||||||
theTextAspect->Aspect()->ColorSubTitleRGBA(),
|
theTextAspect.Aspect()->ColorSubTitleRGBA(),
|
||||||
theResolution);
|
theResolution);
|
||||||
|
|
||||||
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
|
theCtx->SetPolygonMode (aPrevPolygonMode);
|
||||||
|
theCtx->SetPolygonHatchEnabled (aPrevHatchingMode);
|
||||||
|
#endif
|
||||||
|
theCtx->SetSampleAlphaToCoverage (anAlphaToCoverageOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -406,7 +416,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
const OpenGl_AspectText& theTextAspect,
|
||||||
const OpenGl_Vec3 theDVec) const
|
const OpenGl_Vec3 theDVec) const
|
||||||
{
|
{
|
||||||
OpenGl_Mat4d aModViewMat;
|
OpenGl_Mat4d aModViewMat;
|
||||||
@@ -424,7 +434,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
|||||||
{
|
{
|
||||||
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f);
|
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f);
|
||||||
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, 1.f, -1.f, 1.f);
|
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, 1.f, -1.f, 1.f);
|
||||||
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect->Aspect()->GetTextAngle(), 0.f, 0.f, 1.f);
|
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.f, 0.f, 1.f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -466,10 +476,10 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
|
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
|
||||||
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect->Aspect()->GetTextAngle(), 0.0, 0.0, 1.0);
|
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.0, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!theTextAspect->Aspect()->GetTextZoomable())
|
if (!theTextAspect.Aspect()->GetTextZoomable())
|
||||||
{
|
{
|
||||||
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, myScaleHeight, myScaleHeight, myScaleHeight);
|
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, myScaleHeight, myScaleHeight, myScaleHeight);
|
||||||
}
|
}
|
||||||
@@ -506,7 +516,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
|||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Text::drawText (const Handle(OpenGl_Context)& theCtx,
|
void OpenGl_Text::drawText (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Handle(OpenGl_AspectText)& theTextAspect) const
|
const OpenGl_AspectText& theTextAspect) const
|
||||||
{
|
{
|
||||||
(void )theTextAspect;
|
(void )theTextAspect;
|
||||||
if (myVertsVbo.Length() != myTextures.Length()
|
if (myVertsVbo.Length() != myTextures.Length()
|
||||||
@@ -537,14 +547,14 @@ void OpenGl_Text::drawText (const Handle(OpenGl_Context)& theCtx,
|
|||||||
// function : FontKey
|
// function : FontKey
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
TCollection_AsciiString OpenGl_Text::FontKey (const Handle(OpenGl_AspectText)& theAspect,
|
TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_AspectText& theAspect,
|
||||||
const Standard_Integer theHeight,
|
const Standard_Integer theHeight,
|
||||||
const unsigned int theResolution)
|
const unsigned int theResolution)
|
||||||
{
|
{
|
||||||
const Font_FontAspect anAspect = theAspect->Aspect()->GetTextFontAspect() != Font_FA_Undefined
|
const Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined
|
||||||
? theAspect->Aspect()->GetTextFontAspect()
|
? theAspect.Aspect()->GetTextFontAspect()
|
||||||
: Font_FA_Regular;
|
: Font_FA_Regular;
|
||||||
return theAspect->Aspect()->Font()
|
return theAspect.Aspect()->Font()
|
||||||
+ TCollection_AsciiString(":") + Standard_Integer(anAspect)
|
+ TCollection_AsciiString(":") + Standard_Integer(anAspect)
|
||||||
+ TCollection_AsciiString(":") + Standard_Integer(theResolution)
|
+ TCollection_AsciiString(":") + Standard_Integer(theResolution)
|
||||||
+ TCollection_AsciiString(":") + theHeight;
|
+ TCollection_AsciiString(":") + theHeight;
|
||||||
@@ -555,7 +565,7 @@ TCollection_AsciiString OpenGl_Text::FontKey (const Handle(OpenGl_AspectText)& t
|
|||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
|
Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Handle(OpenGl_AspectText)& theAspect,
|
const OpenGl_AspectText& theAspect,
|
||||||
const Standard_Integer theHeight,
|
const Standard_Integer theHeight,
|
||||||
const unsigned int theResolution,
|
const unsigned int theResolution,
|
||||||
const TCollection_AsciiString theKey)
|
const TCollection_AsciiString theKey)
|
||||||
@@ -569,9 +579,9 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
|
|||||||
if (!theCtx->GetResource (theKey, aFont))
|
if (!theCtx->GetResource (theKey, aFont))
|
||||||
{
|
{
|
||||||
Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance();
|
Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance();
|
||||||
const TCollection_AsciiString& aFontName = theAspect->Aspect()->Font();
|
const TCollection_AsciiString& aFontName = theAspect.Aspect()->Font();
|
||||||
Font_FontAspect anAspect = theAspect->Aspect()->GetTextFontAspect() != Font_FA_Undefined
|
Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined
|
||||||
? theAspect->Aspect()->GetTextFontAspect()
|
? theAspect.Aspect()->GetTextFontAspect()
|
||||||
: Font_FA_Regular;
|
: Font_FA_Regular;
|
||||||
Handle(Font_FTFont) aFontFt;
|
Handle(Font_FTFont) aFontFt;
|
||||||
if (Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, anAspect))
|
if (Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, anAspect))
|
||||||
@@ -585,7 +595,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
|
|||||||
{
|
{
|
||||||
TCollection_ExtendedString aMsg;
|
TCollection_ExtendedString aMsg;
|
||||||
aMsg += "Font '";
|
aMsg += "Font '";
|
||||||
aMsg += theAspect->Aspect()->Font();
|
aMsg += theAspect.Aspect()->Font();
|
||||||
aMsg += "' - initialization of GL resources has failed!";
|
aMsg += "' - initialization of GL resources has failed!";
|
||||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
|
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
|
||||||
aFontFt.Nullify();
|
aFontFt.Nullify();
|
||||||
@@ -597,7 +607,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
|
|||||||
{
|
{
|
||||||
TCollection_ExtendedString aMsg;
|
TCollection_ExtendedString aMsg;
|
||||||
aMsg += "Font '";
|
aMsg += "Font '";
|
||||||
aMsg += theAspect->Aspect()->Font();
|
aMsg += theAspect.Aspect()->Font();
|
||||||
aMsg += "' is broken or has incompatible format! File path: ";
|
aMsg += "' is broken or has incompatible format! File path: ";
|
||||||
aMsg += aRequestedFont->FontPathAny (anAspect);
|
aMsg += aRequestedFont->FontPathAny (anAspect);
|
||||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
|
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
|
||||||
@@ -609,7 +619,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
|
|||||||
{
|
{
|
||||||
TCollection_ExtendedString aMsg;
|
TCollection_ExtendedString aMsg;
|
||||||
aMsg += "Font '";
|
aMsg += "Font '";
|
||||||
aMsg += theAspect->Aspect()->Font();
|
aMsg += theAspect.Aspect()->Font();
|
||||||
aMsg += "' is not found in the system!";
|
aMsg += "' is not found in the system!";
|
||||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
|
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
|
||||||
aFont = new OpenGl_Font (aFontFt, theKey);
|
aFont = new OpenGl_Font (aFontFt, theKey);
|
||||||
@@ -625,7 +635,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
|
|||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx,
|
void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
const OpenGl_AspectText& theTextAspect,
|
||||||
const OpenGl_Vec4& theColorSubs) const
|
const OpenGl_Vec4& theColorSubs) const
|
||||||
{
|
{
|
||||||
Handle(OpenGl_ShaderProgram) aPrevProgram = theCtx->ActiveProgram();
|
Handle(OpenGl_ShaderProgram) aPrevProgram = theCtx->ActiveProgram();
|
||||||
@@ -676,7 +686,7 @@ void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx,
|
|||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
const OpenGl_AspectText& theTextAspect,
|
||||||
const OpenGl_Vec4& theColorText,
|
const OpenGl_Vec4& theColorText,
|
||||||
const OpenGl_Vec4& theColorSubs,
|
const OpenGl_Vec4& theColorSubs,
|
||||||
const unsigned int theResolution) const
|
const unsigned int theResolution) const
|
||||||
@@ -749,7 +759,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
myWinX, myWinY, myWinZ);
|
myWinX, myWinY, myWinZ);
|
||||||
|
|
||||||
// compute scale factor for constant text height
|
// compute scale factor for constant text height
|
||||||
if (theTextAspect->Aspect()->GetTextZoomable())
|
if (theTextAspect.Aspect()->GetTextZoomable())
|
||||||
{
|
{
|
||||||
myExportHeight = aPointSize;
|
myExportHeight = aPointSize;
|
||||||
}
|
}
|
||||||
@@ -773,14 +783,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
{
|
{
|
||||||
glDisable (GL_LIGHTING);
|
glDisable (GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Standard_Integer aPrevPolygonMode = theCtx->SetPolygonMode (GL_FILL);
|
|
||||||
const bool aPrevHatchingMode = theCtx->SetPolygonHatchEnabled (false);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// setup depth test
|
// setup depth test
|
||||||
const bool hasDepthTest = !myIs2d
|
const bool hasDepthTest = !myIs2d
|
||||||
&& theTextAspect->Aspect()->Style() != Aspect_TOST_ANNOTATION;
|
&& theTextAspect.Aspect()->Style() != Aspect_TOST_ANNOTATION;
|
||||||
if (!hasDepthTest)
|
if (!hasDepthTest)
|
||||||
{
|
{
|
||||||
glDisable (GL_DEPTH_TEST);
|
glDisable (GL_DEPTH_TEST);
|
||||||
@@ -808,10 +815,9 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
// setup blending
|
// setup blending
|
||||||
glEnable (GL_BLEND);
|
glEnable (GL_BLEND);
|
||||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
const bool anAlphaToCoverageOld = theCtx->SetSampleAlphaToCoverage (false);
|
|
||||||
|
|
||||||
// extra drawings
|
// extra drawings
|
||||||
switch (theTextAspect->Aspect()->DisplayType())
|
switch (theTextAspect.Aspect()->DisplayType())
|
||||||
{
|
{
|
||||||
case Aspect_TODT_BLEND:
|
case Aspect_TODT_BLEND:
|
||||||
{
|
{
|
||||||
@@ -874,7 +880,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (theTextAspect->Aspect()->DisplayType() == Aspect_TODT_DIMENSION)
|
if (theTextAspect.Aspect()->DisplayType() == Aspect_TODT_DIMENSION)
|
||||||
{
|
{
|
||||||
glDisable (GL_BLEND);
|
glDisable (GL_BLEND);
|
||||||
if (!myIs2d)
|
if (!myIs2d)
|
||||||
@@ -906,11 +912,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
glDisable (GL_STENCIL_TEST);
|
glDisable (GL_STENCIL_TEST);
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
glDisable (GL_COLOR_LOGIC_OP);
|
glDisable (GL_COLOR_LOGIC_OP);
|
||||||
|
|
||||||
theCtx->SetPolygonMode (aPrevPolygonMode);
|
|
||||||
theCtx->SetPolygonHatchEnabled (aPrevHatchingMode);
|
|
||||||
#endif
|
#endif
|
||||||
theCtx->SetSampleAlphaToCoverage (anAlphaToCoverageOld);
|
|
||||||
|
|
||||||
// model view matrix was modified
|
// model view matrix was modified
|
||||||
theCtx->WorldViewState.Pop();
|
theCtx->WorldViewState.Pop();
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
//! Text rendering
|
//! Text rendering
|
||||||
class OpenGl_Text : public OpenGl_Element
|
class OpenGl_Text : public OpenGl_Element
|
||||||
{
|
{
|
||||||
DEFINE_STANDARD_RTTIEXT(OpenGl_Text, OpenGl_Element)
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Main constructor
|
//! Main constructor
|
||||||
@@ -83,13 +83,13 @@ public: //! @name methods for compatibility with layers
|
|||||||
Standard_EXPORT OpenGl_Text();
|
Standard_EXPORT OpenGl_Text();
|
||||||
|
|
||||||
//! Create key for shared resource
|
//! Create key for shared resource
|
||||||
Standard_EXPORT static TCollection_AsciiString FontKey (const Handle(OpenGl_AspectText)& theAspect,
|
Standard_EXPORT static TCollection_AsciiString FontKey (const OpenGl_AspectText& theAspect,
|
||||||
const Standard_Integer theHeight,
|
const Standard_Integer theHeight,
|
||||||
const unsigned int theResolution);
|
const unsigned int theResolution);
|
||||||
|
|
||||||
//! Find shared resource for specified font or initialize new one
|
//! Find shared resource for specified font or initialize new one
|
||||||
Standard_EXPORT static Handle(OpenGl_Font) FindFont (const Handle(OpenGl_Context)& theCtx,
|
Standard_EXPORT static Handle(OpenGl_Font) FindFont (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Handle(OpenGl_AspectText)& theAspect,
|
const OpenGl_AspectText& theAspect,
|
||||||
const Standard_Integer theHeight,
|
const Standard_Integer theHeight,
|
||||||
const unsigned int theResolution,
|
const unsigned int theResolution,
|
||||||
const TCollection_AsciiString theKey);
|
const TCollection_AsciiString theKey);
|
||||||
@@ -97,7 +97,7 @@ public: //! @name methods for compatibility with layers
|
|||||||
//! Compute text width
|
//! Compute text width
|
||||||
Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx,
|
Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx,
|
||||||
const NCollection_String& theText,
|
const NCollection_String& theText,
|
||||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
const OpenGl_AspectText& theTextAspect,
|
||||||
const OpenGl_TextParam& theParams,
|
const OpenGl_TextParam& theParams,
|
||||||
const unsigned int theResolution,
|
const unsigned int theResolution,
|
||||||
Standard_ShortReal& theWidth,
|
Standard_ShortReal& theWidth,
|
||||||
@@ -112,8 +112,8 @@ public: //! @name methods for compatibility with layers
|
|||||||
|
|
||||||
//! Perform rendering
|
//! Perform rendering
|
||||||
Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx,
|
Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
const OpenGl_AspectText& theTextAspect,
|
||||||
const unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
|
const unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -127,21 +127,21 @@ private:
|
|||||||
|
|
||||||
//! Setup matrix.
|
//! Setup matrix.
|
||||||
void setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
void setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
const OpenGl_AspectText& theTextAspect,
|
||||||
const OpenGl_Vec3 theDVec) const;
|
const OpenGl_Vec3 theDVec) const;
|
||||||
|
|
||||||
//! Draw arrays of vertices.
|
//! Draw arrays of vertices.
|
||||||
void drawText (const Handle(OpenGl_Context)& theCtx,
|
void drawText (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Handle(OpenGl_AspectText)& theTextAspect) const;
|
const OpenGl_AspectText& theTextAspect) const;
|
||||||
|
|
||||||
//! Draw rectangle from bounding text box.
|
//! Draw rectangle from bounding text box.
|
||||||
void drawRect (const Handle(OpenGl_Context)& theCtx,
|
void drawRect (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
const OpenGl_AspectText& theTextAspect,
|
||||||
const OpenGl_Vec4& theColorSubs) const;
|
const OpenGl_Vec4& theColorSubs) const;
|
||||||
|
|
||||||
//! Main rendering code
|
//! Main rendering code
|
||||||
void render (const Handle(OpenGl_Context)& theCtx,
|
void render (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Handle(OpenGl_AspectText)& theTextAspect,
|
const OpenGl_AspectText& theTextAspect,
|
||||||
const OpenGl_Vec4& theColorText,
|
const OpenGl_Vec4& theColorText,
|
||||||
const OpenGl_Vec4& theColorSubs,
|
const OpenGl_Vec4& theColorSubs,
|
||||||
const unsigned int theResolution) const;
|
const unsigned int theResolution) const;
|
||||||
|
@@ -405,6 +405,15 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
|||||||
const Graphic3d_TypeOfTexture theType,
|
const Graphic3d_TypeOfTexture theType,
|
||||||
const Image_PixMap* theImage)
|
const Image_PixMap* theImage)
|
||||||
{
|
{
|
||||||
|
if (theSizeX < 1
|
||||||
|
|| theSizeY < 1)
|
||||||
|
{
|
||||||
|
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||||
|
"Error: texture of 0 size cannot be created.");
|
||||||
|
Release (theCtx.operator->());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
const GLenum aTarget = theType == Graphic3d_TOT_1D
|
const GLenum aTarget = theType == Graphic3d_TOT_1D
|
||||||
? GL_TEXTURE_1D
|
? GL_TEXTURE_1D
|
||||||
|
@@ -15,24 +15,21 @@
|
|||||||
|
|
||||||
#include <OpenGl_Context.hxx>
|
#include <OpenGl_Context.hxx>
|
||||||
#include <OpenGl_TileSampler.hxx>
|
#include <OpenGl_TileSampler.hxx>
|
||||||
|
#include <Graphic3d_RenderingParams.hxx>
|
||||||
#include <TCollection_ExtendedString.hxx>
|
#include <TCollection_ExtendedString.hxx>
|
||||||
|
|
||||||
namespace
|
// define to debug algorithm values
|
||||||
{
|
//#define RAY_TRACE_PRINT_DEBUG_INFO
|
||||||
//! Scale factor for estimating visual error.
|
|
||||||
static const float THE_SCALE_FACTOR = 1.0f / 1e6f;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : OpenGl_TileSampler
|
//function : OpenGl_TileSampler
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
OpenGl_TileSampler::OpenGl_TileSampler()
|
OpenGl_TileSampler::OpenGl_TileSampler()
|
||||||
: mySample (0),
|
: myLastSample (0),
|
||||||
mySizeX (0),
|
myScaleFactor(1.0f),
|
||||||
mySizeY (0),
|
myTileSize (0),
|
||||||
myTilesX (0),
|
myViewSize (0, 0)
|
||||||
myTilesY (0)
|
|
||||||
{
|
{
|
||||||
mySampler.initFaure();
|
mySampler.initFaure();
|
||||||
}
|
}
|
||||||
@@ -41,156 +38,292 @@ OpenGl_TileSampler::OpenGl_TileSampler()
|
|||||||
//function : GrabVarianceMap
|
//function : GrabVarianceMap
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void OpenGl_TileSampler::GrabVarianceMap (const Handle(OpenGl_Context)& theContext)
|
void OpenGl_TileSampler::GrabVarianceMap (const Handle(OpenGl_Context)& theContext,
|
||||||
{
|
const Handle(OpenGl_Texture)& theTexture)
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
|
||||||
std::vector<GLint> aRawData (NbTiles(), 0);
|
|
||||||
|
|
||||||
theContext->core11fwd->glGetTexImage (GL_TEXTURE_2D, 0, GL_RED_INTEGER, GL_INT, &aRawData.front());
|
|
||||||
const GLenum anErr = theContext->core11fwd->glGetError();
|
|
||||||
if (anErr != GL_NO_ERROR)
|
|
||||||
{
|
|
||||||
theContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_MEDIUM,
|
|
||||||
"Error! Failed to fetch visual error map from the GPU");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int aTileIdx = 0, aNbTiles = NbTiles(); aTileIdx < aNbTiles; ++aTileIdx)
|
|
||||||
{
|
|
||||||
myVarianceMap[aTileIdx] = aRawData[aTileIdx] * THE_SCALE_FACTOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int aX = 0; aX < myTilesX; ++aX)
|
|
||||||
{
|
|
||||||
for (int aY = 0; aY < myTilesY; ++aY)
|
|
||||||
{
|
|
||||||
ChangeTile (aX, aY) *= 1.0f / TileArea (aX, aY); // average error over the tile
|
|
||||||
|
|
||||||
if (aY > 0)
|
|
||||||
{
|
|
||||||
ChangeTile (aX, aY) += Tile (aX, aY - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
myMarginalMap.resize (myTilesX); // build marginal distribution
|
|
||||||
for (int aX = 0; aX < myTilesX; ++aX)
|
|
||||||
{
|
|
||||||
myMarginalMap[aX] = Tile (aX, myTilesY - 1);
|
|
||||||
|
|
||||||
if (aX > 0)
|
|
||||||
myMarginalMap[aX] += myMarginalMap[aX - 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// glGetTexImage() is unavailable on OpenGL ES, FBO + glReadPixels() can be used instead
|
|
||||||
(void )theContext;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Sample
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void OpenGl_TileSampler::Sample (int& theOffsetX,
|
|
||||||
int& theOffsetY)
|
|
||||||
{
|
|
||||||
int aX = 0;
|
|
||||||
int aY = 0;
|
|
||||||
|
|
||||||
const float aKsiX = mySampler.sample (0, mySample) * myMarginalMap.back();
|
|
||||||
for (; aX < myTilesX - 1; ++aX)
|
|
||||||
{
|
|
||||||
if (aKsiX <= myMarginalMap[aX])
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const float aKsiY = mySampler.sample (1, mySample) * Tile (aX, myTilesY - 1);
|
|
||||||
for (; aY < myTilesY - 1; ++aY)
|
|
||||||
{
|
|
||||||
if (aKsiY <= Tile (aX, aY))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
theOffsetX = aX * TileSize();
|
|
||||||
theOffsetY = aY * TileSize();
|
|
||||||
|
|
||||||
++mySample;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : SetSize
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void OpenGl_TileSampler::SetSize (const int theSizeX,
|
|
||||||
const int theSizeY)
|
|
||||||
{
|
|
||||||
if (mySizeX == theSizeX
|
|
||||||
&& mySizeY == theSizeY)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mySizeX = theSizeX;
|
|
||||||
mySizeY = theSizeY;
|
|
||||||
|
|
||||||
myTilesX = static_cast<int> (ceilf (static_cast<float> (mySizeX) / TileSize()));
|
|
||||||
myTilesY = static_cast<int> (ceilf (static_cast<float> (mySizeY) / TileSize()));
|
|
||||||
|
|
||||||
myVarianceMap.resize (myTilesX * myTilesY);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Upload
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void OpenGl_TileSampler::Upload (const Handle(OpenGl_Context)& theContext,
|
|
||||||
const Handle(OpenGl_Texture)& theTexture,
|
|
||||||
const int theNbTilesX,
|
|
||||||
const int theNbTilesY,
|
|
||||||
const bool theAdaptive)
|
|
||||||
{
|
{
|
||||||
if (theTexture.IsNull())
|
if (theTexture.IsNull())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int aNbTilesX = theAdaptive ? theNbTilesX : myTilesX;
|
myVarianceRaw.Init (0);
|
||||||
const int aNbTilesY = theAdaptive ? theNbTilesY : myTilesY;
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
|
theTexture->Bind (theContext);
|
||||||
Standard_ASSERT_RAISE (aNbTilesX * aNbTilesY > 0,
|
theContext->core11fwd->glPixelStorei (GL_PACK_ALIGNMENT, 1);
|
||||||
"Error! Number of sampling tiles should be positive");
|
theContext->core11fwd->glPixelStorei (GL_PACK_ROW_LENGTH, 0);
|
||||||
|
theContext->core11fwd->glGetTexImage (GL_TEXTURE_2D, 0, GL_RED_INTEGER, GL_INT, myVarianceRaw.ChangeData());
|
||||||
std::vector<GLint> aData (aNbTilesX * aNbTilesY * 2);
|
const GLenum anErr = theContext->core11fwd->glGetError();
|
||||||
|
theTexture->Unbind (theContext);
|
||||||
for (int aX = 0; aX < aNbTilesX; ++aX)
|
if (anErr != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
for (int aY = 0; aY < aNbTilesY; ++aY)
|
theContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_MEDIUM,
|
||||||
|
"Error! Failed to fetch visual error map from the GPU");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// glGetTexImage() is unavailable on OpenGL ES, FBO + glReadPixels() can be used instead
|
||||||
|
(void )theContext;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const float aFactor = 1.0f / myScaleFactor;
|
||||||
|
for (Standard_Size aColIter = 0; aColIter < myVarianceMap.SizeX; ++aColIter)
|
||||||
|
{
|
||||||
|
for (Standard_Size aRowIter = 0; aRowIter < myVarianceMap.SizeY; ++aRowIter)
|
||||||
{
|
{
|
||||||
if (!theAdaptive)
|
const int aRawValue = myVarianceRaw.Value (aRowIter, aColIter);
|
||||||
|
Standard_RangeError_Raise_if (aRawValue < 0, "Internal Error: signed integer overflow within OpenGl_TileSampler");
|
||||||
|
|
||||||
|
float& aTile = myVarianceMap.ChangeValue (aRowIter, aColIter);
|
||||||
|
aTile = aFactor * float(aRawValue);
|
||||||
|
aTile *= 1.0f / tileArea ((int )aColIter, (int )aRowIter); // average error over the tile
|
||||||
|
if (aRowIter != 0)
|
||||||
{
|
{
|
||||||
aData[(aY * aNbTilesX + aX) * 2 + 0] = aX * TileSize();
|
aTile += myVarianceMap.Value (aRowIter - 1, aColIter);
|
||||||
aData[(aY * aNbTilesX + aX) * 2 + 1] = aY * TileSize();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Sample (aData[(aY * aNbTilesX + aX) * 2 + 0],
|
|
||||||
aData[(aY * aNbTilesX + aX) * 2 + 1]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
theTexture->Bind (theContext);
|
// build marginal distribution
|
||||||
|
for (Standard_Size aX = 0; aX < myVarianceMap.SizeX; ++aX)
|
||||||
theContext->core11fwd->glTexImage2D (GL_TEXTURE_2D, 0, GL_RG32I, aNbTilesX, aNbTilesY, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, &aData.front());
|
|
||||||
|
|
||||||
if (theContext->core11fwd->glGetError() != GL_NO_ERROR)
|
|
||||||
{
|
{
|
||||||
theContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_MEDIUM,
|
myMarginalMap[aX] = myVarianceMap.Value (myVarianceMap.SizeY - 1, aX);
|
||||||
"Error! Failed to upload tile offset map on the GPU");
|
if (aX != 0)
|
||||||
|
{
|
||||||
|
myMarginalMap[aX] += myMarginalMap[aX - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef RAY_TRACE_PRINT_DEBUG_INFO
|
||||||
|
dumpMap (std::cerr, myVarianceRaw, "OpenGl_TileSampler, Variance map");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : dumpMap
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void OpenGl_TileSampler::dumpMap (std::ostream& theStream,
|
||||||
|
const Image_PixMapTypedData<int>& theMap,
|
||||||
|
const char* theTitle) const
|
||||||
|
{
|
||||||
|
theStream << theTitle << " " << theMap.SizeX << "x" << theMap.SizeY << " (tile " << myTileSize << "x" << myTileSize << ")" << ":\n";
|
||||||
|
for (Standard_Size aRowIter = 0; aRowIter < theMap.SizeY; ++aRowIter)
|
||||||
|
{
|
||||||
|
for (Standard_Size aColIter = 0; aColIter < theMap.SizeX; ++aColIter)
|
||||||
|
{
|
||||||
|
theStream << " [" << theMap.Value (aRowIter, aColIter) << "]";
|
||||||
|
}
|
||||||
|
theStream << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : nextTileToSample
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Graphic3d_Vec2i OpenGl_TileSampler::nextTileToSample()
|
||||||
|
{
|
||||||
|
Graphic3d_Vec2i aTile (0, 0);
|
||||||
|
const float aKsiX = mySampler.sample (0, myLastSample) * myMarginalMap.back();
|
||||||
|
for (; (size_t )aTile.x() < myMarginalMap.size() - 1; ++aTile.x())
|
||||||
|
{
|
||||||
|
if (aKsiX <= myMarginalMap[aTile.x()])
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const float aKsiY = mySampler.sample (1, myLastSample) * myVarianceMap.Value (myVarianceMap.SizeY - 1, aTile.x());
|
||||||
|
for (; (size_t )aTile.y() < myVarianceMap.SizeY - 1; ++aTile.y())
|
||||||
|
{
|
||||||
|
if (aKsiY <= myVarianceMap.Value (aTile.y(), aTile.x()))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
++myLastSample;
|
||||||
|
return aTile;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetSize
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void OpenGl_TileSampler::SetSize (const Graphic3d_RenderingParams& theParams,
|
||||||
|
const Graphic3d_Vec2i& theSize)
|
||||||
|
{
|
||||||
|
if (theSize.x() <= 0
|
||||||
|
|| theSize.y() <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
myViewSize = theSize;
|
||||||
|
|
||||||
|
const int aTileSize = Max (theParams.RayTracingTileSize, 1);
|
||||||
|
const int aNbTilesX = Max (1, static_cast<int> (ceilf (static_cast<float> (theSize.x()) / aTileSize)));
|
||||||
|
const int aNbTilesY = Max (1, static_cast<int> (ceilf (static_cast<float> (theSize.y()) / aTileSize)));
|
||||||
|
if (myTileSize != aTileSize
|
||||||
|
|| (int )myTiles.SizeX != aNbTilesX
|
||||||
|
|| (int )myTiles.SizeY != aNbTilesY)
|
||||||
|
{
|
||||||
|
myTileSize = aTileSize;
|
||||||
|
myScaleFactor = 1.0e6f * (1024.0f / float(myTileSize * myTileSize));
|
||||||
|
|
||||||
|
Handle(NCollection_BaseAllocator) anAlloc = NCollection_BaseAllocator::CommonBaseAllocator();
|
||||||
|
myTiles.SetTopDown (true);
|
||||||
|
myTiles.Init (anAlloc, aNbTilesX, aNbTilesY);
|
||||||
|
myTiles.Init (1);
|
||||||
|
|
||||||
|
myTileSamples.SetTopDown (true);
|
||||||
|
myTileSamples.Init (myTiles.Allocator(), aNbTilesX, aNbTilesY);
|
||||||
|
myTileSamples.Init (1);
|
||||||
|
|
||||||
|
myVarianceMap.SetTopDown (true);
|
||||||
|
myVarianceMap.Init (myTiles.Allocator(), myTiles.SizeX, myTiles.SizeY);
|
||||||
|
myVarianceMap.Init (0.0f);
|
||||||
|
|
||||||
|
myVarianceRaw.SetTopDown (true);
|
||||||
|
myVarianceRaw.Init (myTiles.Allocator(), myTiles.SizeX, myTiles.SizeY);
|
||||||
|
myVarianceRaw.Init (0);
|
||||||
|
|
||||||
|
myOffsets.SetTopDown (true);
|
||||||
|
myOffsets.Init (myTiles.Allocator(), myTiles.SizeX, myTiles.SizeY);
|
||||||
|
myOffsets.Init (Graphic3d_Vec2i (-1, -1));
|
||||||
|
|
||||||
|
myMarginalMap.resize (myTiles.SizeX);
|
||||||
|
myMarginalMap.assign (myMarginalMap.size(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate a size of compact offsets texture optimal for rendering reduced number of tiles
|
||||||
|
Standard_Integer aNbShunkTilesX = (int )myTiles.SizeX, aNbShunkTilesY = (int )myTiles.SizeY;
|
||||||
|
if (theParams.NbRayTracingTiles > 0)
|
||||||
|
{
|
||||||
|
aNbShunkTilesX = 8;
|
||||||
|
aNbShunkTilesY = 8;
|
||||||
|
for (Standard_Integer anIdx = 0; aNbShunkTilesX * aNbShunkTilesY < theParams.NbRayTracingTiles; ++anIdx)
|
||||||
|
{
|
||||||
|
(anIdx % 2 == 0 ? aNbShunkTilesX : aNbShunkTilesY) <<= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((int )myOffsetsShrunk.SizeX != aNbShunkTilesX
|
||||||
|
|| (int )myOffsetsShrunk.SizeY != aNbShunkTilesY)
|
||||||
|
{
|
||||||
|
myOffsetsShrunk.SetTopDown (true);
|
||||||
|
myOffsetsShrunk.Init (myTiles.Allocator(), aNbShunkTilesX, aNbShunkTilesY);
|
||||||
|
myOffsetsShrunk.Init (Graphic3d_Vec2i (-1, -1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : upload
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
bool OpenGl_TileSampler::upload (const Handle(OpenGl_Context)& theContext,
|
||||||
|
const Handle(OpenGl_Texture)& theSamplesTexture,
|
||||||
|
const Handle(OpenGl_Texture)& theOffsetsTexture,
|
||||||
|
const bool theAdaptive)
|
||||||
|
{
|
||||||
|
if (myTiles.IsEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill in myTiles map with a number of passes (samples) per tile.
|
||||||
|
// By default, all tiles receive 1 sample, but basing on visual error level (myVarianceMap),
|
||||||
|
// this amount is re-distributed from tiles having smallest error take 0 samples to tiles having larger error.
|
||||||
|
// This redistribution is smoothed by Halton sampler.
|
||||||
|
//
|
||||||
|
// myOffsets map is filled as redirection of currently rendered tile to another one
|
||||||
|
// so that tiles having smallest error level have 0 tiles redirected from,
|
||||||
|
// while tiles with great error level might be rendered more than 1.
|
||||||
|
// This map is used within single-pass rendering method requiring atomic float operation support from hardware.
|
||||||
|
myTiles.Init (0);
|
||||||
|
Image_PixMapTypedData<Graphic3d_Vec2i>& anOffsets = theAdaptive ? myOffsetsShrunk : myOffsets;
|
||||||
|
anOffsets.Init (Graphic3d_Vec2i (-1, -1));
|
||||||
|
for (Standard_Size aRowIter = 0; aRowIter < anOffsets.SizeY; ++aRowIter)
|
||||||
|
{
|
||||||
|
for (Standard_Size aColIter = 0; aColIter < anOffsets.SizeX; ++aColIter)
|
||||||
|
{
|
||||||
|
Graphic3d_Vec2i& aRedirectTile = anOffsets.ChangeValue (aRowIter, aColIter);
|
||||||
|
aRedirectTile = theAdaptive ? nextTileToSample() : Graphic3d_Vec2i ((int )aColIter, (int )aRowIter);
|
||||||
|
myTiles.ChangeValue (aRedirectTile.y(), aRedirectTile.x()) += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef RAY_TRACE_PRINT_DEBUG_INFO
|
||||||
|
dumpMap (std::cerr, myTiles, "OpenGl_TileSampler, Samples");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Fill in myTileSamples map from myTiles with an actual number of Samples per Tile as multiple of Tile Area
|
||||||
|
// (e.g. tile that should be rendered ones will have amount of samples equal to its are 4x4=16).
|
||||||
|
// This map is used for discarding tile fragments having <=0 of samples left within multi-pass rendering.
|
||||||
|
myTileSamples.Init (0);
|
||||||
|
for (Standard_Size aRowIter = 0; aRowIter < myTiles.SizeY; ++aRowIter)
|
||||||
|
{
|
||||||
|
for (Standard_Size aColIter = 0; aColIter < myTiles.SizeX; ++aColIter)
|
||||||
|
{
|
||||||
|
myTileSamples.ChangeValue (aRowIter, aColIter) = tileArea ((int )aColIter, (int )aRowIter) * myTiles.Value (aRowIter, aColIter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasErrors = false;
|
||||||
|
|
||||||
|
if (!theSamplesTexture.IsNull())
|
||||||
|
{
|
||||||
|
theSamplesTexture->Bind (theContext);
|
||||||
|
theContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
|
theContext->core11fwd->glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
#endif
|
||||||
|
if (theSamplesTexture->SizeX() == (int )myTileSamples.SizeX
|
||||||
|
&& theSamplesTexture->SizeY() == (int )myTileSamples.SizeY)
|
||||||
|
{
|
||||||
|
theContext->core11fwd->glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, (int )myTileSamples.SizeX, (int )myTileSamples.SizeY, GL_RED_INTEGER, GL_INT, myTileSamples.Data());
|
||||||
|
if (theContext->core11fwd->glGetError() != GL_NO_ERROR)
|
||||||
|
{
|
||||||
|
hasErrors = true;
|
||||||
|
theContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_MEDIUM,
|
||||||
|
"Error! Failed to upload tile samples map on the GPU");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hasErrors = true;
|
||||||
|
}
|
||||||
|
theSamplesTexture->Unbind (theContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!theOffsetsTexture.IsNull())
|
||||||
|
{
|
||||||
|
if (theOffsetsTexture->SizeX() != (int )anOffsets.SizeX
|
||||||
|
|| theOffsetsTexture->SizeY() != (int )anOffsets.SizeY
|
||||||
|
|| !theOffsetsTexture->IsValid())
|
||||||
|
{
|
||||||
|
theOffsetsTexture->Release (theContext.operator->());
|
||||||
|
if (!theOffsetsTexture->Init (theContext, GL_RG32I, GL_RG_INTEGER, GL_INT,
|
||||||
|
(int )anOffsets.SizeX, (int )anOffsets.SizeY, Graphic3d_TOT_2D))
|
||||||
|
{
|
||||||
|
hasErrors = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (theOffsetsTexture->IsValid())
|
||||||
|
{
|
||||||
|
theOffsetsTexture->Bind (theContext);
|
||||||
|
theContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
|
theContext->core11fwd->glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
#endif
|
||||||
|
theContext->core11fwd->glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, (int )anOffsets.SizeX, (int )anOffsets.SizeY, GL_RG_INTEGER, GL_INT, anOffsets.Data());
|
||||||
|
if (theContext->core11fwd->glGetError() != GL_NO_ERROR)
|
||||||
|
{
|
||||||
|
hasErrors = true;
|
||||||
|
theContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_MEDIUM,
|
||||||
|
"Error! Failed to upload tile offset map on the GPU");
|
||||||
|
}
|
||||||
|
theOffsetsTexture->Unbind (theContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !hasErrors;
|
||||||
|
}
|
||||||
|
@@ -19,8 +19,12 @@
|
|||||||
#include <OpenGl_Texture.hxx>
|
#include <OpenGl_Texture.hxx>
|
||||||
#include <OpenGl_HaltonSampler.hxx>
|
#include <OpenGl_HaltonSampler.hxx>
|
||||||
|
|
||||||
|
#include <Image_PixMapTypedData.hxx>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
class Graphic3d_RenderingParams;
|
||||||
|
|
||||||
//! Tool object used for sampling screen tiles according to estimated pixel variance (used in path tracing engine).
|
//! Tool object used for sampling screen tiles according to estimated pixel variance (used in path tracing engine).
|
||||||
//! To improve GPU thread coherency, rendering window is split into pixel blocks or tiles. The important feature of
|
//! To improve GPU thread coherency, rendering window is split into pixel blocks or tiles. The important feature of
|
||||||
//! this approach is that it is possible to keep the same number of tiles for any screen resolution (e.g. 256 tiles
|
//! this approach is that it is possible to keep the same number of tiles for any screen resolution (e.g. 256 tiles
|
||||||
@@ -30,87 +34,126 @@
|
|||||||
//! final final image is the same for both cases.
|
//! final final image is the same for both cases.
|
||||||
class OpenGl_TileSampler
|
class OpenGl_TileSampler
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
|
|
||||||
//! Size of individual tile in pixels.
|
|
||||||
static int TileSize() { return 32; }
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Creates new tile sampler.
|
//! Creates new tile sampler.
|
||||||
Standard_EXPORT OpenGl_TileSampler();
|
Standard_EXPORT OpenGl_TileSampler();
|
||||||
|
|
||||||
//! Returns width of ray-tracing viewport.
|
//! Size of individual tile in pixels.
|
||||||
int SizeX() const { return mySizeX; }
|
Graphic3d_Vec2i TileSize() const { return Graphic3d_Vec2i (myTileSize, myTileSize); }
|
||||||
|
|
||||||
//! Returns height of ray-tracing viewport.
|
//! Scale factor for quantization of visual error (float) into signed integer.
|
||||||
int SizeY() const { return mySizeY; }
|
float VarianceScaleFactor() const { return myScaleFactor; }
|
||||||
|
|
||||||
//! Returns number of tiles in X dimension.
|
//! Returns number of tiles in X dimension.
|
||||||
int NbTilesX() const { return myTilesX; }
|
int NbTilesX() const { return (int)myTiles.SizeX; }
|
||||||
|
|
||||||
//! Returns number of tiles in Y dimension.
|
//! Returns number of tiles in Y dimension.
|
||||||
int NbTilesY() const { return myTilesY; }
|
int NbTilesY() const { return (int)myTiles.SizeY; }
|
||||||
|
|
||||||
//! Returns total number of tiles in viewport.
|
//! Returns total number of tiles in viewport.
|
||||||
int NbTiles() const { return myTilesX * myTilesY; }
|
int NbTiles() const { return int(myTiles.SizeX * myTiles.SizeY); }
|
||||||
|
|
||||||
//! Specifies size of ray-tracing viewport.
|
//! Returns ray-tracing viewport.
|
||||||
Standard_EXPORT void SetSize (const int theSizeX,
|
const Graphic3d_Vec2i& ViewSize() const { return myViewSize; }
|
||||||
const int theSizeY);
|
|
||||||
|
|
||||||
//! Returns number of pixels in the given tile.
|
//! Number of tiles within offsets texture.
|
||||||
int TileArea (const int theX,
|
Graphic3d_Vec2i NbOffsetTiles (bool theAdaptive) const
|
||||||
const int theY) const
|
|
||||||
{
|
{
|
||||||
return Min (TileSize(), mySizeX - theX * TileSize())
|
return theAdaptive
|
||||||
* Min (TileSize(), mySizeY - theY * TileSize());
|
? Graphic3d_Vec2i ((int )myOffsetsShrunk.SizeX, (int )myOffsetsShrunk.SizeY)
|
||||||
|
: Graphic3d_Vec2i ((int )myOffsets.SizeX, (int )myOffsets.SizeY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Maximum number of tiles within offsets texture.
|
||||||
|
Graphic3d_Vec2i NbOffsetTilesMax() const { return NbOffsetTiles (true).cwiseMax (NbOffsetTiles (false)); }
|
||||||
|
|
||||||
|
//! Viewport for rendering using offsets texture.
|
||||||
|
Graphic3d_Vec2i OffsetTilesViewport (bool theAdaptive) const { return NbOffsetTiles (theAdaptive) * myTileSize; }
|
||||||
|
|
||||||
|
//! Maximum viewport for rendering using offsets texture.
|
||||||
|
Graphic3d_Vec2i OffsetTilesViewportMax() const { return NbOffsetTilesMax() * myTileSize; }
|
||||||
|
|
||||||
|
//! Return maximum number of samples per tile.
|
||||||
|
int MaxTileSamples() const
|
||||||
|
{
|
||||||
|
int aNbSamples = 0;
|
||||||
|
for (Standard_Size aRowIter = 0; aRowIter < myTiles.SizeY; ++aRowIter)
|
||||||
|
{
|
||||||
|
for (Standard_Size aColIter = 0; aColIter < myTiles.SizeX; ++aColIter)
|
||||||
|
{
|
||||||
|
aNbSamples = Max (aNbSamples, myTiles.Value (aRowIter, aColIter));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return aNbSamples;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Specifies size of ray-tracing viewport and recomputes tile size.
|
||||||
|
Standard_EXPORT void SetSize (const Graphic3d_RenderingParams& theParams,
|
||||||
|
const Graphic3d_Vec2i& theSize);
|
||||||
|
|
||||||
//! Fetches current error estimation from the GPU and
|
//! Fetches current error estimation from the GPU and
|
||||||
//! builds 2D discrete distribution for tile sampling.
|
//! builds 2D discrete distribution for tile sampling.
|
||||||
Standard_EXPORT void GrabVarianceMap (const Handle(OpenGl_Context)& theContext);
|
Standard_EXPORT void GrabVarianceMap (const Handle(OpenGl_Context)& theContext,
|
||||||
|
const Handle(OpenGl_Texture)& theTexture);
|
||||||
|
|
||||||
//! Samples tile location according to estimated error.
|
//! Resets (restart) tile sampler to initial state.
|
||||||
Standard_EXPORT void Sample (int& theOffsetX,
|
void Reset() { myLastSample = 0; }
|
||||||
int& theOffsetY);
|
|
||||||
|
|
||||||
//! Resets tile sampler to initial state.
|
//! Uploads tile samples to the given OpenGL texture.
|
||||||
void Reset() { mySample = 0; }
|
bool UploadSamples (const Handle(OpenGl_Context)& theContext,
|
||||||
|
const Handle(OpenGl_Texture)& theSamplesTexture,
|
||||||
|
const bool theAdaptive)
|
||||||
|
{
|
||||||
|
return upload (theContext, theSamplesTexture, Handle(OpenGl_Texture)(), theAdaptive);
|
||||||
|
}
|
||||||
|
|
||||||
//! Uploads offsets of sampled tiles to the given OpenGL texture.
|
//! Uploads offsets of sampled tiles to the given OpenGL texture.
|
||||||
Standard_EXPORT void Upload (const Handle(OpenGl_Context)& theContext,
|
bool UploadOffsets (const Handle(OpenGl_Context)& theContext,
|
||||||
const Handle(OpenGl_Texture)& theTexture,
|
const Handle(OpenGl_Texture)& theOffsetsTexture,
|
||||||
const int theNbTilesX,
|
const bool theAdaptive)
|
||||||
const int theNbTilesY,
|
|
||||||
const bool theAdaptive);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
//! Returns tile value (estimated error).
|
|
||||||
float Tile (const int theX,
|
|
||||||
const int theY) const
|
|
||||||
{
|
{
|
||||||
return myVarianceMap[theY * myTilesX + theX];
|
return upload (theContext, Handle(OpenGl_Texture)(), theOffsetsTexture, theAdaptive);
|
||||||
}
|
|
||||||
|
|
||||||
//! Returns tile value (estimated error).
|
|
||||||
float& ChangeTile (const int theX,
|
|
||||||
const int theY)
|
|
||||||
{
|
|
||||||
return myVarianceMap[theY * myTilesX + theX];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
std::vector<float> myVarianceMap; //!< Estimation of visual error per tile
|
//! Returns number of pixels in the given tile.
|
||||||
std::vector<float> myMarginalMap; //!< Marginal distribution of 2D error map
|
int tileArea (int theX, int theY) const
|
||||||
OpenGl_HaltonSampler mySampler; //!< Halton sequence generator
|
{
|
||||||
int mySample; //!< Index of generated sample
|
const int aSizeX = Min (myTileSize, myViewSize.x() - theX * myTileSize);
|
||||||
int mySizeX; //!< Width of ray-tracing viewport
|
const int aSizeY = Min (myTileSize, myViewSize.y() - theY * myTileSize);
|
||||||
int mySizeY; //!< Height of ray-tracing viewport
|
return aSizeX * aSizeY;
|
||||||
int myTilesX; //!< Number of tiles in X dimension
|
}
|
||||||
int myTilesY; //!< Number of tiles in Y dimension
|
|
||||||
|
//! Samples tile location according to estimated error.
|
||||||
|
Standard_EXPORT Graphic3d_Vec2i nextTileToSample();
|
||||||
|
|
||||||
|
//! Uploads offsets of sampled tiles to the given OpenGL texture.
|
||||||
|
Standard_EXPORT bool upload (const Handle(OpenGl_Context)& theContext,
|
||||||
|
const Handle(OpenGl_Texture)& theSamplesTexture,
|
||||||
|
const Handle(OpenGl_Texture)& theOffsetsTexture,
|
||||||
|
const bool theAdaptive);
|
||||||
|
|
||||||
|
//! Auxiliary method for dumping 2D image map into stream (e.g. for debugging).
|
||||||
|
Standard_EXPORT void dumpMap (std::ostream& theStream,
|
||||||
|
const Image_PixMapTypedData<int>& theMap,
|
||||||
|
const char* theTitle) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
Image_PixMapTypedData<unsigned int> myTiles; //!< number of samples per tile (initially all 1)
|
||||||
|
Image_PixMapTypedData<unsigned int> myTileSamples; //!< number of samples for all pixels within the tile (initially equals to Tile area)
|
||||||
|
Image_PixMapTypedData<float> myVarianceMap; //!< Estimation of visual error per tile
|
||||||
|
Image_PixMapTypedData<int> myVarianceRaw; //!< Estimation of visual error per tile (raw data)
|
||||||
|
Image_PixMapTypedData<Graphic3d_Vec2i> myOffsets; //!< 2D array of tiles redirecting to another tile
|
||||||
|
Image_PixMapTypedData<Graphic3d_Vec2i> myOffsetsShrunk; //!< 2D array of tiles redirecting to another tile (shrunk)
|
||||||
|
std::vector<float> myMarginalMap; //!< Marginal distribution of 2D error map
|
||||||
|
OpenGl_HaltonSampler mySampler; //!< Halton sequence generator
|
||||||
|
unsigned int myLastSample; //!< Index of generated sample
|
||||||
|
float myScaleFactor; //!< scale factor for quantization of visual error (float) into signed integer
|
||||||
|
int myTileSize; //!< tile size
|
||||||
|
Graphic3d_Vec2i myViewSize; //!< ray-tracing viewport
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -110,9 +110,6 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
|
|||||||
myRaytraceFBO1[1] = new OpenGl_FrameBuffer();
|
myRaytraceFBO1[1] = new OpenGl_FrameBuffer();
|
||||||
myRaytraceFBO2[0] = new OpenGl_FrameBuffer();
|
myRaytraceFBO2[0] = new OpenGl_FrameBuffer();
|
||||||
myRaytraceFBO2[1] = new OpenGl_FrameBuffer();
|
myRaytraceFBO2[1] = new OpenGl_FrameBuffer();
|
||||||
|
|
||||||
myGraduatedTrihedron = new OpenGl_GraduatedTrihedron();
|
|
||||||
myFrameStatsPrs = new OpenGl_FrameStatsPrs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -133,8 +130,8 @@ OpenGl_View::~OpenGl_View()
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
|
void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
|
||||||
{
|
{
|
||||||
myGraduatedTrihedron->Release (theCtx.operator->());
|
myGraduatedTrihedron.Release (theCtx.operator->());
|
||||||
myFrameStatsPrs->Release (theCtx.operator->());
|
myFrameStatsPrs.Release (theCtx.operator->());
|
||||||
|
|
||||||
if (!myTextureEnv.IsNull())
|
if (!myTextureEnv.IsNull())
|
||||||
{
|
{
|
||||||
@@ -146,15 +143,15 @@ void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
|
|||||||
myTextureEnv.Nullify();
|
myTextureEnv.Nullify();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!myTextureParams.IsNull())
|
if (myTextureParams != NULL)
|
||||||
{
|
{
|
||||||
myTextureParams->Release (theCtx.operator->());
|
myTextureParams->Release (theCtx.operator->());
|
||||||
}
|
}
|
||||||
if (!myBgGradientArray.IsNull())
|
if (myBgGradientArray != NULL)
|
||||||
{
|
{
|
||||||
myBgGradientArray->Release (theCtx.operator->());
|
myBgGradientArray->Release (theCtx.operator->());
|
||||||
}
|
}
|
||||||
if (!myBgTextureArray.IsNull())
|
if (myBgTextureArray != NULL)
|
||||||
{
|
{
|
||||||
myBgTextureArray->Release (theCtx.operator->());
|
myBgTextureArray->Release (theCtx.operator->());
|
||||||
}
|
}
|
||||||
@@ -336,7 +333,7 @@ void OpenGl_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron&
|
|||||||
myGTrihedronData = theTrihedronData;
|
myGTrihedronData = theTrihedronData;
|
||||||
myGTrihedronData.PtrView = this;
|
myGTrihedronData.PtrView = this;
|
||||||
myGTrihedronData.CubicAxesCallback = SetMinMaxValuesCallback;
|
myGTrihedronData.CubicAxesCallback = SetMinMaxValuesCallback;
|
||||||
myGraduatedTrihedron->SetValues (myGTrihedronData);
|
myGraduatedTrihedron.SetValues (myGTrihedronData);
|
||||||
myToShowGradTrihedron = true;
|
myToShowGradTrihedron = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,7 +344,7 @@ void OpenGl_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron&
|
|||||||
void OpenGl_View::GraduatedTrihedronErase()
|
void OpenGl_View::GraduatedTrihedronErase()
|
||||||
{
|
{
|
||||||
myGTrihedronData.PtrView = NULL;
|
myGTrihedronData.PtrView = NULL;
|
||||||
myGraduatedTrihedron->Release (myWorkspace->GetGlContext().operator->());
|
myGraduatedTrihedron.Release (myWorkspace->GetGlContext().operator->());
|
||||||
myToShowGradTrihedron = false;
|
myToShowGradTrihedron = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,7 +354,7 @@ void OpenGl_View::GraduatedTrihedronErase()
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_View::GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax)
|
void OpenGl_View::GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax)
|
||||||
{
|
{
|
||||||
myGraduatedTrihedron->SetMinMax (theMin, theMax);
|
myGraduatedTrihedron.SetMinMax (theMin, theMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
@@ -297,7 +297,7 @@ public:
|
|||||||
const Quantity_ColorRGBA& BackgroundColor() const { return myBgColor; }
|
const Quantity_ColorRGBA& BackgroundColor() const { return myBgColor; }
|
||||||
|
|
||||||
//! Change graduated trihedron.
|
//! Change graduated trihedron.
|
||||||
const Handle(OpenGl_GraduatedTrihedron)& ChangeGraduatedTrihedron() { return myGraduatedTrihedron; }
|
OpenGl_GraduatedTrihedron& ChangeGraduatedTrihedron() { return myGraduatedTrihedron; }
|
||||||
|
|
||||||
void SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
|
void SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Handle(Graphic3d_TextureEnv)& theTexture);
|
const Handle(Graphic3d_TextureEnv)& theTexture);
|
||||||
@@ -486,8 +486,8 @@ protected:
|
|||||||
//! Is needed for selection of overlapping objects and storage of the current view volume
|
//! Is needed for selection of overlapping objects and storage of the current view volume
|
||||||
OpenGl_BVHTreeSelector myBVHSelector;
|
OpenGl_BVHTreeSelector myBVHSelector;
|
||||||
|
|
||||||
Handle(OpenGl_GraduatedTrihedron) myGraduatedTrihedron;
|
OpenGl_GraduatedTrihedron myGraduatedTrihedron;
|
||||||
Handle(OpenGl_FrameStatsPrs) myFrameStatsPrs;
|
OpenGl_FrameStatsPrs myFrameStatsPrs;
|
||||||
|
|
||||||
Handle(OpenGl_TextureSet) myTextureEnv;
|
Handle(OpenGl_TextureSet) myTextureEnv;
|
||||||
|
|
||||||
@@ -520,9 +520,9 @@ protected: //! @name Rendering properties
|
|||||||
|
|
||||||
protected: //! @name Background parameters
|
protected: //! @name Background parameters
|
||||||
|
|
||||||
Handle(OpenGl_AspectFace) myTextureParams; //!< Stores texture and its parameters for textured background
|
OpenGl_AspectFace* myTextureParams; //!< Stores texture and its parameters for textured background
|
||||||
Handle(OpenGl_BackgroundArray) myBgGradientArray; //!< Primitive array for gradient background
|
OpenGl_BackgroundArray* myBgGradientArray; //!< Primitive array for gradient background
|
||||||
Handle(OpenGl_BackgroundArray) myBgTextureArray; //!< Primitive array for texture background
|
OpenGl_BackgroundArray* myBgTextureArray; //!< Primitive array for texture background
|
||||||
|
|
||||||
protected: //! @name data types related to ray-tracing
|
protected: //! @name data types related to ray-tracing
|
||||||
|
|
||||||
@@ -592,7 +592,10 @@ protected: //! @name data types related to ray-tracing
|
|||||||
|
|
||||||
// images used by ISS mode
|
// images used by ISS mode
|
||||||
OpenGl_RT_uRenderImage,
|
OpenGl_RT_uRenderImage,
|
||||||
|
OpenGl_RT_uTilesImage,
|
||||||
OpenGl_RT_uOffsetImage,
|
OpenGl_RT_uOffsetImage,
|
||||||
|
OpenGl_RT_uTileSize,
|
||||||
|
OpenGl_RT_uVarianceScaleFactor,
|
||||||
|
|
||||||
// maximum radiance value
|
// maximum radiance value
|
||||||
OpenGl_RT_uMaxRadiance,
|
OpenGl_RT_uMaxRadiance,
|
||||||
@@ -603,12 +606,10 @@ protected: //! @name data types related to ray-tracing
|
|||||||
//! Defines OpenGL image samplers.
|
//! Defines OpenGL image samplers.
|
||||||
enum ShaderImageNames
|
enum ShaderImageNames
|
||||||
{
|
{
|
||||||
OpenGl_RT_OutputImageLft = 0,
|
OpenGl_RT_OutputImage = 0,
|
||||||
OpenGl_RT_OutputImageRgh = 1,
|
OpenGl_RT_VisualErrorImage = 1,
|
||||||
OpenGl_RT_VisualErrorImageLft = 2,
|
OpenGl_RT_TileOffsetsImage = 2,
|
||||||
OpenGl_RT_VisualErrorImageRgh = 3,
|
OpenGl_RT_TileSamplesImage = 3
|
||||||
OpenGl_RT_TileOffsetsImageLft = 4,
|
|
||||||
OpenGl_RT_TileOffsetsImageRgh = 5
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Tool class for management of shader sources.
|
//! Tool class for management of shader sources.
|
||||||
@@ -692,17 +693,14 @@ protected: //! @name data types related to ray-tracing
|
|||||||
//! Enables/disables adaptive screen sampling for path tracing.
|
//! Enables/disables adaptive screen sampling for path tracing.
|
||||||
Standard_Boolean AdaptiveScreenSampling;
|
Standard_Boolean AdaptiveScreenSampling;
|
||||||
|
|
||||||
|
//! Enables/disables 1-pass atomic mode for AdaptiveScreenSampling.
|
||||||
|
Standard_Boolean AdaptiveScreenSamplingAtomic;
|
||||||
|
|
||||||
//! Enables/disables environment map for background.
|
//! Enables/disables environment map for background.
|
||||||
Standard_Boolean UseEnvMapForBackground;
|
Standard_Boolean UseEnvMapForBackground;
|
||||||
|
|
||||||
//! Maximum radiance value used for clamping radiance estimation.
|
//! Maximum radiance value used for clamping radiance estimation.
|
||||||
Standard_ShortReal RadianceClampingValue;
|
Standard_ShortReal RadianceClampingValue;
|
||||||
|
|
||||||
//! Number of tiles in X dimension (in adaptive sampling mode).
|
|
||||||
Standard_Integer NbTilesX;
|
|
||||||
|
|
||||||
//! Number of tiles in Y dimension (in adaptive sampling mode).
|
|
||||||
Standard_Integer NbTilesY;
|
|
||||||
|
|
||||||
//! Enables/disables depth-of-field effect (path tracing, perspective camera).
|
//! Enables/disables depth-of-field effect (path tracing, perspective camera).
|
||||||
Standard_Boolean DepthOfField;
|
Standard_Boolean DepthOfField;
|
||||||
@@ -719,10 +717,9 @@ protected: //! @name data types related to ray-tracing
|
|||||||
UseBindlessTextures (Standard_False),
|
UseBindlessTextures (Standard_False),
|
||||||
TwoSidedBsdfModels (Standard_False),
|
TwoSidedBsdfModels (Standard_False),
|
||||||
AdaptiveScreenSampling (Standard_False),
|
AdaptiveScreenSampling (Standard_False),
|
||||||
|
AdaptiveScreenSamplingAtomic (Standard_False),
|
||||||
UseEnvMapForBackground (Standard_False),
|
UseEnvMapForBackground (Standard_False),
|
||||||
RadianceClampingValue (30.0),
|
RadianceClampingValue (30.0),
|
||||||
NbTilesX (16),
|
|
||||||
NbTilesY (16),
|
|
||||||
DepthOfField (Standard_False),
|
DepthOfField (Standard_False),
|
||||||
ToneMappingMethod (Graphic3d_ToneMappingMethod_Disabled) { }
|
ToneMappingMethod (Graphic3d_ToneMappingMethod_Disabled) { }
|
||||||
};
|
};
|
||||||
@@ -776,11 +773,11 @@ protected: //! @name methods related to ray-tracing
|
|||||||
const Handle(OpenGl_Context)& theGlContext);
|
const Handle(OpenGl_Context)& theGlContext);
|
||||||
|
|
||||||
//! Creates ray-tracing material properties.
|
//! Creates ray-tracing material properties.
|
||||||
OpenGl_RaytraceMaterial convertMaterial (const Handle(OpenGl_AspectFace)& theAspect,
|
OpenGl_RaytraceMaterial convertMaterial (const OpenGl_AspectFace* theAspect,
|
||||||
const Handle(OpenGl_Context)& theGlContext);
|
const Handle(OpenGl_Context)& theGlContext);
|
||||||
|
|
||||||
//! Adds OpenGL primitive array to ray-traced scene geometry.
|
//! Adds OpenGL primitive array to ray-traced scene geometry.
|
||||||
Handle(OpenGl_TriangleSet) addRaytracePrimitiveArray (const Handle(OpenGl_PrimitiveArray)& theArray,
|
Handle(OpenGl_TriangleSet) addRaytracePrimitiveArray (const OpenGl_PrimitiveArray* theArray,
|
||||||
const Standard_Integer theMatID,
|
const Standard_Integer theMatID,
|
||||||
const OpenGl_Mat4* theTrans);
|
const OpenGl_Mat4* theTrans);
|
||||||
|
|
||||||
@@ -789,7 +786,7 @@ protected: //! @name methods related to ray-tracing
|
|||||||
const Standard_Integer theMatID,
|
const Standard_Integer theMatID,
|
||||||
const Standard_Integer theCount,
|
const Standard_Integer theCount,
|
||||||
const Standard_Integer theOffset,
|
const Standard_Integer theOffset,
|
||||||
const Handle(OpenGl_PrimitiveArray)& theArray);
|
const OpenGl_PrimitiveArray& theArray);
|
||||||
|
|
||||||
//! Adds OpenGL triangle array to ray-traced scene geometry.
|
//! Adds OpenGL triangle array to ray-traced scene geometry.
|
||||||
Standard_Boolean addRaytraceTriangleArray (OpenGl_TriangleSet& theSet,
|
Standard_Boolean addRaytraceTriangleArray (OpenGl_TriangleSet& theSet,
|
||||||
@@ -854,7 +851,9 @@ protected: //! @name methods related to ray-tracing
|
|||||||
const Handle(OpenGl_ShaderObject)& theFragShader);
|
const Handle(OpenGl_ShaderObject)& theFragShader);
|
||||||
|
|
||||||
//! Initializes OpenGL/GLSL shader programs.
|
//! Initializes OpenGL/GLSL shader programs.
|
||||||
Standard_Boolean initRaytraceResources (const Handle(OpenGl_Context)& theGlContext);
|
Standard_Boolean initRaytraceResources (const Standard_Integer theSizeX,
|
||||||
|
const Standard_Integer theSizeY,
|
||||||
|
const Handle(OpenGl_Context)& theGlContext);
|
||||||
|
|
||||||
//! Releases OpenGL/GLSL shader programs.
|
//! Releases OpenGL/GLSL shader programs.
|
||||||
void releaseRaytraceResources (const Handle(OpenGl_Context)& theGlContext,
|
void releaseRaytraceResources (const Handle(OpenGl_Context)& theGlContext,
|
||||||
@@ -884,7 +883,8 @@ protected: //! @name methods related to ray-tracing
|
|||||||
const int theWinSizeY);
|
const int theWinSizeY);
|
||||||
|
|
||||||
//! Binds ray-trace textures to corresponding texture units.
|
//! Binds ray-trace textures to corresponding texture units.
|
||||||
void bindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext);
|
void bindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext,
|
||||||
|
int theStereoView);
|
||||||
|
|
||||||
//! Unbinds ray-trace textures from corresponding texture unit.
|
//! Unbinds ray-trace textures from corresponding texture unit.
|
||||||
void unbindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext);
|
void unbindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext);
|
||||||
@@ -914,9 +914,13 @@ protected: //! @name methods related to ray-tracing
|
|||||||
Standard_Boolean runPathtrace (const Standard_Integer theSizeX,
|
Standard_Boolean runPathtrace (const Standard_Integer theSizeX,
|
||||||
const Standard_Integer theSizeY,
|
const Standard_Integer theSizeY,
|
||||||
Graphic3d_Camera::Projection theProjection,
|
Graphic3d_Camera::Projection theProjection,
|
||||||
OpenGl_FrameBuffer* theReadDrawFbo,
|
|
||||||
const Handle(OpenGl_Context)& theGlContext);
|
const Handle(OpenGl_Context)& theGlContext);
|
||||||
|
|
||||||
|
//! Runs path tracing (global illumination) kernel.
|
||||||
|
Standard_Boolean runPathtraceOut (Graphic3d_Camera::Projection theProjection,
|
||||||
|
OpenGl_FrameBuffer* theReadDrawFbo,
|
||||||
|
const Handle(OpenGl_Context)& theGlContext);
|
||||||
|
|
||||||
//! Redraws the window using OpenGL/GLSL ray-tracing or path tracing.
|
//! Redraws the window using OpenGL/GLSL ray-tracing or path tracing.
|
||||||
Standard_Boolean raytrace (const Standard_Integer theSizeX,
|
Standard_Boolean raytrace (const Standard_Integer theSizeX,
|
||||||
const Standard_Integer theSizeY,
|
const Standard_Integer theSizeY,
|
||||||
@@ -1010,6 +1014,9 @@ protected: //! @name fields related to ray-tracing
|
|||||||
//! Texture containing offsets of sampled screen tiles (2 textures are used in stereo mode).
|
//! Texture containing offsets of sampled screen tiles (2 textures are used in stereo mode).
|
||||||
//! Used if adaptive screen sampling is activated.
|
//! Used if adaptive screen sampling is activated.
|
||||||
Handle(OpenGl_Texture) myRaytraceTileOffsetsTexture[2];
|
Handle(OpenGl_Texture) myRaytraceTileOffsetsTexture[2];
|
||||||
|
//! Texture containing amount of extra per-tile samples (2 textures are used in stereo mode).
|
||||||
|
//! Used if adaptive screen sampling is activated.
|
||||||
|
Handle(OpenGl_Texture) myRaytraceTileSamplesTexture[2];
|
||||||
|
|
||||||
//! Vertex buffer (VBO) for drawing dummy quad.
|
//! Vertex buffer (VBO) for drawing dummy quad.
|
||||||
OpenGl_VertexBuffer myRaytraceScreenQuad;
|
OpenGl_VertexBuffer myRaytraceScreenQuad;
|
||||||
|
@@ -144,10 +144,11 @@ Standard_Boolean OpenGl_View::updateRaytraceGeometry (const RaytraceUpdateMode
|
|||||||
for (OpenGl_Structure::GroupIterator aGroupIter (aStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
|
for (OpenGl_Structure::GroupIterator aGroupIter (aStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||||
{
|
{
|
||||||
// Extract OpenGL elements from the group (primitives arrays)
|
// Extract OpenGL elements from the group (primitives arrays)
|
||||||
for (OpenGl_ElementNodes::Iterator anElemIterator (aGroupIter.Value()->GetElements()); anElemIterator.More(); anElemIterator.Next())
|
for (const OpenGl_ElementNode* aNode = aGroupIter.Value()->FirstNode(); aNode != NULL; aNode = aNode->next)
|
||||||
{
|
{
|
||||||
Handle(OpenGl_PrimitiveArray) aPrimArray = Handle(OpenGl_PrimitiveArray)::DownCast (anElemIterator.Value());
|
OpenGl_PrimitiveArray* aPrimArray = dynamic_cast<OpenGl_PrimitiveArray*> (aNode->elem);
|
||||||
if (!aPrimArray.IsNull())
|
|
||||||
|
if (aPrimArray != NULL)
|
||||||
{
|
{
|
||||||
anArrayIDs.insert (aPrimArray->GetUID());
|
anArrayIDs.insert (aPrimArray->GetUID());
|
||||||
}
|
}
|
||||||
@@ -343,7 +344,7 @@ void buildTextureTransform (const Handle(Graphic3d_TextureParams)& theParams, BV
|
|||||||
// function : convertMaterial
|
// function : convertMaterial
|
||||||
// purpose : Creates ray-tracing material properties
|
// purpose : Creates ray-tracing material properties
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const Handle(OpenGl_AspectFace)& theAspect,
|
OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const OpenGl_AspectFace* theAspect,
|
||||||
const Handle(OpenGl_Context)& theGlContext)
|
const Handle(OpenGl_Context)& theGlContext)
|
||||||
{
|
{
|
||||||
OpenGl_RaytraceMaterial theMaterial;
|
OpenGl_RaytraceMaterial theMaterial;
|
||||||
@@ -508,7 +509,7 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
|
|||||||
{
|
{
|
||||||
// Get group material
|
// Get group material
|
||||||
OpenGl_RaytraceMaterial aGroupMaterial;
|
OpenGl_RaytraceMaterial aGroupMaterial;
|
||||||
if (!aGroupIter.Value()->AspectFace().IsNull())
|
if (aGroupIter.Value()->AspectFace() != NULL)
|
||||||
{
|
{
|
||||||
aGroupMaterial = convertMaterial (
|
aGroupMaterial = convertMaterial (
|
||||||
aGroupIter.Value()->AspectFace(), theGlContext);
|
aGroupIter.Value()->AspectFace(), theGlContext);
|
||||||
@@ -518,14 +519,14 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
|
|||||||
|
|
||||||
// Use group material if available, otherwise use structure material
|
// Use group material if available, otherwise use structure material
|
||||||
myRaytraceGeometry.Materials.push_back (
|
myRaytraceGeometry.Materials.push_back (
|
||||||
!aGroupIter.Value()->AspectFace().IsNull() ? aGroupMaterial : theStructMat);
|
aGroupIter.Value()->AspectFace() != NULL ? aGroupMaterial : theStructMat);
|
||||||
|
|
||||||
// Add OpenGL elements from group (extract primitives arrays and aspects)
|
// Add OpenGL elements from group (extract primitives arrays and aspects)
|
||||||
for (OpenGl_ElementNodes::Iterator anElemIterator (aGroupIter.Value()->GetElements()); anElemIterator.More(); anElemIterator.Next())
|
for (const OpenGl_ElementNode* aNode = aGroupIter.Value()->FirstNode(); aNode != NULL; aNode = aNode->next)
|
||||||
{
|
{
|
||||||
Handle(OpenGl_AspectFace) anAspect = Handle(OpenGl_AspectFace)::DownCast (anElemIterator.Value());
|
OpenGl_AspectFace* anAspect = dynamic_cast<OpenGl_AspectFace*> (aNode->elem);
|
||||||
|
|
||||||
if (!anAspect.IsNull())
|
if (anAspect != NULL)
|
||||||
{
|
{
|
||||||
aMatID = static_cast<Standard_Integer> (myRaytraceGeometry.Materials.size());
|
aMatID = static_cast<Standard_Integer> (myRaytraceGeometry.Materials.size());
|
||||||
|
|
||||||
@@ -535,9 +536,9 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Handle(OpenGl_PrimitiveArray) aPrimArray = Handle(OpenGl_PrimitiveArray)::DownCast (anElemIterator.Value());
|
OpenGl_PrimitiveArray* aPrimArray = dynamic_cast<OpenGl_PrimitiveArray*> (aNode->elem);
|
||||||
|
|
||||||
if (!aPrimArray.IsNull())
|
if (aPrimArray != NULL)
|
||||||
{
|
{
|
||||||
std::map<Standard_Size, OpenGl_TriangleSet*>::iterator aSetIter = myArrayToTrianglesMap.find (aPrimArray->GetUID());
|
std::map<Standard_Size, OpenGl_TriangleSet*>::iterator aSetIter = myArrayToTrianglesMap.find (aPrimArray->GetUID());
|
||||||
|
|
||||||
@@ -584,7 +585,7 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
|
|||||||
// function : addRaytracePrimitiveArray
|
// function : addRaytracePrimitiveArray
|
||||||
// purpose : Adds OpenGL primitive array to ray-traced scene geometry
|
// purpose : Adds OpenGL primitive array to ray-traced scene geometry
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const Handle(OpenGl_PrimitiveArray)& theArray,
|
Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const OpenGl_PrimitiveArray* theArray,
|
||||||
const Standard_Integer theMaterial,
|
const Standard_Integer theMaterial,
|
||||||
const OpenGl_Mat4* theTransform)
|
const OpenGl_Mat4* theTransform)
|
||||||
{
|
{
|
||||||
@@ -704,7 +705,7 @@ Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const Handle(
|
|||||||
{
|
{
|
||||||
const Standard_Integer aVertNum = aBounds->Bounds[aBound];
|
const Standard_Integer aVertNum = aBounds->Bounds[aBound];
|
||||||
|
|
||||||
if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, aBoundStart, theArray))
|
if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, aBoundStart, *theArray))
|
||||||
{
|
{
|
||||||
aSet.Nullify();
|
aSet.Nullify();
|
||||||
return Handle(OpenGl_TriangleSet)();
|
return Handle(OpenGl_TriangleSet)();
|
||||||
@@ -717,7 +718,7 @@ Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const Handle(
|
|||||||
{
|
{
|
||||||
const Standard_Integer aVertNum = !anIndices.IsNull() ? anIndices->NbElements : anAttribs->NbElements;
|
const Standard_Integer aVertNum = !anIndices.IsNull() ? anIndices->NbElements : anAttribs->NbElements;
|
||||||
|
|
||||||
if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, 0, theArray))
|
if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, 0, *theArray))
|
||||||
{
|
{
|
||||||
aSet.Nullify();
|
aSet.Nullify();
|
||||||
return Handle(OpenGl_TriangleSet)();
|
return Handle(OpenGl_TriangleSet)();
|
||||||
@@ -741,17 +742,17 @@ Standard_Boolean OpenGl_View::addRaytraceVertexIndices (OpenGl_TriangleSet&
|
|||||||
const Standard_Integer theMatID,
|
const Standard_Integer theMatID,
|
||||||
const Standard_Integer theCount,
|
const Standard_Integer theCount,
|
||||||
const Standard_Integer theOffset,
|
const Standard_Integer theOffset,
|
||||||
const Handle(OpenGl_PrimitiveArray)& theArray)
|
const OpenGl_PrimitiveArray& theArray)
|
||||||
{
|
{
|
||||||
switch (theArray->DrawMode())
|
switch (theArray.DrawMode())
|
||||||
{
|
{
|
||||||
case GL_TRIANGLES: return addRaytraceTriangleArray (theSet, theMatID, theCount, theOffset, theArray->Indices());
|
case GL_TRIANGLES: return addRaytraceTriangleArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
|
||||||
case GL_TRIANGLE_FAN: return addRaytraceTriangleFanArray (theSet, theMatID, theCount, theOffset, theArray->Indices());
|
case GL_TRIANGLE_FAN: return addRaytraceTriangleFanArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
|
||||||
case GL_TRIANGLE_STRIP: return addRaytraceTriangleStripArray (theSet, theMatID, theCount, theOffset, theArray->Indices());
|
case GL_TRIANGLE_STRIP: return addRaytraceTriangleStripArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
case GL_QUAD_STRIP: return addRaytraceQuadrangleStripArray (theSet, theMatID, theCount, theOffset, theArray->Indices());
|
case GL_QUAD_STRIP: return addRaytraceQuadrangleStripArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
|
||||||
case GL_QUADS: return addRaytraceQuadrangleArray (theSet, theMatID, theCount, theOffset, theArray->Indices());
|
case GL_QUADS: return addRaytraceQuadrangleArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
|
||||||
case GL_POLYGON: return addRaytracePolygonArray (theSet, theMatID, theCount, theOffset, theArray->Indices());
|
case GL_POLYGON: return addRaytracePolygonArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1135,11 +1136,14 @@ TCollection_AsciiString OpenGl_View::generateShaderPrefix (const Handle(OpenGl_C
|
|||||||
|
|
||||||
if (myRaytraceParameters.AdaptiveScreenSampling) // adaptive screen sampling requested
|
if (myRaytraceParameters.AdaptiveScreenSampling) // adaptive screen sampling requested
|
||||||
{
|
{
|
||||||
// to activate the feature we need OpenGL 4.4 and GL_NV_shader_atomic_float extension
|
if (theGlContext->IsGlGreaterEqual (4, 4))
|
||||||
if (theGlContext->IsGlGreaterEqual (4, 4) && theGlContext->CheckExtension ("GL_NV_shader_atomic_float"))
|
|
||||||
{
|
{
|
||||||
aPrefixString += TCollection_AsciiString ("\n#define ADAPTIVE_SAMPLING") +
|
aPrefixString += TCollection_AsciiString ("\n#define ADAPTIVE_SAMPLING");
|
||||||
TCollection_AsciiString ("\n#define BLOCK_SIZE ") + TCollection_AsciiString (OpenGl_TileSampler::TileSize());
|
if (myRaytraceParameters.AdaptiveScreenSamplingAtomic
|
||||||
|
&& theGlContext->CheckExtension ("GL_NV_shader_atomic_float"))
|
||||||
|
{
|
||||||
|
aPrefixString += TCollection_AsciiString ("\n#define ADAPTIVE_SAMPLING_ATOMIC");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1327,7 +1331,9 @@ Handle(OpenGl_ShaderProgram) OpenGl_View::initProgram (const Handle(OpenGl_Conte
|
|||||||
// function : initRaytraceResources
|
// function : initRaytraceResources
|
||||||
// purpose : Initializes OpenGL/GLSL shader programs
|
// purpose : Initializes OpenGL/GLSL shader programs
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean OpenGl_View::initRaytraceResources (const Handle(OpenGl_Context)& theGlContext)
|
Standard_Boolean OpenGl_View::initRaytraceResources (const Standard_Integer theSizeX,
|
||||||
|
const Standard_Integer theSizeY,
|
||||||
|
const Handle(OpenGl_Context)& theGlContext)
|
||||||
{
|
{
|
||||||
if (myRaytraceInitStatus == OpenGl_RT_FAIL)
|
if (myRaytraceInitStatus == OpenGl_RT_FAIL)
|
||||||
{
|
{
|
||||||
@@ -1371,46 +1377,25 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Handle(OpenGl_Context
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Integer aNbTilesX = 8;
|
|
||||||
Standard_Integer aNbTilesY = 8;
|
|
||||||
|
|
||||||
for (Standard_Integer anIdx = 0; aNbTilesX * aNbTilesY < myRenderParams.NbRayTracingTiles; ++anIdx)
|
|
||||||
{
|
|
||||||
(anIdx % 2 == 0 ? aNbTilesX : aNbTilesY) <<= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myRenderParams.RaytracingDepth != myRaytraceParameters.NbBounces
|
if (myRenderParams.RaytracingDepth != myRaytraceParameters.NbBounces
|
||||||
|| myRenderParams.IsTransparentShadowEnabled != myRaytraceParameters.TransparentShadows
|
|| myRenderParams.IsTransparentShadowEnabled != myRaytraceParameters.TransparentShadows
|
||||||
|| myRenderParams.IsGlobalIlluminationEnabled != myRaytraceParameters.GlobalIllumination
|
|| myRenderParams.IsGlobalIlluminationEnabled != myRaytraceParameters.GlobalIllumination
|
||||||
|| myRenderParams.TwoSidedBsdfModels != myRaytraceParameters.TwoSidedBsdfModels
|
|| myRenderParams.TwoSidedBsdfModels != myRaytraceParameters.TwoSidedBsdfModels
|
||||||
|| myRaytraceGeometry.HasTextures() != myRaytraceParameters.UseBindlessTextures
|
|| myRaytraceGeometry.HasTextures() != myRaytraceParameters.UseBindlessTextures)
|
||||||
|| aNbTilesX != myRaytraceParameters.NbTilesX
|
|
||||||
|| aNbTilesY != myRaytraceParameters.NbTilesY)
|
|
||||||
{
|
{
|
||||||
myRaytraceParameters.NbBounces = myRenderParams.RaytracingDepth;
|
myRaytraceParameters.NbBounces = myRenderParams.RaytracingDepth;
|
||||||
myRaytraceParameters.TransparentShadows = myRenderParams.IsTransparentShadowEnabled;
|
myRaytraceParameters.TransparentShadows = myRenderParams.IsTransparentShadowEnabled;
|
||||||
myRaytraceParameters.GlobalIllumination = myRenderParams.IsGlobalIlluminationEnabled;
|
myRaytraceParameters.GlobalIllumination = myRenderParams.IsGlobalIlluminationEnabled;
|
||||||
myRaytraceParameters.TwoSidedBsdfModels = myRenderParams.TwoSidedBsdfModels;
|
myRaytraceParameters.TwoSidedBsdfModels = myRenderParams.TwoSidedBsdfModels;
|
||||||
myRaytraceParameters.UseBindlessTextures = myRaytraceGeometry.HasTextures();
|
myRaytraceParameters.UseBindlessTextures = myRaytraceGeometry.HasTextures();
|
||||||
|
|
||||||
#ifdef RAY_TRACE_PRINT_INFO
|
|
||||||
if (aNbTilesX != myRaytraceParameters.NbTilesX
|
|
||||||
|| aNbTilesY != myRaytraceParameters.NbTilesY)
|
|
||||||
{
|
|
||||||
std::cout << "Number of tiles X: " << aNbTilesX << "\n";
|
|
||||||
std::cout << "Number of tiles Y: " << aNbTilesY << "\n";
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
myRaytraceParameters.NbTilesX = aNbTilesX;
|
|
||||||
myRaytraceParameters.NbTilesY = aNbTilesY;
|
|
||||||
|
|
||||||
aToRebuildShaders = Standard_True;
|
aToRebuildShaders = Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myRenderParams.AdaptiveScreenSampling != myRaytraceParameters.AdaptiveScreenSampling)
|
if (myRenderParams.AdaptiveScreenSampling != myRaytraceParameters.AdaptiveScreenSampling
|
||||||
|
|| myRenderParams.AdaptiveScreenSamplingAtomic != myRaytraceParameters.AdaptiveScreenSamplingAtomic)
|
||||||
{
|
{
|
||||||
myRaytraceParameters.AdaptiveScreenSampling = myRenderParams.AdaptiveScreenSampling;
|
myRaytraceParameters.AdaptiveScreenSampling = myRenderParams.AdaptiveScreenSampling;
|
||||||
|
myRaytraceParameters.AdaptiveScreenSamplingAtomic = myRenderParams.AdaptiveScreenSamplingAtomic;
|
||||||
if (myRenderParams.AdaptiveScreenSampling) // adaptive sampling was requested
|
if (myRenderParams.AdaptiveScreenSampling) // adaptive sampling was requested
|
||||||
{
|
{
|
||||||
if (!theGlContext->HasRayTracingAdaptiveSampling())
|
if (!theGlContext->HasRayTracingAdaptiveSampling())
|
||||||
@@ -1418,12 +1403,21 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Handle(OpenGl_Context
|
|||||||
// disable the feature if it is not supported
|
// disable the feature if it is not supported
|
||||||
myRaytraceParameters.AdaptiveScreenSampling = myRenderParams.AdaptiveScreenSampling = Standard_False;
|
myRaytraceParameters.AdaptiveScreenSampling = myRenderParams.AdaptiveScreenSampling = Standard_False;
|
||||||
theGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_LOW,
|
theGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_LOW,
|
||||||
"Adaptive sampling not supported (OpenGL 4.4 or GL_NV_shader_atomic_float is missing)");
|
"Adaptive sampling is not supported (OpenGL 4.4 is missing)");
|
||||||
|
}
|
||||||
|
else if (myRaytraceParameters.AdaptiveScreenSamplingAtomic
|
||||||
|
&& !theGlContext->HasRayTracingAdaptiveSamplingAtomic())
|
||||||
|
{
|
||||||
|
// disable the feature if it is not supported
|
||||||
|
myRaytraceParameters.AdaptiveScreenSamplingAtomic = myRenderParams.AdaptiveScreenSamplingAtomic = Standard_False;
|
||||||
|
theGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_LOW,
|
||||||
|
"Atomic adaptive sampling is not supported (GL_NV_shader_atomic_float is missing)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aToRebuildShaders = Standard_True;
|
aToRebuildShaders = Standard_True;
|
||||||
}
|
}
|
||||||
|
myTileSampler.SetSize (myRenderParams, myRaytraceParameters.AdaptiveScreenSampling ? Graphic3d_Vec2i (theSizeX, theSizeY) : Graphic3d_Vec2i (0, 0));
|
||||||
|
|
||||||
const bool toEnableDof = !myCamera->IsOrthographic() && myRaytraceParameters.GlobalIllumination;
|
const bool toEnableDof = !myCamera->IsOrthographic() && myRaytraceParameters.GlobalIllumination;
|
||||||
if (myRaytraceParameters.DepthOfField != toEnableDof)
|
if (myRaytraceParameters.DepthOfField != toEnableDof)
|
||||||
@@ -1456,27 +1450,10 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Handle(OpenGl_Context
|
|||||||
myPostFSAAShaderSource.SetPrefix (aPrefixString);
|
myPostFSAAShaderSource.SetPrefix (aPrefixString);
|
||||||
myOutImageShaderSource.SetPrefix (aPrefixString);
|
myOutImageShaderSource.SetPrefix (aPrefixString);
|
||||||
|
|
||||||
if (!myRaytraceShader->LoadSource (theGlContext, myRaytraceShaderSource.Source())
|
if (!myRaytraceShader->LoadAndCompile (theGlContext, myRaytraceShaderSource.Source())
|
||||||
|| !myPostFSAAShader->LoadSource (theGlContext, myPostFSAAShaderSource.Source())
|
|| !myPostFSAAShader->LoadAndCompile (theGlContext, myPostFSAAShaderSource.Source())
|
||||||
|| !myOutImageShader->LoadSource (theGlContext, myOutImageShaderSource.Source()))
|
|| !myOutImageShader->LoadAndCompile (theGlContext, myOutImageShaderSource.Source()))
|
||||||
{
|
{
|
||||||
return safeFailBack ("Failed to load source into ray-tracing fragment shaders", theGlContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
TCollection_AsciiString aLog;
|
|
||||||
|
|
||||||
if (!myRaytraceShader->Compile (theGlContext)
|
|
||||||
|| !myPostFSAAShader->Compile (theGlContext)
|
|
||||||
|| !myOutImageShader->Compile (theGlContext))
|
|
||||||
{
|
|
||||||
#ifdef RAY_TRACE_PRINT_INFO
|
|
||||||
myRaytraceShader->FetchInfoLog (theGlContext, aLog);
|
|
||||||
|
|
||||||
if (!aLog.IsEmpty())
|
|
||||||
{
|
|
||||||
std::cout << "Failed to compile ray-tracing shader: " << aLog << "\n";
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return safeFailBack ("Failed to compile ray-tracing fragment shaders", theGlContext);
|
return safeFailBack ("Failed to compile ray-tracing fragment shaders", theGlContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1488,14 +1465,6 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Handle(OpenGl_Context
|
|||||||
|| !myPostFSAAProgram->Link (theGlContext)
|
|| !myPostFSAAProgram->Link (theGlContext)
|
||||||
|| !myOutImageProgram->Link (theGlContext))
|
|| !myOutImageProgram->Link (theGlContext))
|
||||||
{
|
{
|
||||||
#ifdef RAY_TRACE_PRINT_INFO
|
|
||||||
myRaytraceProgram->FetchInfoLog (theGlContext, aLog);
|
|
||||||
|
|
||||||
if (!aLog.IsEmpty())
|
|
||||||
{
|
|
||||||
std::cout << "Failed to compile ray-tracing shader: " << aLog << "\n";
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return safeFailBack ("Failed to initialize vertex attributes for ray-tracing program", theGlContext);
|
return safeFailBack ("Failed to initialize vertex attributes for ray-tracing program", theGlContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1771,8 +1740,14 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Handle(OpenGl_Context
|
|||||||
|
|
||||||
myUniformLocations[anIndex][OpenGl_RT_uRenderImage] =
|
myUniformLocations[anIndex][OpenGl_RT_uRenderImage] =
|
||||||
aShaderProgram->GetUniformLocation (theGlContext, "uRenderImage");
|
aShaderProgram->GetUniformLocation (theGlContext, "uRenderImage");
|
||||||
|
myUniformLocations[anIndex][OpenGl_RT_uTilesImage] =
|
||||||
|
aShaderProgram->GetUniformLocation (theGlContext, "uTilesImage");
|
||||||
myUniformLocations[anIndex][OpenGl_RT_uOffsetImage] =
|
myUniformLocations[anIndex][OpenGl_RT_uOffsetImage] =
|
||||||
aShaderProgram->GetUniformLocation (theGlContext, "uOffsetImage");
|
aShaderProgram->GetUniformLocation (theGlContext, "uOffsetImage");
|
||||||
|
myUniformLocations[anIndex][OpenGl_RT_uTileSize] =
|
||||||
|
aShaderProgram->GetUniformLocation (theGlContext, "uTileSize");
|
||||||
|
myUniformLocations[anIndex][OpenGl_RT_uVarianceScaleFactor] =
|
||||||
|
aShaderProgram->GetUniformLocation (theGlContext, "uVarianceScaleFactor");
|
||||||
|
|
||||||
myUniformLocations[anIndex][OpenGl_RT_uBackColorTop] =
|
myUniformLocations[anIndex][OpenGl_RT_uBackColorTop] =
|
||||||
aShaderProgram->GetUniformLocation (theGlContext, "uBackColorTop");
|
aShaderProgram->GetUniformLocation (theGlContext, "uBackColorTop");
|
||||||
@@ -1855,6 +1830,8 @@ void OpenGl_View::releaseRaytraceResources (const Handle(OpenGl_Context)& theGlC
|
|||||||
nullifyResource (theGlContext, myRaytraceTileOffsetsTexture[1]);
|
nullifyResource (theGlContext, myRaytraceTileOffsetsTexture[1]);
|
||||||
nullifyResource (theGlContext, myRaytraceVisualErrorTexture[0]);
|
nullifyResource (theGlContext, myRaytraceVisualErrorTexture[0]);
|
||||||
nullifyResource (theGlContext, myRaytraceVisualErrorTexture[1]);
|
nullifyResource (theGlContext, myRaytraceVisualErrorTexture[1]);
|
||||||
|
nullifyResource (theGlContext, myRaytraceTileSamplesTexture[0]);
|
||||||
|
nullifyResource (theGlContext, myRaytraceTileSamplesTexture[1]);
|
||||||
|
|
||||||
nullifyResource (theGlContext, mySceneNodeInfoTexture);
|
nullifyResource (theGlContext, mySceneNodeInfoTexture);
|
||||||
nullifyResource (theGlContext, mySceneMinPointTexture);
|
nullifyResource (theGlContext, mySceneMinPointTexture);
|
||||||
@@ -1899,107 +1876,91 @@ Standard_Boolean OpenGl_View::updateRaytraceBuffers (const Standard_Integer
|
|||||||
|
|
||||||
if (myRaytraceParameters.AdaptiveScreenSampling)
|
if (myRaytraceParameters.AdaptiveScreenSampling)
|
||||||
{
|
{
|
||||||
const Standard_Integer aSizeX = std::max (myRaytraceParameters.NbTilesX * 64, theSizeX);
|
Graphic3d_Vec2i aMaxViewport = myTileSampler.OffsetTilesViewportMax().cwiseMax (Graphic3d_Vec2i (theSizeX, theSizeY));
|
||||||
const Standard_Integer aSizeY = std::max (myRaytraceParameters.NbTilesY * 64, theSizeY);
|
myRaytraceFBO1[0]->InitLazy (theGlContext, aMaxViewport.x(), aMaxViewport.y(), GL_RGBA32F, myFboDepthFormat);
|
||||||
|
myRaytraceFBO2[0]->InitLazy (theGlContext, aMaxViewport.x(), aMaxViewport.y(), GL_RGBA32F, myFboDepthFormat);
|
||||||
myRaytraceFBO1[0]->InitLazy (theGlContext, aSizeX, aSizeY, GL_RGBA32F, myFboDepthFormat);
|
|
||||||
myRaytraceFBO2[0]->InitLazy (theGlContext, aSizeX, aSizeY, GL_RGBA32F, myFboDepthFormat);
|
|
||||||
|
|
||||||
if (myRaytraceFBO1[1]->IsValid()) // second FBO not needed
|
if (myRaytraceFBO1[1]->IsValid()) // second FBO not needed
|
||||||
{
|
{
|
||||||
myRaytraceFBO1[1]->Release (theGlContext.operator->());
|
myRaytraceFBO1[1]->Release (theGlContext.operator->());
|
||||||
myRaytraceFBO2[1]->Release (theGlContext.operator->());
|
myRaytraceFBO2[1]->Release (theGlContext.operator->());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // non-adaptive mode
|
|
||||||
|
for (int aViewIter = 0; aViewIter < 2; ++aViewIter)
|
||||||
{
|
{
|
||||||
if (myRaytraceFBO1[0]->GetSizeX() != theSizeX
|
if (myRaytraceTileOffsetsTexture[aViewIter].IsNull())
|
||||||
|| myRaytraceFBO1[0]->GetSizeY() != theSizeY)
|
|
||||||
{
|
{
|
||||||
myAccumFrames = 0; // accumulation should be restarted
|
myRaytraceOutputTexture[aViewIter] = new OpenGl_Texture();
|
||||||
|
myRaytraceVisualErrorTexture[aViewIter] = new OpenGl_Texture();
|
||||||
|
myRaytraceTileSamplesTexture[aViewIter] = new OpenGl_Texture();
|
||||||
|
myRaytraceTileOffsetsTexture[aViewIter] = new OpenGl_Texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
myRaytraceFBO1[0]->InitLazy (theGlContext, theSizeX, theSizeY, GL_RGBA32F, myFboDepthFormat);
|
if (aViewIter == 1
|
||||||
myRaytraceFBO2[0]->InitLazy (theGlContext, theSizeX, theSizeY, GL_RGBA32F, myFboDepthFormat);
|
&& myCamera->ProjectionType() != Graphic3d_Camera::Projection_Stereo)
|
||||||
|
|
||||||
// Init second set of buffers for stereographic rendering
|
|
||||||
if (myCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo)
|
|
||||||
{
|
|
||||||
myRaytraceFBO1[1]->InitLazy (theGlContext, theSizeX, theSizeY, GL_RGBA32F, myFboDepthFormat);
|
|
||||||
myRaytraceFBO2[1]->InitLazy (theGlContext, theSizeX, theSizeY, GL_RGBA32F, myFboDepthFormat);
|
|
||||||
}
|
|
||||||
else if (myRaytraceFBO1[1]->IsValid()) // second FBO not needed
|
|
||||||
{
|
{
|
||||||
myRaytraceFBO1[1]->Release (theGlContext.operator->());
|
myRaytraceFBO1[1]->Release (theGlContext.operator->());
|
||||||
myRaytraceFBO2[1]->Release (theGlContext.operator->());
|
myRaytraceFBO2[1]->Release (theGlContext.operator->());
|
||||||
}
|
myRaytraceOutputTexture[1]->Release (theGlContext.operator->());
|
||||||
}
|
|
||||||
|
|
||||||
myTileSampler.SetSize (theSizeX, theSizeY);
|
|
||||||
|
|
||||||
if (myRaytraceTileOffsetsTexture[0].IsNull()
|
|
||||||
|| myRaytraceTileOffsetsTexture[1].IsNull())
|
|
||||||
{
|
|
||||||
myRaytraceOutputTexture[0] = new OpenGl_Texture();
|
|
||||||
myRaytraceOutputTexture[1] = new OpenGl_Texture();
|
|
||||||
|
|
||||||
myRaytraceTileOffsetsTexture[0] = new OpenGl_Texture();
|
|
||||||
myRaytraceTileOffsetsTexture[1] = new OpenGl_Texture();
|
|
||||||
myRaytraceVisualErrorTexture[0] = new OpenGl_Texture();
|
|
||||||
myRaytraceVisualErrorTexture[1] = new OpenGl_Texture();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myRaytraceOutputTexture[0]->SizeX() / 3 != theSizeX
|
|
||||||
|| myRaytraceOutputTexture[0]->SizeY() / 2 != theSizeY)
|
|
||||||
{
|
|
||||||
myAccumFrames = 0;
|
|
||||||
|
|
||||||
// Due to limitations of OpenGL image load-store extension
|
|
||||||
// atomic operations are supported only for single-channel
|
|
||||||
// images, so we define GL_R32F image. It is used as array
|
|
||||||
// of 6D floating point vectors:
|
|
||||||
// 0 - R color channel
|
|
||||||
// 1 - G color channel
|
|
||||||
// 2 - B color channel
|
|
||||||
// 3 - hit time transformed into OpenGL NDC space
|
|
||||||
// 4 - luminance accumulated for odd samples only
|
|
||||||
myRaytraceOutputTexture[0]->InitRectangle (theGlContext,
|
|
||||||
theSizeX * 3, theSizeY * 2, OpenGl_TextureFormat::Create<GLfloat, 1>());
|
|
||||||
|
|
||||||
// workaround for some NVIDIA drivers
|
|
||||||
myRaytraceVisualErrorTexture[0]->Release (theGlContext.operator->());
|
|
||||||
myRaytraceTileOffsetsTexture[0]->Release (theGlContext.operator->());
|
|
||||||
|
|
||||||
myRaytraceVisualErrorTexture[0]->Init (theGlContext,
|
|
||||||
GL_R32I, GL_RED_INTEGER, GL_INT, myTileSampler.NbTilesX(), myTileSampler.NbTilesY(), Graphic3d_TOT_2D);
|
|
||||||
|
|
||||||
myRaytraceTileOffsetsTexture[0]->Init (theGlContext,
|
|
||||||
GL_RG32I, GL_RG_INTEGER, GL_INT, myTileSampler.NbTilesX(), myTileSampler.NbTilesY(), Graphic3d_TOT_2D);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo)
|
|
||||||
{
|
|
||||||
if (myRaytraceOutputTexture[1]->SizeX() / 3 != theSizeX
|
|
||||||
|| myRaytraceOutputTexture[1]->SizeY() / 2 != theSizeY)
|
|
||||||
{
|
|
||||||
myRaytraceOutputTexture[1]->InitRectangle (theGlContext,
|
|
||||||
theSizeX * 3, theSizeY * 2, OpenGl_TextureFormat::Create<GLfloat, 1>());
|
|
||||||
|
|
||||||
myRaytraceVisualErrorTexture[1]->Release (theGlContext.operator->());
|
myRaytraceVisualErrorTexture[1]->Release (theGlContext.operator->());
|
||||||
myRaytraceTileOffsetsTexture[1]->Release (theGlContext.operator->());
|
myRaytraceTileOffsetsTexture[1]->Release (theGlContext.operator->());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
myRaytraceVisualErrorTexture[1]->Init (theGlContext,
|
if (myRaytraceParameters.AdaptiveScreenSampling)
|
||||||
GL_R32I, GL_RED_INTEGER, GL_INT, myTileSampler.NbTilesX(), myTileSampler.NbTilesY(), Graphic3d_TOT_2D);
|
{
|
||||||
|
if (myRaytraceOutputTexture[aViewIter]->SizeX() / 3 == theSizeX
|
||||||
|
&& myRaytraceOutputTexture[aViewIter]->SizeY() / 2 == theSizeY
|
||||||
|
&& myRaytraceVisualErrorTexture[aViewIter]->SizeX() == myTileSampler.NbTilesX()
|
||||||
|
&& myRaytraceVisualErrorTexture[aViewIter]->SizeY() == myTileSampler.NbTilesY())
|
||||||
|
{
|
||||||
|
if (myRaytraceParameters.AdaptiveScreenSamplingAtomic)
|
||||||
|
{
|
||||||
|
continue; // offsets texture is dynamically resized
|
||||||
|
}
|
||||||
|
else if (myRaytraceTileSamplesTexture[aViewIter]->SizeX() == myTileSampler.NbTilesX()
|
||||||
|
&& myRaytraceTileSamplesTexture[aViewIter]->SizeY() == myTileSampler.NbTilesY())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
myRaytraceTileOffsetsTexture[1]->Init (theGlContext,
|
myAccumFrames = 0;
|
||||||
GL_RG32I, GL_RG_INTEGER, GL_INT, myTileSampler.NbTilesX(), myTileSampler.NbTilesY(), Graphic3d_TOT_2D);
|
|
||||||
|
// Due to limitations of OpenGL image load-store extension
|
||||||
|
// atomic operations are supported only for single-channel
|
||||||
|
// images, so we define GL_R32F image. It is used as array
|
||||||
|
// of 6D floating point vectors:
|
||||||
|
// 0 - R color channel
|
||||||
|
// 1 - G color channel
|
||||||
|
// 2 - B color channel
|
||||||
|
// 3 - hit time transformed into OpenGL NDC space
|
||||||
|
// 4 - luminance accumulated for odd samples only
|
||||||
|
myRaytraceOutputTexture[aViewIter]->InitRectangle (theGlContext, theSizeX * 3, theSizeY * 2, OpenGl_TextureFormat::Create<GLfloat, 1>());
|
||||||
|
|
||||||
|
// workaround for some NVIDIA drivers
|
||||||
|
myRaytraceVisualErrorTexture[aViewIter]->Release (theGlContext.operator->());
|
||||||
|
myRaytraceTileSamplesTexture[aViewIter]->Release (theGlContext.operator->());
|
||||||
|
myRaytraceVisualErrorTexture[aViewIter]->Init (theGlContext, GL_R32I, GL_RED_INTEGER, GL_INT,
|
||||||
|
myTileSampler.NbTilesX(), myTileSampler.NbTilesY(), Graphic3d_TOT_2D);
|
||||||
|
if (!myRaytraceParameters.AdaptiveScreenSamplingAtomic)
|
||||||
|
{
|
||||||
|
myRaytraceTileSamplesTexture[aViewIter]->Init (theGlContext, GL_R32I, GL_RED_INTEGER, GL_INT,
|
||||||
|
myTileSampler.NbTilesX(), myTileSampler.NbTilesY(), Graphic3d_TOT_2D);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // non-adaptive mode
|
||||||
|
{
|
||||||
|
if (myRaytraceFBO1[aViewIter]->GetSizeX() != theSizeX
|
||||||
|
|| myRaytraceFBO1[aViewIter]->GetSizeY() != theSizeY)
|
||||||
|
{
|
||||||
|
myAccumFrames = 0; // accumulation should be restarted
|
||||||
|
}
|
||||||
|
|
||||||
|
myRaytraceFBO1[aViewIter]->InitLazy (theGlContext, theSizeX, theSizeY, GL_RGBA32F, myFboDepthFormat);
|
||||||
|
myRaytraceFBO2[aViewIter]->InitLazy (theGlContext, theSizeX, theSizeY, GL_RGBA32F, myFboDepthFormat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
myRaytraceOutputTexture[1]->Release (theGlContext.operator->());
|
|
||||||
}
|
|
||||||
|
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2679,7 +2640,7 @@ Standard_Boolean OpenGl_View::setUniformState (const Standard_Integer the
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set background colors (only gradient background supported)
|
// Set background colors (only gradient background supported)
|
||||||
if (!myBgGradientArray.IsNull() && myBgGradientArray->IsDefined())
|
if (myBgGradientArray != NULL && myBgGradientArray->IsDefined())
|
||||||
{
|
{
|
||||||
theProgram->SetUniform (theGlContext,
|
theProgram->SetUniform (theGlContext,
|
||||||
myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], myBgGradientArray->GradientColor (0));
|
myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], myBgGradientArray->GradientColor (0));
|
||||||
@@ -2745,25 +2706,30 @@ Standard_Boolean OpenGl_View::setUniformState (const Standard_Integer the
|
|||||||
// function : bindRaytraceTextures
|
// function : bindRaytraceTextures
|
||||||
// purpose : Binds ray-trace textures to corresponding texture units
|
// purpose : Binds ray-trace textures to corresponding texture units
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_View::bindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext)
|
void OpenGl_View::bindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext,
|
||||||
|
int theStereoView)
|
||||||
{
|
{
|
||||||
if (myRaytraceParameters.AdaptiveScreenSampling)
|
if (myRaytraceParameters.AdaptiveScreenSampling
|
||||||
|
&& myRaytraceParameters.GlobalIllumination)
|
||||||
{
|
{
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
theGlContext->core42->glBindImageTexture (OpenGl_RT_OutputImageLft,
|
theGlContext->core42->glBindImageTexture (OpenGl_RT_OutputImage,
|
||||||
myRaytraceOutputTexture[0]->TextureId(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32F);
|
myRaytraceOutputTexture[theStereoView]->TextureId(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32F);
|
||||||
theGlContext->core42->glBindImageTexture (OpenGl_RT_OutputImageRgh,
|
theGlContext->core42->glBindImageTexture (OpenGl_RT_VisualErrorImage,
|
||||||
myRaytraceOutputTexture[1]->TextureId(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32F);
|
myRaytraceVisualErrorTexture[theStereoView]->TextureId(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32I);
|
||||||
|
if (myRaytraceParameters.AdaptiveScreenSamplingAtomic)
|
||||||
theGlContext->core42->glBindImageTexture (OpenGl_RT_VisualErrorImageLft,
|
{
|
||||||
myRaytraceVisualErrorTexture[0]->TextureId(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32I);
|
theGlContext->core42->glBindImageTexture (OpenGl_RT_TileOffsetsImage,
|
||||||
theGlContext->core42->glBindImageTexture (OpenGl_RT_VisualErrorImageRgh,
|
myRaytraceTileOffsetsTexture[theStereoView]->TextureId(), 0, GL_TRUE, 0, GL_READ_ONLY, GL_RG32I);
|
||||||
myRaytraceVisualErrorTexture[1]->TextureId(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32I);
|
}
|
||||||
theGlContext->core42->glBindImageTexture (OpenGl_RT_TileOffsetsImageLft,
|
else
|
||||||
myRaytraceTileOffsetsTexture[0]->TextureId(), 0, GL_TRUE, 0, GL_READ_ONLY, GL_RG32I);
|
{
|
||||||
theGlContext->core42->glBindImageTexture (OpenGl_RT_TileOffsetsImageRgh,
|
theGlContext->core42->glBindImageTexture (OpenGl_RT_TileSamplesImage,
|
||||||
myRaytraceTileOffsetsTexture[1]->TextureId(), 0, GL_TRUE, 0, GL_READ_ONLY, GL_RG32I);
|
myRaytraceTileSamplesTexture[theStereoView]->TextureId(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32I);
|
||||||
#endif
|
}
|
||||||
|
#else
|
||||||
|
(void )theStereoView;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!myTextureEnv.IsNull()
|
if (!myTextureEnv.IsNull()
|
||||||
@@ -2825,7 +2791,8 @@ Standard_Boolean OpenGl_View::runRaytraceShaders (const Standard_Integer
|
|||||||
|
|
||||||
if (myRaytraceParameters.GlobalIllumination) // path tracing
|
if (myRaytraceParameters.GlobalIllumination) // path tracing
|
||||||
{
|
{
|
||||||
aResult &= runPathtrace (theSizeX, theSizeY, theProjection, theReadDrawFbo, theGlContext);
|
aResult &= runPathtrace (theSizeX, theSizeY, theProjection, theGlContext);
|
||||||
|
aResult &= runPathtraceOut (theProjection, theReadDrawFbo, theGlContext);
|
||||||
}
|
}
|
||||||
else // Whitted-style ray-tracing
|
else // Whitted-style ray-tracing
|
||||||
{
|
{
|
||||||
@@ -2847,13 +2814,9 @@ Standard_Boolean OpenGl_View::runRaytrace (const Standard_Integer theSize
|
|||||||
{
|
{
|
||||||
Standard_Boolean aResult = Standard_True;
|
Standard_Boolean aResult = Standard_True;
|
||||||
|
|
||||||
bindRaytraceTextures (theGlContext);
|
|
||||||
|
|
||||||
Handle(OpenGl_FrameBuffer) aRenderImageFramebuffer;
|
|
||||||
Handle(OpenGl_FrameBuffer) aDepthSourceFramebuffer;
|
|
||||||
|
|
||||||
// Choose proper set of frame buffers for stereo rendering
|
// Choose proper set of frame buffers for stereo rendering
|
||||||
const Standard_Integer aFBOIdx (theProjection == Graphic3d_Camera::Projection_MonoRightEye);
|
const Standard_Integer aFBOIdx = (theProjection == Graphic3d_Camera::Projection_MonoRightEye) ? 1 : 0;
|
||||||
|
bindRaytraceTextures (theGlContext, aFBOIdx);
|
||||||
|
|
||||||
if (myRenderParams.IsAntialiasingEnabled) // if second FSAA pass is used
|
if (myRenderParams.IsAntialiasingEnabled) // if second FSAA pass is used
|
||||||
{
|
{
|
||||||
@@ -2923,8 +2886,8 @@ Standard_Boolean OpenGl_View::runRaytrace (const Standard_Integer theSize
|
|||||||
aFramebuffer->ColorTexture()->Bind (theGlContext, OpenGl_RT_FsaaInputTexture);
|
aFramebuffer->ColorTexture()->Bind (theGlContext, OpenGl_RT_FsaaInputTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
aRenderImageFramebuffer = myRaytraceFBO2[aFBOIdx];
|
const Handle(OpenGl_FrameBuffer)& aRenderImageFramebuffer = myRaytraceFBO2[aFBOIdx];
|
||||||
aDepthSourceFramebuffer = myRaytraceFBO1[aFBOIdx];
|
const Handle(OpenGl_FrameBuffer)& aDepthSourceFramebuffer = myRaytraceFBO1[aFBOIdx];
|
||||||
|
|
||||||
glEnable (GL_DEPTH_TEST);
|
glEnable (GL_DEPTH_TEST);
|
||||||
|
|
||||||
@@ -2964,11 +2927,8 @@ Standard_Boolean OpenGl_View::runRaytrace (const Standard_Integer theSize
|
|||||||
Standard_Boolean OpenGl_View::runPathtrace (const Standard_Integer theSizeX,
|
Standard_Boolean OpenGl_View::runPathtrace (const Standard_Integer theSizeX,
|
||||||
const Standard_Integer theSizeY,
|
const Standard_Integer theSizeY,
|
||||||
const Graphic3d_Camera::Projection theProjection,
|
const Graphic3d_Camera::Projection theProjection,
|
||||||
OpenGl_FrameBuffer* theReadDrawFbo,
|
|
||||||
const Handle(OpenGl_Context)& theGlContext)
|
const Handle(OpenGl_Context)& theGlContext)
|
||||||
{
|
{
|
||||||
Standard_Boolean aResult = Standard_True;
|
|
||||||
|
|
||||||
if (myToUpdateEnvironmentMap) // check whether the map was changed
|
if (myToUpdateEnvironmentMap) // check whether the map was changed
|
||||||
{
|
{
|
||||||
myAccumFrames = myToUpdateEnvironmentMap = 0;
|
myAccumFrames = myToUpdateEnvironmentMap = 0;
|
||||||
@@ -2977,15 +2937,13 @@ Standard_Boolean OpenGl_View::runPathtrace (const Standard_Integer
|
|||||||
if (myRenderParams.CameraApertureRadius != myPrevCameraApertureRadius
|
if (myRenderParams.CameraApertureRadius != myPrevCameraApertureRadius
|
||||||
|| myRenderParams.CameraFocalPlaneDist != myPrevCameraFocalPlaneDist)
|
|| myRenderParams.CameraFocalPlaneDist != myPrevCameraFocalPlaneDist)
|
||||||
{
|
{
|
||||||
|
|
||||||
myPrevCameraApertureRadius = myRenderParams.CameraApertureRadius;
|
myPrevCameraApertureRadius = myRenderParams.CameraApertureRadius;
|
||||||
myPrevCameraFocalPlaneDist = myRenderParams.CameraFocalPlaneDist;
|
myPrevCameraFocalPlaneDist = myRenderParams.CameraFocalPlaneDist;
|
||||||
|
|
||||||
myAccumFrames = 0;
|
myAccumFrames = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choose proper set of frame buffers for stereo rendering
|
// Choose proper set of frame buffers for stereo rendering
|
||||||
const Standard_Integer aFBOIdx (theProjection == Graphic3d_Camera::Projection_MonoRightEye);
|
const Standard_Integer aFBOIdx = (theProjection == Graphic3d_Camera::Projection_MonoRightEye) ? 1 : 0;
|
||||||
|
|
||||||
if (myRaytraceParameters.AdaptiveScreenSampling)
|
if (myRaytraceParameters.AdaptiveScreenSampling)
|
||||||
{
|
{
|
||||||
@@ -2994,106 +2952,120 @@ Standard_Boolean OpenGl_View::runPathtrace (const Standard_Integer
|
|||||||
myTileSampler.Reset(); // reset tile sampler to its initial state
|
myTileSampler.Reset(); // reset tile sampler to its initial state
|
||||||
|
|
||||||
// Adaptive sampling is starting at the second frame
|
// Adaptive sampling is starting at the second frame
|
||||||
myTileSampler.Upload (theGlContext,
|
if (myRaytraceParameters.AdaptiveScreenSamplingAtomic)
|
||||||
myRaytraceTileOffsetsTexture[aFBOIdx],
|
{
|
||||||
myRaytraceParameters.NbTilesX,
|
myTileSampler.UploadOffsets (theGlContext, myRaytraceTileOffsetsTexture[aFBOIdx], false);
|
||||||
myRaytraceParameters.NbTilesY,
|
}
|
||||||
false);
|
else
|
||||||
}
|
{
|
||||||
}
|
myTileSampler.UploadSamples (theGlContext, myRaytraceTileSamplesTexture[aFBOIdx], false);
|
||||||
|
}
|
||||||
|
|
||||||
bindRaytraceTextures (theGlContext);
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
|
|
||||||
Handle(OpenGl_FrameBuffer) aRenderImageFramebuffer;
|
|
||||||
Handle(OpenGl_FrameBuffer) aDepthSourceFramebuffer;
|
|
||||||
Handle(OpenGl_FrameBuffer) anAccumImageFramebuffer;
|
|
||||||
|
|
||||||
const Standard_Integer anImageId = (aFBOIdx != 0)
|
|
||||||
? OpenGl_RT_OutputImageRgh
|
|
||||||
: OpenGl_RT_OutputImageLft;
|
|
||||||
|
|
||||||
const Standard_Integer anErrorId = (aFBOIdx != 0)
|
|
||||||
? OpenGl_RT_VisualErrorImageRgh
|
|
||||||
: OpenGl_RT_VisualErrorImageLft;
|
|
||||||
|
|
||||||
const Standard_Integer anOffsetId = (aFBOIdx != 0)
|
|
||||||
? OpenGl_RT_TileOffsetsImageRgh
|
|
||||||
: OpenGl_RT_TileOffsetsImageLft;
|
|
||||||
|
|
||||||
aRenderImageFramebuffer = myAccumFrames % 2 ? myRaytraceFBO1[aFBOIdx] : myRaytraceFBO2[aFBOIdx];
|
|
||||||
anAccumImageFramebuffer = myAccumFrames % 2 ? myRaytraceFBO2[aFBOIdx] : myRaytraceFBO1[aFBOIdx];
|
|
||||||
|
|
||||||
aDepthSourceFramebuffer = aRenderImageFramebuffer;
|
|
||||||
|
|
||||||
anAccumImageFramebuffer->ColorTexture()->Bind (theGlContext, OpenGl_RT_PrevAccumTexture);
|
|
||||||
|
|
||||||
aRenderImageFramebuffer->BindBuffer (theGlContext);
|
|
||||||
|
|
||||||
if (myAccumFrames == 0)
|
|
||||||
{
|
|
||||||
myRNG.SetSeed(); // start RNG from beginning
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear adaptive screen sampling images
|
|
||||||
if (myRaytraceParameters.AdaptiveScreenSampling)
|
|
||||||
{
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
|
||||||
if (myAccumFrames == 0 || (myAccumFrames == 1 && myCamera->IsStereo()))
|
|
||||||
{
|
|
||||||
theGlContext->core44->glClearTexImage (myRaytraceOutputTexture[aFBOIdx]->TextureId(), 0, GL_RED, GL_FLOAT, NULL);
|
theGlContext->core44->glClearTexImage (myRaytraceOutputTexture[aFBOIdx]->TextureId(), 0, GL_RED, GL_FLOAT, NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear adaptive screen sampling images
|
||||||
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
theGlContext->core44->glClearTexImage (myRaytraceVisualErrorTexture[aFBOIdx]->TextureId(), 0, GL_RED_INTEGER, GL_INT, NULL);
|
theGlContext->core44->glClearTexImage (myRaytraceVisualErrorTexture[aFBOIdx]->TextureId(), 0, GL_RED_INTEGER, GL_INT, NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set frame accumulation weight
|
bindRaytraceTextures (theGlContext, aFBOIdx);
|
||||||
myRaytraceProgram->SetUniform (theGlContext,
|
|
||||||
myUniformLocations[0][OpenGl_RT_uAccumSamples], myAccumFrames);
|
|
||||||
|
|
||||||
// Set random number generator seed
|
const Handle(OpenGl_FrameBuffer)& anAccumImageFramebuffer = myAccumFrames % 2 ? myRaytraceFBO2[aFBOIdx] : myRaytraceFBO1[aFBOIdx];
|
||||||
myRaytraceProgram->SetUniform (theGlContext,
|
anAccumImageFramebuffer->ColorTexture()->Bind (theGlContext, OpenGl_RT_PrevAccumTexture);
|
||||||
myUniformLocations[0][OpenGl_RT_uFrameRndSeed], static_cast<Standard_Integer> (myRNG.NextInt() >> 2));
|
|
||||||
|
// Set frame accumulation weight
|
||||||
|
myRaytraceProgram->SetUniform (theGlContext, myUniformLocations[0][OpenGl_RT_uAccumSamples], myAccumFrames);
|
||||||
|
|
||||||
// Set image uniforms for render program
|
// Set image uniforms for render program
|
||||||
myRaytraceProgram->SetUniform (theGlContext,
|
if (myRaytraceParameters.AdaptiveScreenSampling)
|
||||||
myUniformLocations[0][OpenGl_RT_uRenderImage], anImageId);
|
|
||||||
myRaytraceProgram->SetUniform (theGlContext,
|
|
||||||
myUniformLocations[0][OpenGl_RT_uOffsetImage], anOffsetId);
|
|
||||||
|
|
||||||
glDisable (GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
if (myRaytraceParameters.AdaptiveScreenSampling
|
|
||||||
&& ((myAccumFrames > 0 && !myCamera->IsStereo()) || myAccumFrames > 1))
|
|
||||||
{
|
{
|
||||||
glViewport (0,
|
myRaytraceProgram->SetUniform (theGlContext, myUniformLocations[0][OpenGl_RT_uRenderImage], OpenGl_RT_OutputImage);
|
||||||
0,
|
myRaytraceProgram->SetUniform (theGlContext, myUniformLocations[0][OpenGl_RT_uTilesImage], OpenGl_RT_TileSamplesImage);
|
||||||
myTileSampler.TileSize() * myRaytraceParameters.NbTilesX,
|
myRaytraceProgram->SetUniform (theGlContext, myUniformLocations[0][OpenGl_RT_uOffsetImage], OpenGl_RT_TileOffsetsImage);
|
||||||
myTileSampler.TileSize() * myRaytraceParameters.NbTilesY);
|
myRaytraceProgram->SetUniform (theGlContext, myUniformLocations[0][OpenGl_RT_uTileSize], myTileSampler.TileSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
const Handle(OpenGl_FrameBuffer)& aRenderImageFramebuffer = myAccumFrames % 2 ? myRaytraceFBO1[aFBOIdx] : myRaytraceFBO2[aFBOIdx];
|
||||||
|
aRenderImageFramebuffer->BindBuffer (theGlContext);
|
||||||
|
if (myRaytraceParameters.AdaptiveScreenSampling
|
||||||
|
&& myRaytraceParameters.AdaptiveScreenSamplingAtomic)
|
||||||
|
{
|
||||||
|
// extend viewport here, so that tiles at boundaries (cut tile size by target rendering viewport)
|
||||||
|
// redirected to inner tiles (full tile size) are drawn entirely
|
||||||
|
const Graphic3d_Vec2i anOffsetViewport = myTileSampler.OffsetTilesViewport (myAccumFrames > 1); // shrunk offsets texture will be uploaded since 3rd frame
|
||||||
|
glViewport (0, 0, anOffsetViewport.x(), anOffsetViewport.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate for the given RNG seed
|
// Generate for the given RNG seed
|
||||||
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
|
glDisable (GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
// Adaptive Screen Sampling computes the same overall amount of samples per frame redraw as normal Path Tracing,
|
||||||
|
// but distributes them unequally across pixels (grouped in tiles), so that some pixels do not receive new samples at all.
|
||||||
|
//
|
||||||
|
// Offsets map (redirecting currently rendered tile to another tile) allows performing Adaptive Screen Sampling in single pass,
|
||||||
|
// but current implementation relies on atomic float operations (AdaptiveScreenSamplingAtomic) for this.
|
||||||
|
// So that when atomic floats are not supported by GPU, multi-pass rendering is used instead.
|
||||||
|
//
|
||||||
|
// Single-pass rendering is more optimal due to smaller amount of draw calls,
|
||||||
|
// memory synchronization barriers, discarding most of the fragments and bad parallelization in case of very small amount of tiles requiring more samples.
|
||||||
|
// However, atomic operations on float values still produces different result (close, but not bit exact) making non-regression testing not robust.
|
||||||
|
// It should be possible following single-pass rendering approach but using extra accumulation buffer and resolving pass as possible improvement.
|
||||||
|
const int aNbPasses = myRaytraceParameters.AdaptiveScreenSampling
|
||||||
|
&& !myRaytraceParameters.AdaptiveScreenSamplingAtomic
|
||||||
|
? myTileSampler.MaxTileSamples()
|
||||||
|
: 1;
|
||||||
|
if (myAccumFrames == 0)
|
||||||
|
{
|
||||||
|
myRNG.SetSeed(); // start RNG from beginning
|
||||||
|
}
|
||||||
|
for (int aPassIter = 0; aPassIter < aNbPasses; ++aPassIter)
|
||||||
|
{
|
||||||
|
myRaytraceProgram->SetUniform (theGlContext, myUniformLocations[0][OpenGl_RT_uFrameRndSeed], static_cast<Standard_Integer> (myRNG.NextInt() >> 2));
|
||||||
|
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
|
||||||
|
if (myRaytraceParameters.AdaptiveScreenSampling)
|
||||||
|
{
|
||||||
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
|
theGlContext->core44->glMemoryBarrier (GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aRenderImageFramebuffer->UnbindBuffer (theGlContext);
|
||||||
|
|
||||||
if (myRaytraceParameters.AdaptiveScreenSampling
|
if (myRaytraceParameters.AdaptiveScreenSampling
|
||||||
&& ((myAccumFrames > 0 && !myCamera->IsStereo()) || myAccumFrames > 1))
|
&& myRaytraceParameters.AdaptiveScreenSamplingAtomic)
|
||||||
{
|
{
|
||||||
glViewport (0,
|
glViewport (0, 0, theSizeX, theSizeY);
|
||||||
0,
|
|
||||||
theSizeX,
|
|
||||||
theSizeY);
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : runPathtraceOut
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
Standard_Boolean OpenGl_View::runPathtraceOut (const Graphic3d_Camera::Projection theProjection,
|
||||||
|
OpenGl_FrameBuffer* theReadDrawFbo,
|
||||||
|
const Handle(OpenGl_Context)& theGlContext)
|
||||||
|
{
|
||||||
// Output accumulated path traced image
|
// Output accumulated path traced image
|
||||||
theGlContext->BindProgram (myOutImageProgram);
|
theGlContext->BindProgram (myOutImageProgram);
|
||||||
|
|
||||||
|
// Choose proper set of frame buffers for stereo rendering
|
||||||
|
const Standard_Integer aFBOIdx = (theProjection == Graphic3d_Camera::Projection_MonoRightEye) ? 1 : 0;
|
||||||
|
|
||||||
if (myRaytraceParameters.AdaptiveScreenSampling)
|
if (myRaytraceParameters.AdaptiveScreenSampling)
|
||||||
{
|
{
|
||||||
// Set uniforms for display program
|
// Set uniforms for display program
|
||||||
myOutImageProgram->SetUniform (theGlContext, "uRenderImage", anImageId);
|
myOutImageProgram->SetUniform (theGlContext, "uRenderImage", OpenGl_RT_OutputImage);
|
||||||
myOutImageProgram->SetUniform (theGlContext, "uAccumFrames", myAccumFrames);
|
myOutImageProgram->SetUniform (theGlContext, "uAccumFrames", myAccumFrames);
|
||||||
myOutImageProgram->SetUniform (theGlContext, "uVarianceImage", anErrorId);
|
myOutImageProgram->SetUniform (theGlContext, "uVarianceImage", OpenGl_RT_VisualErrorImage);
|
||||||
myOutImageProgram->SetUniform (theGlContext, "uDebugAdaptive", myRenderParams.ShowSamplingTiles ? 1 : 0);
|
myOutImageProgram->SetUniform (theGlContext, "uDebugAdaptive", myRenderParams.ShowSamplingTiles ? 1 : 0);
|
||||||
|
myOutImageProgram->SetUniform (theGlContext, "uTileSize", myTileSampler.TileSize());
|
||||||
|
myOutImageProgram->SetUniform (theGlContext, "uVarianceScaleFactor", myTileSampler.VarianceScaleFactor());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myRaytraceParameters.GlobalIllumination)
|
if (myRaytraceParameters.GlobalIllumination)
|
||||||
@@ -3113,40 +3085,33 @@ Standard_Boolean OpenGl_View::runPathtrace (const Standard_Integer
|
|||||||
{
|
{
|
||||||
theReadDrawFbo->BindBuffer (theGlContext);
|
theReadDrawFbo->BindBuffer (theGlContext);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
aRenderImageFramebuffer->UnbindBuffer (theGlContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const Handle(OpenGl_FrameBuffer)& aRenderImageFramebuffer = myAccumFrames % 2 ? myRaytraceFBO1[aFBOIdx] : myRaytraceFBO2[aFBOIdx];
|
||||||
aRenderImageFramebuffer->ColorTexture()->Bind (theGlContext, OpenGl_RT_PrevAccumTexture);
|
aRenderImageFramebuffer->ColorTexture()->Bind (theGlContext, OpenGl_RT_PrevAccumTexture);
|
||||||
|
|
||||||
glEnable (GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
// Copy accumulated image with correct depth values
|
// Copy accumulated image with correct depth values
|
||||||
|
glEnable (GL_DEPTH_TEST);
|
||||||
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
|
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
|
||||||
|
|
||||||
aRenderImageFramebuffer->ColorTexture()->Unbind (theGlContext, OpenGl_RT_PrevAccumTexture);
|
aRenderImageFramebuffer->ColorTexture()->Unbind (theGlContext, OpenGl_RT_PrevAccumTexture);
|
||||||
|
|
||||||
if (myRaytraceParameters.AdaptiveScreenSampling)
|
if (myRaytraceParameters.AdaptiveScreenSampling)
|
||||||
{
|
{
|
||||||
myRaytraceVisualErrorTexture[aFBOIdx]->Bind (theGlContext);
|
// Download visual error map from the GPU and build adjusted tile offsets for optimal image sampling
|
||||||
|
myTileSampler.GrabVarianceMap (theGlContext, myRaytraceVisualErrorTexture[aFBOIdx]);
|
||||||
// Download visual error map from the GPU and build
|
if (myRaytraceParameters.AdaptiveScreenSamplingAtomic)
|
||||||
// adjusted tile offsets for optimal image sampling
|
{
|
||||||
myTileSampler.GrabVarianceMap (theGlContext);
|
myTileSampler.UploadOffsets (theGlContext, myRaytraceTileOffsetsTexture[aFBOIdx], myAccumFrames != 0);
|
||||||
|
}
|
||||||
myTileSampler.Upload (theGlContext,
|
else
|
||||||
myRaytraceTileOffsetsTexture[aFBOIdx],
|
{
|
||||||
myRaytraceParameters.NbTilesX,
|
myTileSampler.UploadSamples (theGlContext, myRaytraceTileSamplesTexture[aFBOIdx], myAccumFrames != 0);
|
||||||
myRaytraceParameters.NbTilesY,
|
}
|
||||||
myAccumFrames > 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unbindRaytraceTextures (theGlContext);
|
unbindRaytraceTextures (theGlContext);
|
||||||
|
|
||||||
theGlContext->BindProgram (NULL);
|
theGlContext->BindProgram (NULL);
|
||||||
|
return true;
|
||||||
return aResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -3159,7 +3124,7 @@ Standard_Boolean OpenGl_View::raytrace (const Standard_Integer theSizeX,
|
|||||||
OpenGl_FrameBuffer* theReadDrawFbo,
|
OpenGl_FrameBuffer* theReadDrawFbo,
|
||||||
const Handle(OpenGl_Context)& theGlContext)
|
const Handle(OpenGl_Context)& theGlContext)
|
||||||
{
|
{
|
||||||
if (!initRaytraceResources (theGlContext))
|
if (!initRaytraceResources (theSizeX, theSizeY, theGlContext))
|
||||||
{
|
{
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
@@ -125,9 +125,7 @@ void OpenGl_View::drawBackground (const Handle(OpenGl_Workspace)& theWorkspace)
|
|||||||
{
|
{
|
||||||
aCtx->core11fwd->glDisable (GL_BLEND);
|
aCtx->core11fwd->glDisable (GL_BLEND);
|
||||||
|
|
||||||
const Handle(OpenGl_AspectFace) anOldAspectFace = theWorkspace->AspectFace();
|
const OpenGl_AspectFace* anOldAspectFace = theWorkspace->SetAspectFace (myTextureParams);
|
||||||
theWorkspace->SetAspectFace (myTextureParams);
|
|
||||||
|
|
||||||
myBgTextureArray->Render (theWorkspace);
|
myBgTextureArray->Render (theWorkspace);
|
||||||
theWorkspace->SetAspectFace (anOldAspectFace);
|
theWorkspace->SetAspectFace (anOldAspectFace);
|
||||||
}
|
}
|
||||||
@@ -169,6 +167,7 @@ void OpenGl_View::Redraw()
|
|||||||
Graphic3d_Camera::Projection aProjectType = myCamera->ProjectionType();
|
Graphic3d_Camera::Projection aProjectType = myCamera->ProjectionType();
|
||||||
Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext();
|
Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext();
|
||||||
aCtx->FrameStats()->FrameStart (myWorkspace->View(), false);
|
aCtx->FrameStats()->FrameStart (myWorkspace->View(), false);
|
||||||
|
aCtx->SetLineFeather (myRenderParams.LineFeather);
|
||||||
|
|
||||||
// release pending GL resources
|
// release pending GL resources
|
||||||
aCtx->ReleaseDelayed();
|
aCtx->ReleaseDelayed();
|
||||||
@@ -181,10 +180,19 @@ void OpenGl_View::Redraw()
|
|||||||
&& !aCtx->caps->buffersNoSwap
|
&& !aCtx->caps->buffersNoSwap
|
||||||
&& aFrameBuffer == NULL;
|
&& aFrameBuffer == NULL;
|
||||||
|
|
||||||
Standard_Integer aSizeX = aFrameBuffer != NULL ? aFrameBuffer->GetVPSizeX() : myWindow->Width();
|
const Standard_Integer aSizeX = aFrameBuffer != NULL ? aFrameBuffer->GetVPSizeX() : myWindow->Width();
|
||||||
Standard_Integer aSizeY = aFrameBuffer != NULL ? aFrameBuffer->GetVPSizeY() : myWindow->Height();
|
const Standard_Integer aSizeY = aFrameBuffer != NULL ? aFrameBuffer->GetVPSizeY() : myWindow->Height();
|
||||||
Standard_Integer aRendSizeX = Standard_Integer(myRenderParams.RenderResolutionScale * aSizeX + 0.5f);
|
const Standard_Integer aRendSizeX = Standard_Integer(myRenderParams.RenderResolutionScale * aSizeX + 0.5f);
|
||||||
Standard_Integer aRendSizeY = Standard_Integer(myRenderParams.RenderResolutionScale * aSizeY + 0.5f);
|
const Standard_Integer aRendSizeY = Standard_Integer(myRenderParams.RenderResolutionScale * aSizeY + 0.5f);
|
||||||
|
if (aSizeX < 1
|
||||||
|
|| aSizeY < 1
|
||||||
|
|| aRendSizeX < 1
|
||||||
|
|| aRendSizeY < 1)
|
||||||
|
{
|
||||||
|
myBackBufferRestored = Standard_False;
|
||||||
|
myIsImmediateDrawn = Standard_False;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// determine multisampling parameters
|
// determine multisampling parameters
|
||||||
Standard_Integer aNbSamples = !myToDisableMSAA && aSizeX == aRendSizeX
|
Standard_Integer aNbSamples = !myToDisableMSAA && aSizeX == aRendSizeX
|
||||||
@@ -871,7 +879,9 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
|
|||||||
// ==================================
|
// ==================================
|
||||||
|
|
||||||
const Handle(OpenGl_Context)& aContext = myWorkspace->GetGlContext();
|
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)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
// Disable current clipping planes
|
// Disable current clipping planes
|
||||||
@@ -1036,6 +1046,7 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
myWorkspace->ResetAppliedAspect();
|
myWorkspace->ResetAppliedAspect();
|
||||||
|
aContext->SetAllowSampleAlphaToCoverage (false);
|
||||||
aContext->SetSampleAlphaToCoverage (false);
|
aContext->SetSampleAlphaToCoverage (false);
|
||||||
|
|
||||||
// reset FFP state for safety
|
// reset FFP state for safety
|
||||||
@@ -1085,15 +1096,16 @@ void OpenGl_View::renderStructs (Graphic3d_Camera::Projection theProjection,
|
|||||||
|
|
||||||
if (!toRenderGL)
|
if (!toRenderGL)
|
||||||
{
|
{
|
||||||
toRenderGL = !initRaytraceResources (aCtx) ||
|
const Standard_Integer aSizeX = theReadDrawFbo != NULL ? theReadDrawFbo->GetVPSizeX() : myWindow->Width();
|
||||||
!updateRaytraceGeometry (OpenGl_GUM_CHECK, myId, aCtx);
|
const Standard_Integer aSizeY = theReadDrawFbo != NULL ? theReadDrawFbo->GetVPSizeY() : myWindow->Height();
|
||||||
|
|
||||||
|
toRenderGL = !initRaytraceResources (aSizeX, aSizeY, aCtx)
|
||||||
|
|| !updateRaytraceGeometry (OpenGl_GUM_CHECK, myId, aCtx);
|
||||||
|
|
||||||
toRenderGL |= !myIsRaytraceDataValid; // if no ray-trace data use OpenGL
|
toRenderGL |= !myIsRaytraceDataValid; // if no ray-trace data use OpenGL
|
||||||
|
|
||||||
if (!toRenderGL)
|
if (!toRenderGL)
|
||||||
{
|
{
|
||||||
const Standard_Integer aSizeX = theReadDrawFbo != NULL ? theReadDrawFbo->GetVPSizeX() : myWindow->Width();
|
|
||||||
const Standard_Integer aSizeY = theReadDrawFbo != NULL ? theReadDrawFbo->GetVPSizeY() : myWindow->Height();
|
|
||||||
myOpenGlFBO ->InitLazy (aCtx, aSizeX, aSizeY, myFboColorFormat, myFboDepthFormat, 0);
|
myOpenGlFBO ->InitLazy (aCtx, aSizeX, aSizeY, myFboColorFormat, myFboDepthFormat, 0);
|
||||||
|
|
||||||
if (theReadDrawFbo != NULL)
|
if (theReadDrawFbo != NULL)
|
||||||
@@ -1163,7 +1175,7 @@ void OpenGl_View::renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace)
|
|||||||
{
|
{
|
||||||
if (myToShowGradTrihedron)
|
if (myToShowGradTrihedron)
|
||||||
{
|
{
|
||||||
myGraduatedTrihedron->Render (theWorkspace);
|
myGraduatedTrihedron.Render (theWorkspace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1176,8 +1188,8 @@ void OpenGl_View::renderFrameStats()
|
|||||||
if (myRenderParams.ToShowStats
|
if (myRenderParams.ToShowStats
|
||||||
&& myRenderParams.CollectedStats != Graphic3d_RenderingParams::PerfCounters_NONE)
|
&& myRenderParams.CollectedStats != Graphic3d_RenderingParams::PerfCounters_NONE)
|
||||||
{
|
{
|
||||||
myFrameStatsPrs->Update (myWorkspace);
|
myFrameStatsPrs.Update (myWorkspace);
|
||||||
myFrameStatsPrs->Render (myWorkspace);
|
myFrameStatsPrs.Render (myWorkspace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -123,25 +123,16 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
|
|||||||
myNbSkippedTranspElems (0),
|
myNbSkippedTranspElems (0),
|
||||||
myRenderFilter (OpenGl_RenderFilter_Empty),
|
myRenderFilter (OpenGl_RenderFilter_Empty),
|
||||||
//
|
//
|
||||||
|
myAspectLineSet (&myDefaultAspectLine),
|
||||||
|
myAspectFaceSet (&myDefaultAspectFace),
|
||||||
|
myAspectMarkerSet (&myDefaultAspectMarker),
|
||||||
|
myAspectTextSet (&myDefaultAspectText),
|
||||||
|
//
|
||||||
ViewMatrix_applied (&myDefaultMatrix),
|
ViewMatrix_applied (&myDefaultMatrix),
|
||||||
StructureMatrix_applied (&myDefaultMatrix),
|
StructureMatrix_applied (&myDefaultMatrix),
|
||||||
myToAllowFaceCulling (false),
|
myToAllowFaceCulling (false),
|
||||||
myModelViewMatrix (myDefaultMatrix)
|
myModelViewMatrix (myDefaultMatrix)
|
||||||
{
|
{
|
||||||
myDefaultAspectLine = new OpenGl_AspectLine();
|
|
||||||
myDefaultAspectFace = new OpenGl_AspectFace();
|
|
||||||
myDefaultAspectMarker = new OpenGl_AspectMarker();
|
|
||||||
myDefaultAspectText = new OpenGl_AspectText();
|
|
||||||
|
|
||||||
myNoneCulling = new OpenGl_AspectFace();
|
|
||||||
myFrontCulling = new OpenGl_AspectFace();
|
|
||||||
myFontFaceAspect = new OpenGl_AspectFace();
|
|
||||||
|
|
||||||
myAspectLineSet = myDefaultAspectLine;
|
|
||||||
myAspectFaceSet = myDefaultAspectFace;
|
|
||||||
myAspectMarkerSet = myDefaultAspectMarker;
|
|
||||||
myAspectTextSet = myDefaultAspectText;
|
|
||||||
|
|
||||||
if (!myGlContext.IsNull() && myGlContext->MakeCurrent())
|
if (!myGlContext.IsNull() && myGlContext->MakeCurrent())
|
||||||
{
|
{
|
||||||
myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
@@ -164,16 +155,16 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
myFontFaceAspect->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Mask, 0.285f);
|
myFontFaceAspect.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend, 0.285f);
|
||||||
myFontFaceAspect->Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
myFontFaceAspect.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
||||||
|
|
||||||
myNoneCulling->Aspect()->SetSuppressBackFaces (false);
|
myNoneCulling .Aspect()->SetSuppressBackFaces (false);
|
||||||
myNoneCulling->Aspect()->SetDrawEdges (false);
|
myNoneCulling .Aspect()->SetDrawEdges (false);
|
||||||
myNoneCulling->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
|
myNoneCulling .Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
|
||||||
|
|
||||||
myFrontCulling->Aspect()->SetSuppressBackFaces (true);
|
myFrontCulling.Aspect()->SetSuppressBackFaces (true);
|
||||||
myFrontCulling->Aspect()->SetDrawEdges (false);
|
myFrontCulling.Aspect()->SetDrawEdges (false);
|
||||||
myFrontCulling->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
|
myFrontCulling.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -202,6 +193,14 @@ Standard_Boolean OpenGl_Workspace::Activate()
|
|||||||
{
|
{
|
||||||
myGlContext->ShaderManager()->PushState (Handle(OpenGl_ShaderProgram)());
|
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;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,12 +214,12 @@ void OpenGl_Workspace::ResetAppliedAspect()
|
|||||||
|
|
||||||
myHighlightStyle.Nullify();
|
myHighlightStyle.Nullify();
|
||||||
myToAllowFaceCulling = false;
|
myToAllowFaceCulling = false;
|
||||||
myAspectLineSet = myDefaultAspectLine;
|
myAspectLineSet = &myDefaultAspectLine;
|
||||||
myAspectFaceSet = myDefaultAspectFace;
|
myAspectFaceSet = &myDefaultAspectFace;
|
||||||
myAspectFaceApplied.Nullify();
|
myAspectFaceApplied.Nullify();
|
||||||
myAspectMarkerSet = myDefaultAspectMarker;
|
myAspectMarkerSet = &myDefaultAspectMarker;
|
||||||
myAspectMarkerApplied.Nullify();
|
myAspectMarkerApplied.Nullify();
|
||||||
myAspectTextSet = myDefaultAspectText;
|
myAspectTextSet = &myDefaultAspectText;
|
||||||
myGlContext->SetPolygonOffset (Graphic3d_PolygonOffset());
|
myGlContext->SetPolygonOffset (Graphic3d_PolygonOffset());
|
||||||
|
|
||||||
ApplyAspectLine();
|
ApplyAspectLine();
|
||||||
@@ -228,8 +227,8 @@ void OpenGl_Workspace::ResetAppliedAspect()
|
|||||||
ApplyAspectMarker();
|
ApplyAspectMarker();
|
||||||
ApplyAspectText();
|
ApplyAspectText();
|
||||||
|
|
||||||
myGlContext->SetTypeOfLine (myDefaultAspectLine->Aspect()->Type());
|
myGlContext->SetTypeOfLine (myDefaultAspectLine.Aspect()->Type());
|
||||||
myGlContext->SetLineWidth (myDefaultAspectLine->Aspect()->Width());
|
myGlContext->SetLineWidth (myDefaultAspectLine.Aspect()->Width());
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -238,9 +237,9 @@ void OpenGl_Workspace::ResetAppliedAspect()
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
Graphic3d_PolygonOffset OpenGl_Workspace::SetDefaultPolygonOffset (const Graphic3d_PolygonOffset& theOffset)
|
Graphic3d_PolygonOffset OpenGl_Workspace::SetDefaultPolygonOffset (const Graphic3d_PolygonOffset& theOffset)
|
||||||
{
|
{
|
||||||
Graphic3d_PolygonOffset aPrev = myDefaultAspectFace->Aspect()->PolygonOffset();
|
Graphic3d_PolygonOffset aPrev = myDefaultAspectFace.Aspect()->PolygonOffset();
|
||||||
myDefaultAspectFace->Aspect()->SetPolygonOffset (theOffset);
|
myDefaultAspectFace.Aspect()->SetPolygonOffset (theOffset);
|
||||||
if (myAspectFaceApplied == myDefaultAspectFace->Aspect()
|
if (myAspectFaceApplied == myDefaultAspectFace.Aspect()
|
||||||
|| myAspectFaceApplied.IsNull()
|
|| myAspectFaceApplied.IsNull()
|
||||||
|| (myAspectFaceApplied->PolygonOffset().Mode & Aspect_POM_None) == Aspect_POM_None)
|
|| (myAspectFaceApplied->PolygonOffset().Mode & Aspect_POM_None) == Aspect_POM_None)
|
||||||
{
|
{
|
||||||
@@ -253,43 +252,51 @@ Graphic3d_PolygonOffset OpenGl_Workspace::SetDefaultPolygonOffset (const Graphic
|
|||||||
// function : SetAspectLine
|
// function : SetAspectLine
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Workspace::SetAspectLine (const Handle(OpenGl_AspectLine)& theAspect)
|
const OpenGl_AspectLine* OpenGl_Workspace::SetAspectLine (const OpenGl_AspectLine* theAspect)
|
||||||
{
|
{
|
||||||
|
const OpenGl_AspectLine* aPrevAspectLine = myAspectLineSet;
|
||||||
myAspectLineSet = theAspect;
|
myAspectLineSet = theAspect;
|
||||||
|
return aPrevAspectLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : SetAspectFace
|
// function : SetAspectFace
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Workspace::SetAspectFace (const Handle(OpenGl_AspectFace)& theAspect)
|
const OpenGl_AspectFace * OpenGl_Workspace::SetAspectFace (const OpenGl_AspectFace* theAspect)
|
||||||
{
|
{
|
||||||
|
const OpenGl_AspectFace* aPrevAspectFace = myAspectFaceSet;
|
||||||
myAspectFaceSet = theAspect;
|
myAspectFaceSet = theAspect;
|
||||||
|
return aPrevAspectFace;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : SetAspectMarker
|
// function : SetAspectMarker
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Workspace::SetAspectMarker (const Handle(OpenGl_AspectMarker)& theAspect)
|
const OpenGl_AspectMarker* OpenGl_Workspace::SetAspectMarker (const OpenGl_AspectMarker* theAspect)
|
||||||
{
|
{
|
||||||
|
const OpenGl_AspectMarker* aPrevAspectMarker = myAspectMarkerSet;
|
||||||
myAspectMarkerSet = theAspect;
|
myAspectMarkerSet = theAspect;
|
||||||
|
return aPrevAspectMarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : SetAspectText
|
// function : SetAspectText
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Workspace::SetAspectText (const Handle(OpenGl_AspectText)& theAspect)
|
const OpenGl_AspectText * OpenGl_Workspace::SetAspectText (const OpenGl_AspectText* theAspect)
|
||||||
{
|
{
|
||||||
|
const OpenGl_AspectText* aPrevAspectText = myAspectTextSet;
|
||||||
myAspectTextSet = theAspect;
|
myAspectTextSet = theAspect;
|
||||||
|
return aPrevAspectText;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : ApplyAspectFace
|
// function : ApplyAspectFace
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
const Handle(OpenGl_AspectFace)& OpenGl_Workspace::ApplyAspectFace()
|
const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
|
||||||
{
|
{
|
||||||
if (myView->BackfacingModel() == Graphic3d_TOBM_AUTOMATIC)
|
if (myView->BackfacingModel() == Graphic3d_TOBM_AUTOMATIC)
|
||||||
{
|
{
|
||||||
@@ -317,60 +324,38 @@ const Handle(OpenGl_AspectFace)& OpenGl_Workspace::ApplyAspectFace()
|
|||||||
}
|
}
|
||||||
myAspectFaceAppliedWithHL = myHighlightStyle;
|
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
|
// Aspect_POM_None means: do not change current settings
|
||||||
if ((myAspectFaceSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None)
|
if ((myAspectFaceSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None)
|
||||||
{
|
{
|
||||||
myGlContext->SetPolygonOffset (myAspectFaceSet->Aspect()->PolygonOffset());
|
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
|
// Case of hidden line
|
||||||
if (myAspectFaceSet->Aspect()->InteriorStyle() == Aspect_IS_HIDDENLINE)
|
if (anIntstyle == Aspect_IS_HIDDENLINE)
|
||||||
{
|
{
|
||||||
// copy all values including line edge aspect
|
// copy all values including line edge aspect
|
||||||
*myAspectFaceHl.Aspect() = *myAspectFaceSet->Aspect();
|
*myAspectFaceHl.Aspect() = *myAspectFaceSet->Aspect();
|
||||||
myAspectFaceHl.SetAspectEdge (myAspectFaceSet->AspectEdge());
|
myAspectFaceHl.SetAspectEdge (myAspectFaceSet->AspectEdge());
|
||||||
myAspectFaceHl.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
myAspectFaceHl.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
||||||
myAspectFaceHl.Aspect()->SetInteriorColor (myView->BackgroundColor().GetRGB());
|
myAspectFaceHl.Aspect()->SetInteriorColor (myView->BackgroundColor().GetRGB());
|
||||||
|
myAspectFaceHl.Aspect()->SetDistinguish (false);
|
||||||
myAspectFaceHl.SetNoLighting();
|
myAspectFaceHl.SetNoLighting();
|
||||||
myAspectFaceSet = &myAspectFaceHl;
|
myAspectFaceSet = &myAspectFaceHl;
|
||||||
}
|
}
|
||||||
@@ -396,7 +381,7 @@ const Handle(OpenGl_AspectFace)& OpenGl_Workspace::ApplyAspectFace()
|
|||||||
// function : ApplyAspectMarker
|
// function : ApplyAspectMarker
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
const Handle(OpenGl_AspectMarker)& OpenGl_Workspace::ApplyAspectMarker()
|
const OpenGl_AspectMarker* OpenGl_Workspace::ApplyAspectMarker()
|
||||||
{
|
{
|
||||||
if (myAspectMarkerSet->Aspect() != myAspectMarkerApplied)
|
if (myAspectMarkerSet->Aspect() != myAspectMarkerApplied)
|
||||||
{
|
{
|
||||||
@@ -487,7 +472,7 @@ Standard_Boolean OpenGl_Workspace::BufferDump (const Handle(OpenGl_FrameBuffer)&
|
|||||||
// function : ShouldRender
|
// function : ShouldRender
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
bool OpenGl_Workspace::ShouldRender (const Handle(OpenGl_Element)& theElement)
|
bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement)
|
||||||
{
|
{
|
||||||
// render only non-raytracable elements when RayTracing is enabled
|
// render only non-raytracable elements when RayTracing is enabled
|
||||||
if ((myRenderFilter & OpenGl_RenderFilter_NonRaytraceableOnly) != 0)
|
if ((myRenderFilter & OpenGl_RenderFilter_NonRaytraceableOnly) != 0)
|
||||||
@@ -523,7 +508,7 @@ bool OpenGl_Workspace::ShouldRender (const Handle(OpenGl_Element)& theElement)
|
|||||||
{
|
{
|
||||||
if (!theElement->IsFillDrawMode())
|
if (!theElement->IsFillDrawMode())
|
||||||
{
|
{
|
||||||
if (Handle(OpenGl_AspectFace)::DownCast(theElement).IsNull())
|
if (dynamic_cast<const OpenGl_AspectFace*> (theElement) == NULL)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -83,9 +83,6 @@ public:
|
|||||||
//! @return true if depth writing is enabled.
|
//! @return true if depth writing is enabled.
|
||||||
Standard_Boolean& UseDepthWrite() { return myUseDepthWrite; }
|
Standard_Boolean& UseDepthWrite() { return myUseDepthWrite; }
|
||||||
|
|
||||||
//! @return true if frustum culling algorithm is enabled
|
|
||||||
Standard_EXPORT Standard_Boolean IsCullingEnabled() const;
|
|
||||||
|
|
||||||
//! Configure default polygon offset parameters.
|
//! Configure default polygon offset parameters.
|
||||||
//! Return previous settings.
|
//! Return previous settings.
|
||||||
Standard_EXPORT Graphic3d_PolygonOffset SetDefaultPolygonOffset (const Graphic3d_PolygonOffset& theOffset);
|
Standard_EXPORT Graphic3d_PolygonOffset SetDefaultPolygonOffset (const Graphic3d_PolygonOffset& theOffset);
|
||||||
@@ -163,44 +160,44 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Currently set line aspect (can differ from applied).
|
//! Currently set line aspect (can differ from applied).
|
||||||
const Handle(OpenGl_AspectLine)& AspectLine() const { return myAspectLineSet; }
|
const OpenGl_AspectLine* AspectLine() const { return myAspectLineSet; }
|
||||||
|
|
||||||
//! Currently set face aspect (can differ from applied).
|
//! Currently set face aspect (can differ from applied).
|
||||||
const Handle(OpenGl_AspectFace)& AspectFace() const { return myAspectFaceSet; }
|
const OpenGl_AspectFace* AspectFace() const { return myAspectFaceSet; }
|
||||||
|
|
||||||
//! Currently set marker aspect (can differ from applied).
|
//! Currently set marker aspect (can differ from applied).
|
||||||
const Handle(OpenGl_AspectMarker)& AspectMarker() const { return myAspectMarkerSet; }
|
const OpenGl_AspectMarker* AspectMarker() const { return myAspectMarkerSet; }
|
||||||
|
|
||||||
//! Currently set text aspect (can differ from applied).
|
//! Currently set text aspect (can differ from applied).
|
||||||
const Handle(OpenGl_AspectText)& AspectText() const { return myAspectTextSet; }
|
const OpenGl_AspectText* AspectText() const { return myAspectTextSet; }
|
||||||
|
|
||||||
//! Assign new line aspect (will be applied within ApplyAspectLine()).
|
//! Assign new line aspect (will be applied within ApplyAspectLine()).
|
||||||
Standard_EXPORT void SetAspectLine (const Handle(OpenGl_AspectLine)& theAspect);
|
Standard_EXPORT const OpenGl_AspectLine* SetAspectLine (const OpenGl_AspectLine* theAspect);
|
||||||
|
|
||||||
//! Assign new face aspect (will be applied within ApplyAspectFace()).
|
//! Assign new face aspect (will be applied within ApplyAspectFace()).
|
||||||
Standard_EXPORT void SetAspectFace (const Handle(OpenGl_AspectFace)& theAspect);
|
Standard_EXPORT const OpenGl_AspectFace* SetAspectFace (const OpenGl_AspectFace* theAspect);
|
||||||
|
|
||||||
//! Assign new marker aspect (will be applied within ApplyAspectMarker()).
|
//! Assign new marker aspect (will be applied within ApplyAspectMarker()).
|
||||||
Standard_EXPORT void SetAspectMarker (const Handle(OpenGl_AspectMarker)& theAspect);
|
Standard_EXPORT const OpenGl_AspectMarker* SetAspectMarker (const OpenGl_AspectMarker* theAspect);
|
||||||
|
|
||||||
//! Assign new text aspect (will be applied within ApplyAspectText()).
|
//! Assign new text aspect (will be applied within ApplyAspectText()).
|
||||||
Standard_EXPORT void SetAspectText (const Handle(OpenGl_AspectText)& theAspect);
|
Standard_EXPORT const OpenGl_AspectText* SetAspectText (const OpenGl_AspectText* theAspect);
|
||||||
|
|
||||||
//! Apply line aspect.
|
//! Apply line aspect.
|
||||||
//! @return aspect set by SetAspectLine()
|
//! @return aspect set by SetAspectLine()
|
||||||
const Handle(OpenGl_AspectLine)& ApplyAspectLine() { return myAspectLineSet; }
|
const OpenGl_AspectLine* ApplyAspectLine() { return myAspectLineSet; }
|
||||||
|
|
||||||
//! Apply face aspect.
|
//! Apply face aspect.
|
||||||
//! @return aspect set by SetAspectFace()
|
//! @return aspect set by SetAspectFace()
|
||||||
Standard_EXPORT const Handle(OpenGl_AspectFace)& ApplyAspectFace();
|
Standard_EXPORT const OpenGl_AspectFace* ApplyAspectFace();
|
||||||
|
|
||||||
//! Apply marker aspect.
|
//! Apply marker aspect.
|
||||||
//! @return aspect set by SetAspectMarker()
|
//! @return aspect set by SetAspectMarker()
|
||||||
Standard_EXPORT const Handle(OpenGl_AspectMarker)& ApplyAspectMarker();
|
Standard_EXPORT const OpenGl_AspectMarker* ApplyAspectMarker();
|
||||||
|
|
||||||
//! Apply text aspect.
|
//! Apply text aspect.
|
||||||
//! @return aspect set by SetAspectText()
|
//! @return aspect set by SetAspectText()
|
||||||
const Handle(OpenGl_AspectText)& ApplyAspectText() { return myAspectTextSet; }
|
const OpenGl_AspectText* ApplyAspectText() { return myAspectTextSet; }
|
||||||
|
|
||||||
//! Clear the applied aspect state to default values.
|
//! Clear the applied aspect state to default values.
|
||||||
void ResetAppliedAspect();
|
void ResetAppliedAspect();
|
||||||
@@ -216,7 +213,7 @@ public:
|
|||||||
//! Checks whether the element can be rendered or not.
|
//! Checks whether the element can be rendered or not.
|
||||||
//! @param theElement [in] the element to check
|
//! @param theElement [in] the element to check
|
||||||
//! @return True if element can be rendered
|
//! @return True if element can be rendered
|
||||||
bool ShouldRender (const Handle(OpenGl_Element)& theElement);
|
bool ShouldRender (const OpenGl_Element* theElement);
|
||||||
|
|
||||||
//! Return the number of skipped transparent elements within active OpenGl_RenderFilter_OpaqueOnly filter.
|
//! Return the number of skipped transparent elements within active OpenGl_RenderFilter_OpaqueOnly filter.
|
||||||
//! @sa OpenGl_LayerList::Render()
|
//! @sa OpenGl_LayerList::Render()
|
||||||
@@ -233,13 +230,13 @@ public:
|
|||||||
inline const OpenGl_Matrix* ModelMatrix() const { return StructureMatrix_applied; }
|
inline const OpenGl_Matrix* ModelMatrix() const { return StructureMatrix_applied; }
|
||||||
|
|
||||||
//! Returns face aspect for textured font rendering.
|
//! Returns face aspect for textured font rendering.
|
||||||
const Handle(OpenGl_AspectFace)& FontFaceAspect() const { return myFontFaceAspect; }
|
const OpenGl_AspectFace& FontFaceAspect() const { return myFontFaceAspect; }
|
||||||
|
|
||||||
//! Returns face aspect for none culling mode.
|
//! Returns face aspect for none culling mode.
|
||||||
const Handle(OpenGl_AspectFace)& NoneCulling() const { return myNoneCulling; }
|
const OpenGl_AspectFace& NoneCulling() const { return myNoneCulling; }
|
||||||
|
|
||||||
//! Returns face aspect for front face culling mode.
|
//! Returns face aspect for front face culling mode.
|
||||||
const Handle(OpenGl_AspectFace)& FrontCulling() const { return myFrontCulling; }
|
const OpenGl_AspectFace& FrontCulling() const { return myFrontCulling; }
|
||||||
|
|
||||||
//! Sets a new environment texture.
|
//! Sets a new environment texture.
|
||||||
void SetEnvironmentTexture (const Handle(OpenGl_TextureSet)& theTexture) { myEnvironmentTexture = theTexture; }
|
void SetEnvironmentTexture (const Handle(OpenGl_TextureSet)& theTexture) { myEnvironmentTexture = theTexture; }
|
||||||
@@ -254,26 +251,26 @@ protected: //! @name protected fields
|
|||||||
Handle(OpenGl_Context) myGlContext;
|
Handle(OpenGl_Context) myGlContext;
|
||||||
Standard_Boolean myUseZBuffer;
|
Standard_Boolean myUseZBuffer;
|
||||||
Standard_Boolean myUseDepthWrite;
|
Standard_Boolean myUseDepthWrite;
|
||||||
Handle(OpenGl_AspectFace) myNoneCulling;
|
OpenGl_AspectFace myNoneCulling;
|
||||||
Handle(OpenGl_AspectFace) myFrontCulling;
|
OpenGl_AspectFace myFrontCulling;
|
||||||
Handle(OpenGl_AspectFace) myFontFaceAspect;
|
OpenGl_AspectFace myFontFaceAspect;
|
||||||
|
|
||||||
protected: //! @name fields related to status
|
protected: //! @name fields related to status
|
||||||
|
|
||||||
Standard_Integer myNbSkippedTranspElems; //!< counter of skipped transparent elements for OpenGl_LayerList two rendering passes method
|
Standard_Integer myNbSkippedTranspElems; //!< counter of skipped transparent elements for OpenGl_LayerList two rendering passes method
|
||||||
Standard_Integer myRenderFilter; //!< active filter for skipping rendering of elements by some criteria (multiple render passes)
|
Standard_Integer myRenderFilter; //!< active filter for skipping rendering of elements by some criteria (multiple render passes)
|
||||||
|
|
||||||
Handle(OpenGl_AspectLine) myDefaultAspectLine;
|
OpenGl_AspectLine myDefaultAspectLine;
|
||||||
Handle(OpenGl_AspectFace) myDefaultAspectFace;
|
OpenGl_AspectFace myDefaultAspectFace;
|
||||||
Handle(OpenGl_AspectMarker) myDefaultAspectMarker;
|
OpenGl_AspectMarker myDefaultAspectMarker;
|
||||||
Handle(OpenGl_AspectText) myDefaultAspectText;
|
OpenGl_AspectText myDefaultAspectText;
|
||||||
|
|
||||||
Handle(OpenGl_AspectLine) myAspectLineSet;
|
const OpenGl_AspectLine* myAspectLineSet;
|
||||||
Handle(OpenGl_AspectFace) myAspectFaceSet;
|
const OpenGl_AspectFace* myAspectFaceSet;
|
||||||
Handle(Graphic3d_AspectFillArea3d) myAspectFaceApplied;
|
Handle(Graphic3d_AspectFillArea3d) myAspectFaceApplied;
|
||||||
Handle(OpenGl_AspectMarker) myAspectMarkerSet;
|
const OpenGl_AspectMarker* myAspectMarkerSet;
|
||||||
Handle(Graphic3d_AspectMarker3d) myAspectMarkerApplied;
|
Handle(Graphic3d_AspectMarker3d) myAspectMarkerApplied;
|
||||||
Handle(OpenGl_AspectText) myAspectTextSet;
|
const OpenGl_AspectText* myAspectTextSet;
|
||||||
Handle(Graphic3d_PresentationAttributes) myAspectFaceAppliedWithHL;
|
Handle(Graphic3d_PresentationAttributes) myAspectFaceAppliedWithHL;
|
||||||
|
|
||||||
const OpenGl_Matrix* ViewMatrix_applied;
|
const OpenGl_Matrix* ViewMatrix_applied;
|
||||||
|
@@ -29,6 +29,19 @@
|
|||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Drawer, Graphic3d_PresentationAttributes)
|
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
|
// function : Prs3d_Drawer
|
||||||
// purpose :
|
// purpose :
|
||||||
@@ -270,7 +283,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FreeBoundaryAspect()
|
|||||||
}
|
}
|
||||||
if (myFreeBoundaryAspect.IsNull())
|
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;
|
return myFreeBoundaryAspect;
|
||||||
@@ -313,7 +326,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::UnFreeBoundaryAspect()
|
|||||||
}
|
}
|
||||||
if (myUnFreeBoundaryAspect.IsNull())
|
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;
|
return myUnFreeBoundaryAspect;
|
||||||
@@ -356,7 +369,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FaceBoundaryAspect()
|
|||||||
}
|
}
|
||||||
if (myFaceBoundaryAspect.IsNull())
|
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;
|
return myFaceBoundaryAspect;
|
||||||
@@ -539,7 +552,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::WireAspect()
|
|||||||
}
|
}
|
||||||
if (myWireAspect.IsNull())
|
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;
|
return myWireAspect;
|
||||||
@@ -588,6 +601,30 @@ const Handle(Prs3d_PointAspect)& Prs3d_Drawer::PointAspect()
|
|||||||
return myPointAspect;
|
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
|
// function : SetPointAspect
|
||||||
// purpose :
|
// purpose :
|
||||||
@@ -614,7 +651,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::LineAspect()
|
|||||||
}
|
}
|
||||||
if (myLineAspect.IsNull())
|
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;
|
return myLineAspect;
|
||||||
@@ -684,6 +721,30 @@ const Handle(Prs3d_ShadingAspect)& Prs3d_Drawer::ShadingAspect()
|
|||||||
return myShadingAspect;
|
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
|
// function : SetShadingAspect
|
||||||
// purpose :
|
// purpose :
|
||||||
@@ -742,7 +803,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SeenLineAspect()
|
|||||||
}
|
}
|
||||||
if (mySeenLineAspect.IsNull())
|
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;
|
return mySeenLineAspect;
|
||||||
@@ -817,7 +878,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::HiddenLineAspect()
|
|||||||
}
|
}
|
||||||
if (myHiddenLineAspect.IsNull())
|
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;
|
return myHiddenLineAspect;
|
||||||
@@ -871,7 +932,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::VectorAspect()
|
|||||||
}
|
}
|
||||||
if (myVectorAspect.IsNull())
|
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;
|
return myVectorAspect;
|
||||||
@@ -966,7 +1027,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SectionAspect()
|
|||||||
}
|
}
|
||||||
if (mySectionAspect.IsNull())
|
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;
|
return mySectionAspect;
|
||||||
@@ -1059,17 +1120,156 @@ void Prs3d_Drawer::ClearLocalAttributes()
|
|||||||
myTypeOfHLR = Prs3d_TOH_NotSet;
|
myTypeOfHLR = Prs3d_TOH_NotSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Copy line aspect defaults from the Link.
|
// =======================================================================
|
||||||
inline void copyLineAspect (const Handle(Prs3d_Drawer)& theLink,
|
// function : SetOwnLineAspects
|
||||||
Handle(Prs3d_LineAspect)& theAspect,
|
// purpose :
|
||||||
const Handle(Prs3d_LineAspect)& theBaseAspect)
|
// =======================================================================
|
||||||
|
Standard_Boolean Prs3d_Drawer::SetOwnLineAspects (const Handle(Prs3d_Drawer)& theDefaults)
|
||||||
{
|
{
|
||||||
Handle(Prs3d_LineAspect) aBaseAspect = theBaseAspect;
|
bool isUpdateNeeded = false;
|
||||||
if (!theLink.IsNull())
|
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);
|
isUpdateNeeded = true;
|
||||||
*theAspect->Aspect() = *aBaseAspect->Aspect();
|
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.
|
//! Assign the shader program.
|
||||||
@@ -1100,103 +1300,8 @@ bool Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
|
|||||||
{
|
{
|
||||||
if (theToOverrideDefaults)
|
if (theToOverrideDefaults)
|
||||||
{
|
{
|
||||||
if (!myHasOwnUIsoAspect)
|
isUpdateNeeded = SetOwnLineAspects() || isUpdateNeeded;
|
||||||
{
|
isUpdateNeeded = SetOwnDatumAspects() || isUpdateNeeded;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setAspectProgram (theProgram, myHasOwnUIsoAspect, myUIsoAspect);
|
setAspectProgram (theProgram, myHasOwnUIsoAspect, myUIsoAspect);
|
||||||
@@ -1245,15 +1350,9 @@ bool Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
|
|||||||
case Graphic3d_ASPECT_MARKER:
|
case Graphic3d_ASPECT_MARKER:
|
||||||
{
|
{
|
||||||
if (theToOverrideDefaults
|
if (theToOverrideDefaults
|
||||||
&& !myHasOwnPointAspect)
|
&& SetupOwnPointAspect())
|
||||||
{
|
{
|
||||||
isUpdateNeeded = true;
|
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);
|
setAspectProgram (theProgram, myHasOwnPointAspect, myPointAspect);
|
||||||
@@ -1262,15 +1361,9 @@ bool Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
|
|||||||
case Graphic3d_ASPECT_FILL_AREA:
|
case Graphic3d_ASPECT_FILL_AREA:
|
||||||
{
|
{
|
||||||
if (theToOverrideDefaults
|
if (theToOverrideDefaults
|
||||||
&& !myHasOwnShadingAspect)
|
&& SetupOwnShadingAspect())
|
||||||
{
|
{
|
||||||
isUpdateNeeded = true;
|
isUpdateNeeded = true;
|
||||||
myShadingAspect = new Prs3d_ShadingAspect();
|
|
||||||
myHasOwnShadingAspect = true;
|
|
||||||
if (!myLink.IsNull())
|
|
||||||
{
|
|
||||||
*myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setAspectProgram (theProgram, myHasOwnShadingAspect, myShadingAspect);
|
setAspectProgram (theProgram, myHasOwnShadingAspect, myShadingAspect);
|
||||||
return isUpdateNeeded;
|
return isUpdateNeeded;
|
||||||
@@ -1289,15 +1382,9 @@ bool Prs3d_Drawer::SetShadingModel (Graphic3d_TypeOfShadingModel theModel,
|
|||||||
bool isUpdateNeeded = false;
|
bool isUpdateNeeded = false;
|
||||||
|
|
||||||
if (theToOverrideDefaults
|
if (theToOverrideDefaults
|
||||||
&& !myHasOwnShadingAspect)
|
&& SetupOwnShadingAspect())
|
||||||
{
|
{
|
||||||
isUpdateNeeded = true;
|
isUpdateNeeded = true;
|
||||||
myShadingAspect = new Prs3d_ShadingAspect();
|
|
||||||
myHasOwnShadingAspect = true;
|
|
||||||
if (!myLink.IsNull())
|
|
||||||
{
|
|
||||||
*myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!myShadingAspect.IsNull()
|
if (!myShadingAspect.IsNull()
|
||||||
|
@@ -439,6 +439,10 @@ public:
|
|||||||
//! point aspect that overrides the one in the link.
|
//! point aspect that overrides the one in the link.
|
||||||
Standard_Boolean HasOwnPointAspect() const { return myHasOwnPointAspect; }
|
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.
|
//! Returns settings for line aspects.
|
||||||
//! These settings can be edited. The default values are:
|
//! These settings can be edited. The default values are:
|
||||||
//! Color: Quantity_NOC_YELLOW
|
//! Color: Quantity_NOC_YELLOW
|
||||||
@@ -457,6 +461,14 @@ public:
|
|||||||
//! line aspect that overrides the one in the link.
|
//! line aspect that overrides the one in the link.
|
||||||
Standard_Boolean HasOwnLineAspect() const { return myHasOwnLineAspect; }
|
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.
|
//! Returns settings for text aspect.
|
||||||
//! These settings can be edited. The default value is:
|
//! These settings can be edited. The default value is:
|
||||||
//! - Color: Quantity_NOC_YELLOW
|
//! - Color: Quantity_NOC_YELLOW
|
||||||
@@ -487,6 +499,10 @@ public:
|
|||||||
//! shading aspect that overrides the one in the link.
|
//! shading aspect that overrides the one in the link.
|
||||||
Standard_Boolean HasOwnShadingAspect() const { return myHasOwnShadingAspect; }
|
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.
|
//! Returns settings for seen line aspects.
|
||||||
//! These settings can be edited. The default values are:
|
//! These settings can be edited. The default values are:
|
||||||
//! Color: Quantity_NOC_YELLOW
|
//! Color: Quantity_NOC_YELLOW
|
||||||
|
@@ -3,7 +3,6 @@ QABugs.hxx
|
|||||||
QABugs_1.cxx
|
QABugs_1.cxx
|
||||||
QABugs_2.cxx
|
QABugs_2.cxx
|
||||||
QABugs_3.cxx
|
QABugs_3.cxx
|
||||||
QABugs_4.cxx
|
|
||||||
QABugs_5.cxx
|
QABugs_5.cxx
|
||||||
QABugs_6.cxx
|
QABugs_6.cxx
|
||||||
QABugs_7.cxx
|
QABugs_7.cxx
|
||||||
|
@@ -19,7 +19,6 @@ void QABugs::Commands(Draw_Interpretor& theCommands) {
|
|||||||
QABugs::Commands_1(theCommands);
|
QABugs::Commands_1(theCommands);
|
||||||
QABugs::Commands_2(theCommands);
|
QABugs::Commands_2(theCommands);
|
||||||
QABugs::Commands_3(theCommands);
|
QABugs::Commands_3(theCommands);
|
||||||
QABugs::Commands_4(theCommands);
|
|
||||||
QABugs::Commands_5(theCommands);
|
QABugs::Commands_5(theCommands);
|
||||||
QABugs::Commands_6(theCommands);
|
QABugs::Commands_6(theCommands);
|
||||||
QABugs::Commands_7(theCommands);
|
QABugs::Commands_7(theCommands);
|
||||||
|
@@ -40,9 +40,7 @@ public:
|
|||||||
Standard_EXPORT static void Commands_2 (Draw_Interpretor& DI);
|
Standard_EXPORT static void Commands_2 (Draw_Interpretor& DI);
|
||||||
|
|
||||||
Standard_EXPORT static void Commands_3 (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_5 (Draw_Interpretor& DI);
|
||||||
|
|
||||||
Standard_EXPORT static void Commands_6 (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;
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user