1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0027700: Visualization - glPolygonMode() used for frame drawing affects label text shading

Patch extends GL-state caching mechanism of OpenGl_Context by new methods.
The methods allow setting/inquiring polygon rasterization and hatching modes:
- OpenGl_Context::SetPolygonMode
- OpenGl_Context::SetPolygonHatchEnabled
- OpenGl_Context::SetPolygonHatchStyle

With these methods OpenGl_Text is able to configure shading as necessary.
And this configuration is done irrespectively of currently defined face aspect.
Code of OpenGl_Workspace is also modified to use these methods as well.

Porting notes:
- OpenGl_LineAttributes now require OpenGl_Context instance for calling GL API.
- OpenGl_LineAttributes has new flag IsEnabled, it turns on/off hatching without changing the hatch type.
  By default this flag is turned on and can be never modified for compatibility with old code.
- OpenGl_LineAttributes is not anymore a field of OpenGl_Workspace::myLineAttrib.
  This resource is directly created by an OpenGl_Context instance on demand.
  If you use custom implementation of hatch patterns please create and share custom resource
  under resource-key "OpenGl_LineAttributes" in corresponding OpenGl_Context before using
  methods SetPolygonHatchEnabled, SetPolygonHatchStyle.
This commit is contained in:
apl 2016-08-01 22:09:20 +03:00 committed by bugmaster
parent d509e5a43f
commit 6d0e6be5a2
9 changed files with 352 additions and 108 deletions

View File

@ -141,9 +141,11 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
#if !defined(GL_ES_VERSION_2_0) #if !defined(GL_ES_VERSION_2_0)
myPointSpriteOrig (GL_UPPER_LEFT), myPointSpriteOrig (GL_UPPER_LEFT),
myRenderMode (GL_RENDER), myRenderMode (GL_RENDER),
myPolygonMode (GL_FILL),
#else #else
myPointSpriteOrig (0), myPointSpriteOrig (0),
myRenderMode (0), myRenderMode (0),
myPolygonMode (0),
#endif #endif
myToCullBackFaces (false), myToCullBackFaces (false),
myReadBuffer (0), myReadBuffer (0),
@ -2844,6 +2846,70 @@ Standard_Boolean OpenGl_Context::SetGlNormalizeEnabled (Standard_Boolean isEnabl
return anOldGlNormalize; return anOldGlNormalize;
} }
// =======================================================================
// function : SetPolygonMode
// purpose :
// =======================================================================
Standard_Integer OpenGl_Context::SetPolygonMode (const Standard_Integer theMode)
{
if (myPolygonMode == theMode)
{
return myPolygonMode;
}
const Standard_Integer anOldPolygonMode = myPolygonMode;
myPolygonMode = theMode;
#if !defined(GL_ES_VERSION_2_0)
::glPolygonMode (GL_FRONT_AND_BACK, (GLenum)theMode);
#endif
return anOldPolygonMode;
}
// =======================================================================
// function : SetPolygonHatchEnabled
// purpose :
// =======================================================================
bool OpenGl_Context::SetPolygonHatchEnabled (const bool theIsEnabled)
{
if (myHatchStyles.IsNull())
{
return false;
}
else if (myHatchStyles->IsEnabled() == theIsEnabled)
{
return theIsEnabled;
}
return myHatchStyles->SetEnabled (this, theIsEnabled);
}
// =======================================================================
// function : SetPolygonHatchStyle
// purpose :
// =======================================================================
Standard_Integer OpenGl_Context::SetPolygonHatchStyle (const Standard_Integer theType)
{
if (myHatchStyles.IsNull())
{
if (!GetResource ("OpenGl_LineAttributes", myHatchStyles))
{
// share and register for release once the resource is no longer used
myHatchStyles = new OpenGl_LineAttributes();
ShareResource ("OpenGl_LineAttributes", myHatchStyles);
myHatchStyles->Init (this);
}
}
if (myHatchStyles->TypeOfHatch() == theType)
{
return theType;
}
return myHatchStyles->SetTypeOfHatch (this, theType);
}
// ======================================================================= // =======================================================================
// function : ApplyModelWorldMatrix // function : ApplyModelWorldMatrix
// purpose : // purpose :

View File

@ -17,6 +17,7 @@
#define _OpenGl_Context_H__ #define _OpenGl_Context_H__
#include <Aspect_Handle.hxx> #include <Aspect_Handle.hxx>
#include <Aspect_HatchStyle.hxx>
#include <Aspect_Drawable.hxx> #include <Aspect_Drawable.hxx>
#include <Aspect_Display.hxx> #include <Aspect_Display.hxx>
#include <Aspect_RenderingContext.hxx> #include <Aspect_RenderingContext.hxx>
@ -27,6 +28,7 @@
#include <NCollection_List.hxx> #include <NCollection_List.hxx>
#include <Message.hxx> #include <Message.hxx>
#include <OpenGl_Caps.hxx> #include <OpenGl_Caps.hxx>
#include <OpenGl_LineAttributes.hxx>
#include <OpenGl_MatrixState.hxx> #include <OpenGl_MatrixState.hxx>
#include <OpenGl_Vec.hxx> #include <OpenGl_Vec.hxx>
#include <OpenGl_Resource.hxx> #include <OpenGl_Resource.hxx>
@ -455,6 +457,38 @@ public:
//! @return old value of the flag //! @return old value of the flag
Standard_EXPORT Standard_Boolean SetGlNormalizeEnabled (Standard_Boolean isEnabled); Standard_EXPORT Standard_Boolean SetGlNormalizeEnabled (Standard_Boolean isEnabled);
//! @return cached state of polygon rasterization mode (glPolygonMode()).
Standard_Integer PolygonMode() const { return myPolygonMode; }
//! Sets polygon rasterization mode (glPolygonMode() function).
//! @return old value of the rasterization mode.
Standard_EXPORT Standard_Integer SetPolygonMode (const Standard_Integer theMode);
//! @return cached enabled state of polygon hatching rasterization.
bool IsPolygonHatchEnabled() const
{
return !myHatchStyles.IsNull() && myHatchStyles->TypeOfHatch() != 0;
}
//! Sets enabled state of polygon hatching rasterization
//! without affecting currently selected hatching pattern.
//! @return previous state of polygon hatching mode.
Standard_EXPORT bool SetPolygonHatchEnabled (const bool theIsEnabled);
//! @return cached state of polygon hatch type.
Standard_Integer PolygonHatchStyle() const
{
return myHatchStyles.IsNull() ? Aspect_HS_SOLID : myHatchStyles->TypeOfHatch();
}
//! Sets polygon hatch pattern.
//! Zero-index value is a default alias for solid filling.
//! @param the type of hatch supported by base implementation of
//! OpenGl_LineAttributes (Aspect_HatchStyle) or the type supported by custom
//! implementation derived from OpenGl_LineAttributes class.
//! @return old type of hatch.
Standard_EXPORT Standard_Integer SetPolygonHatchStyle (const Standard_Integer theStyle);
//! Applies matrix stored in ModelWorldState to OpenGl. //! Applies matrix stored in ModelWorldState to OpenGl.
Standard_EXPORT void ApplyModelWorldMatrix(); Standard_EXPORT void ApplyModelWorldMatrix();
@ -725,19 +759,21 @@ private: // context info
private: //! @name fields tracking current state private: //! @name fields tracking current state
Handle(OpenGl_ShaderProgram) myActiveProgram; //!< currently active GLSL program Handle(OpenGl_ShaderProgram) myActiveProgram; //!< currently active GLSL program
Handle(OpenGl_Sampler) myTexSampler; //!< currently active sampler object Handle(OpenGl_Sampler) myTexSampler; //!< currently active sampler object
Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object
Standard_Integer myPointSpriteOrig; //!< GL_POINT_SPRITE_COORD_ORIGIN state (GL_UPPER_LEFT by default) Handle(OpenGl_LineAttributes) myHatchStyles; //!< resource holding predefined hatch styles patterns
Standard_Integer myRenderMode; //!< value for active rendering mode Standard_Integer myPointSpriteOrig; //!< GL_POINT_SPRITE_COORD_ORIGIN state (GL_UPPER_LEFT by default)
bool myToCullBackFaces; //!< back face culling mode enabled state (glIsEnabled (GL_CULL_FACE)) Standard_Integer myRenderMode; //!< value for active rendering mode
Standard_Integer myReadBuffer; //!< current read buffer Standard_Integer myPolygonMode; //!< currently used polygon rasterization mode (glPolygonMode)
Standard_Integer myDrawBuffer; //!< current draw buffer bool myToCullBackFaces; //!< back face culling mode enabled state (glIsEnabled (GL_CULL_FACE))
unsigned int myDefaultVao; //!< default Vertex Array Object Standard_Integer myReadBuffer; //!< current read buffer
Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state Standard_Integer myDrawBuffer; //!< current draw buffer
TCollection_AsciiString myVendor; //!< Graphics Driver's vendor unsigned int myDefaultVao; //!< default Vertex Array Object
TColStd_PackedMapOfInteger myFilters[6]; //!< messages suppressing filter (for sources from GL_DEBUG_SOURCE_API_ARB to GL_DEBUG_SOURCE_OTHER_ARB) Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state
Standard_ShortReal myResolutionRatio; //!< scaling factor for parameters like text size TCollection_AsciiString myVendor; //!< Graphics Driver's vendor
TColStd_PackedMapOfInteger myFilters[6]; //!< messages suppressing filter (for sources from GL_DEBUG_SOURCE_API_ARB to GL_DEBUG_SOURCE_OTHER_ARB)
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)
public: public:

View File

@ -479,13 +479,14 @@ static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] =
} }
}; };
// ======================================================================= // =======================================================================
// function : OpenGl_LineAttributes // function : OpenGl_LineAttributes
// purpose : // purpose :
// ======================================================================= // =======================================================================
OpenGl_LineAttributes::OpenGl_LineAttributes() OpenGl_LineAttributes::OpenGl_LineAttributes()
: myPatternBase(0) : myPatternBase (0),
myTypeOfHatch (0),
myIsEnabled (true)
{ {
// //
} }
@ -508,12 +509,14 @@ void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx)
// Delete surface patterns // Delete surface patterns
if (myPatternBase != 0) if (myPatternBase != 0)
{ {
#if !defined(GL_ES_VERSION_2_0)
if (theGlCtx->IsValid()) if (theGlCtx->IsValid())
{ {
#if !defined(GL_ES_VERSION_2_0) theGlCtx->core11->glDeleteLists ((GLuint )myPatternBase, TEL_HS_USER_DEF_START);
glDeleteLists ((GLuint )myPatternBase, TEL_HS_USER_DEF_START);
#endif
} }
#else
(void )theGlCtx;
#endif
myPatternBase = 0; myPatternBase = 0;
} }
} }
@ -522,7 +525,7 @@ void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx)
// function : Init // function : Init
// purpose : // purpose :
// ======================================================================= // =======================================================================
void OpenGl_LineAttributes::Init (const Handle(OpenGl_Context)& theGlCtx) void OpenGl_LineAttributes::Init (const OpenGl_Context* theGlCtx)
{ {
// Return if already initialized // Return if already initialized
if (myPatternBase != 0) if (myPatternBase != 0)
@ -541,9 +544,9 @@ void OpenGl_LineAttributes::Init (const Handle(OpenGl_Context)& theGlCtx)
myPatternBase = glGenLists(TEL_HS_USER_DEF_START); myPatternBase = glGenLists(TEL_HS_USER_DEF_START);
for (int i = 1; i < TEL_HS_USER_DEF_START; i++) for (int i = 1; i < TEL_HS_USER_DEF_START; i++)
{ {
glNewList ((GLuint )myPatternBase + i, GL_COMPILE); theGlCtx->core11->glNewList ((GLuint )myPatternBase + i, GL_COMPILE);
glPolygonStipple ((const GLubyte* )myInteriors[i < nbi ? i : 0]); theGlCtx->core11->glPolygonStipple ((const GLubyte* )myInteriors[i < nbi ? i : 0]);
glEndList(); theGlCtx->core11->glEndList();
} }
#else #else
(void )theGlCtx; (void )theGlCtx;
@ -554,22 +557,69 @@ void OpenGl_LineAttributes::Init (const Handle(OpenGl_Context)& theGlCtx)
// function : SetTypeOfHatch // function : SetTypeOfHatch
// purpose : // purpose :
// ======================================================================= // =======================================================================
void OpenGl_LineAttributes::SetTypeOfHatch (const int theType) const int OpenGl_LineAttributes::SetTypeOfHatch (const OpenGl_Context* theGlCtx, const int theType)
{ {
#if !defined(GL_ES_VERSION_2_0) // Return if not initialized
if (myPatternBase == 0) if (myPatternBase == 0)
{ {
return; return 0;
} }
const int anOldType = myTypeOfHatch;
#if !defined(GL_ES_VERSION_2_0)
if (theType != 0) if (theType != 0)
{ {
glCallList ((GLuint )myPatternBase + (GLuint )theType); theGlCtx->core11->glCallList ((GLuint )myPatternBase + (GLuint )theType);
glEnable (GL_POLYGON_STIPPLE);
if (myIsEnabled)
{
theGlCtx->core11fwd->glEnable (GL_POLYGON_STIPPLE);
}
} }
else else
glDisable (GL_POLYGON_STIPPLE); {
theGlCtx->core11fwd->glDisable (GL_POLYGON_STIPPLE);
}
#else #else
(void )theType; (void )theGlCtx;
#endif #endif
myTypeOfHatch = theType;
return anOldType;
}
// =======================================================================
// function : SetEnabled
// purpose :
// =======================================================================
bool OpenGl_LineAttributes::SetEnabled (const OpenGl_Context* theGlCtx,
const bool theToEnable)
{
// Return if not initialized
if (myPatternBase == 0)
{
return false;
}
const bool anOldIsEnabled = myIsEnabled;
#if !defined(GL_ES_VERSION_2_0)
if (theToEnable)
{
if (myTypeOfHatch != 0)
{
theGlCtx->core11fwd->glEnable (GL_POLYGON_STIPPLE);
}
}
else
{
theGlCtx->core11fwd->glDisable (GL_POLYGON_STIPPLE);
}
#else
(void )theGlCtx;
#endif
myIsEnabled = theToEnable;
return anOldIsEnabled;
} }

View File

@ -26,26 +26,59 @@ class OpenGl_Context;
#define TEL_HS_USER_DEF_START 15 #define TEL_HS_USER_DEF_START 15
//! Utility class to manage OpenGL state of polygon hatching rasterization
//! and keeping its cached state. The hatching rasterization is implemented
//! using glPolygonStipple function of OpenGL. State of hatching is controlled
//! by two parameters - type of hatching and IsEnabled parameter.
//! The hatching rasterization is enabled only if non-zero index pattern type
//! is selected (zero by default is reserved for solid filling) and if
//! IsEnabled flag is set to true. The IsEnabled parameter is useful for temporarily
//! turning on/off the hatching rasterization without making any costly GL calls
//! for changing the hatch pattern. This is a sharable resource class - it creates
//! OpenGL context objects for each hatch pattern to achieve quicker switching between
//! them, thesse GL objects are freed when the resource is released by owner context.
//! @note The implementation is not supported by Core Profile and by ES version.
class OpenGl_LineAttributes : public OpenGl_Resource class OpenGl_LineAttributes : public OpenGl_Resource
{ {
public: public:
//! Default constructor.
//! By default the parameters are:
//! - IsEnabled (true),
//! - TypeOfHatch (0).
OpenGl_LineAttributes(); OpenGl_LineAttributes();
//! Default destructor.
virtual ~OpenGl_LineAttributes(); virtual ~OpenGl_LineAttributes();
void Init (const Handle(OpenGl_Context)& theGlCtx); //! Initialize hatch patterns as GL resources.
//! Call this method before using hatching.
void Init (const OpenGl_Context* theGlCtx);
//! Release GL resources.
virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE; virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE;
void SetTypeOfHatch (const int theType) const; //! Index of currently selected type of hatch.
int TypeOfHatch() const { return myTypeOfHatch; }
//! Sets type of the hatch.
int SetTypeOfHatch (const OpenGl_Context* theGlCtx, const int theType);
//! Current enabled state of the hatching rasterization.
bool IsEnabled() const { return myIsEnabled; }
//! Turns on/off the hatching rasterization rasterization.
bool SetEnabled (const OpenGl_Context* theGlCtx, const bool theToEnable);
protected: protected:
unsigned int myPatternBase; unsigned int myPatternBase; //!< Base index for predefined hatch patterns
int myTypeOfHatch; //!< Currently activated type of hatch
bool myIsEnabled; //!< Current enabled state of hatching rasterization.
public: public:
DEFINE_STANDARD_RTTIEXT(OpenGl_LineAttributes,OpenGl_Resource) DEFINE_STANDARD_RTTIEXT(OpenGl_LineAttributes,OpenGl_Resource)
}; };
DEFINE_STANDARD_HANDLE(OpenGl_LineAttributes, OpenGl_Resource) DEFINE_STANDARD_HANDLE(OpenGl_LineAttributes, OpenGl_Resource)

View File

@ -414,6 +414,10 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
const OpenGl_AspectText* aTextAspect = theWorkspace->ApplyAspectText(); const OpenGl_AspectText* aTextAspect = theWorkspace->ApplyAspectText();
const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture(); const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext(); const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
#if !defined(GL_ES_VERSION_2_0)
const Standard_Integer aPrevPolygonMode = aCtx->SetPolygonMode (GL_FILL);
const bool aPrevHatchingMode = aCtx->SetPolygonHatchEnabled (false);
#endif
// Bind custom shader program or generate default version // Bind custom shader program or generate default version
if (aCtx->core20fwd != NULL) if (aCtx->core20fwd != NULL)
@ -439,6 +443,10 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{ {
theWorkspace->EnableTexture (aPrevTexture); theWorkspace->EnableTexture (aPrevTexture);
} }
#if !defined(GL_ES_VERSION_2_0)
aCtx->SetPolygonMode (aPrevPolygonMode);
aCtx->SetPolygonHatchEnabled (aPrevHatchingMode);
#endif
// restore Z buffer settings // restore Z buffer settings
if (theWorkspace->UseZBuffer()) if (theWorkspace->UseZBuffer())

View File

@ -153,16 +153,7 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
{ {
myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1); myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
if (!myGlContext->GetResource ("OpenGl_LineAttributes", myLineAttribs))
{
// share and register for release once the resource is no longer used
myLineAttribs = new OpenGl_LineAttributes();
myGlContext->ShareResource ("OpenGl_LineAttributes", myLineAttribs);
myLineAttribs->Init (myGlContext);
}
// General initialization of the context // General initialization of the context
#if !defined(GL_ES_VERSION_2_0) #if !defined(GL_ES_VERSION_2_0)
if (myGlContext->core11 != NULL) if (myGlContext->core11 != NULL)
{ {
@ -188,19 +179,6 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
myFrontCulling.Aspect()->SetDrawEdges (false); myFrontCulling.Aspect()->SetDrawEdges (false);
} }
// =======================================================================
// function : ~OpenGl_Workspace
// purpose :
// =======================================================================
OpenGl_Workspace::~OpenGl_Workspace()
{
if (!myLineAttribs.IsNull())
{
myLineAttribs.Nullify();
myGlContext->ReleaseResource ("OpenGl_LineAttributes", Standard_True);
}
}
// ======================================================================= // =======================================================================
// function : Activate // function : Activate
// purpose : // purpose :
@ -836,28 +814,25 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
case Aspect_IS_EMPTY: case Aspect_IS_EMPTY:
case Aspect_IS_HOLLOW: case Aspect_IS_HOLLOW:
{ {
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); myGlContext->SetPolygonMode (GL_LINE);
break; break;
} }
case Aspect_IS_HATCH: case Aspect_IS_HATCH:
{ {
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); myGlContext->SetPolygonMode (GL_FILL);
myLineAttribs->SetTypeOfHatch (!myAspectFaceApplied.IsNull() ? myAspectFaceApplied->HatchStyle() : Aspect_HS_SOLID); myGlContext->SetPolygonHatchEnabled (true);
break; break;
} }
case Aspect_IS_SOLID: case Aspect_IS_SOLID:
case Aspect_IS_HIDDENLINE: case Aspect_IS_HIDDENLINE:
{ {
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); myGlContext->SetPolygonMode (GL_FILL);
if (myGlContext->core11 != NULL) myGlContext->SetPolygonHatchEnabled (false);
{
glDisable (GL_POLYGON_STIPPLE);
}
break; break;
} }
case Aspect_IS_POINT: case Aspect_IS_POINT:
{ {
glPolygonMode (GL_FRONT_AND_BACK, GL_POINT); myGlContext->SetPolygonMode (GL_POINT);
break; break;
} }
} }
@ -865,12 +840,7 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
if (anIntstyle == Aspect_IS_HATCH) if (anIntstyle == Aspect_IS_HATCH)
{ {
const Aspect_HatchStyle hatchstyle = myAspectFaceSet->Aspect()->HatchStyle(); myGlContext->SetPolygonHatchStyle (myAspectFaceSet->Aspect()->HatchStyle());
if (myAspectFaceApplied.IsNull()
|| myAspectFaceApplied->HatchStyle() != hatchstyle)
{
myLineAttribs->SetTypeOfHatch (hatchstyle);
}
} }
#endif #endif

View File

@ -21,7 +21,6 @@
#include <OpenGl_AspectFace.hxx> #include <OpenGl_AspectFace.hxx>
#include <OpenGl_CappingAlgo.hxx> #include <OpenGl_CappingAlgo.hxx>
#include <OpenGl_FrameBuffer.hxx> #include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_LineAttributes.hxx>
#include <OpenGl_Matrix.hxx> #include <OpenGl_Matrix.hxx>
#include <OpenGl_NamedStatus.hxx> #include <OpenGl_NamedStatus.hxx>
#include <OpenGl_PrinterContext.hxx> #include <OpenGl_PrinterContext.hxx>
@ -121,7 +120,7 @@ public:
Standard_EXPORT OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Window)& theWindow); Standard_EXPORT OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Window)& theWindow);
//! Destructor //! Destructor
Standard_EXPORT virtual ~OpenGl_Workspace(); virtual ~OpenGl_Workspace() {}
//! Activate rendering context. //! Activate rendering context.
Standard_EXPORT Standard_Boolean Activate(); Standard_EXPORT Standard_Boolean Activate();
@ -306,7 +305,7 @@ public:
//! Sets and applies current polygon offset. //! Sets and applies current polygon offset.
void SetPolygonOffset (const Graphic3d_PolygonOffset& theParams); void SetPolygonOffset (const Graphic3d_PolygonOffset& theParams);
//! Returns currently applied polygon offset params. //! Returns currently applied polygon offset parameters.
const Graphic3d_PolygonOffset& AppliedPolygonOffset() { return myPolygonOffsetApplied; } const Graphic3d_PolygonOffset& AppliedPolygonOffset() { return myPolygonOffsetApplied; }
//! Returns capping algorithm rendering filter. //! Returns capping algorithm rendering filter.
@ -358,7 +357,6 @@ protected: //! @name protected fields
Handle(OpenGl_Window) myWindow; Handle(OpenGl_Window) myWindow;
Handle(OpenGl_Context) myGlContext; Handle(OpenGl_Context) myGlContext;
Handle(OpenGl_PrinterContext) myPrintContext; Handle(OpenGl_PrinterContext) myPrintContext;
Handle(OpenGl_LineAttributes) myLineAttribs;
Standard_Boolean myUseZBuffer; Standard_Boolean myUseZBuffer;
Standard_Boolean myUseDepthWrite; Standard_Boolean myUseDepthWrite;
Standard_Boolean myUseGLLight; Standard_Boolean myUseGLLight;

View File

@ -15,49 +15,48 @@
#include <QABugs.hxx> #include <QABugs.hxx>
#include <Draw_Interpretor.hxx>
#include <DBRep.hxx>
#include <DrawTrSurf.hxx>
#include <ViewerTest.hxx>
#include <V3d_View.hxx>
#include <TopoDS_Shape.hxx>
#include <AIS_InteractiveContext.hxx> #include <AIS_InteractiveContext.hxx>
#include <AIS_LocalContext.hxx> #include <AIS_LocalContext.hxx>
#include <AIS_TexturedShape.hxx> #include <AIS_TexturedShape.hxx>
#include <Image_PixMap.hxx> #include <BRepAlgo_Cut.hxx>
#include <Image_Color.hxx> #include <BRepOffsetAPI_MakePipe.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <gp_Pnt2d.hxx> #include <BRepPrimAPI_MakeSphere.hxx>
#include <gp_Ax1.hxx> #include <DBRep.hxx>
#include <gp_Quaternion.hxx> #include <Draw_Interpretor.hxx>
#include <DrawTrSurf.hxx>
#include <GCE2d_MakeSegment.hxx> #include <GCE2d_MakeSegment.hxx>
#include <Geom2d_TrimmedCurve.hxx> #include <Geom2d_TrimmedCurve.hxx>
#include <DrawTrSurf.hxx> #include <GeomFill_Trihedron.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx>
#include <gp_Ax1.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Quaternion.hxx>
#include <Image_Color.hxx>
#include <Image_PixMap.hxx>
#include <NCollection_Handle.hxx>
#include <NCollection_IncAllocator.hxx>
#include <NCollection_Map.hxx>
#include <OSD_Parallel.hxx>
#include <OSD_PerfMeter.hxx>
#include <OSD_Timer.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_Text.hxx>
#include <SelectMgr_Filter.hxx>
#include <Standard_Version.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Shape.hxx>
#include <V3d_View.hxx>
#include <ViewerTest.hxx>
#include <XmlDrivers_DocumentRetrievalDriver.hxx>
#include <XmlDrivers_DocumentStorageDriver.hxx>
#include <cstdio> #include <cstdio>
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
#include <OSD_Timer.hxx>
#include <OSD_Parallel.hxx>
#include <OSD_PerfMeter.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepPrimAPI_MakeSphere.hxx>
#include <BRepAlgo_Cut.hxx>
#include <NCollection_Map.hxx>
#include <NCollection_Handle.hxx>
#include <NCollection_IncAllocator.hxx>
#include <TCollection_HAsciiString.hxx>
#include <GeomFill_Trihedron.hxx>
#include <BRepOffsetAPI_MakePipe.hxx>
#include <TopExp_Explorer.hxx>
#include <SelectMgr_Filter.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <Standard_Version.hxx>
#include <XmlDrivers_DocumentRetrievalDriver.hxx>
#include <XmlDrivers_DocumentStorageDriver.hxx>
#define QCOMPARE(val1, val2) \ #define QCOMPARE(val1, val2) \
di << "Checking " #val1 " == " #val2 << \ di << "Checking " #val1 " == " #val2 << \
@ -5182,6 +5181,72 @@ static Standard_Integer OCC27523 (Draw_Interpretor& theDI, Standard_Integer theA
return 0; return 0;
} }
//========================================================================
//function : OCC27700
//purpose : glPolygonMode() used for frame drawing affects label text shading
//========================================================================
class OCC27700_Text : public AIS_InteractiveObject
{
public:
DEFINE_STANDARD_RTTI_INLINE (OCC27700_Text, AIS_InteractiveObject)
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer /*theMode*/) Standard_OVERRIDE
{
Handle(Graphic3d_ArrayOfTriangles) aFrame = new Graphic3d_ArrayOfTriangles (6, 6);
aFrame->AddVertex (gp_Pnt (-1, 0, 0));
aFrame->AddVertex (gp_Pnt (-1, 1, 0));
aFrame->AddVertex (gp_Pnt ( 3, 1, 0));
aFrame->AddVertex (gp_Pnt ( 3, 0, 0));
aFrame->AddEdge (1);
aFrame->AddEdge (2);
aFrame->AddEdge (3);
aFrame->AddEdge (2);
aFrame->AddEdge (3);
aFrame->AddEdge (4);
Handle(Graphic3d_AspectFillArea3d) aFillAspect =
new Graphic3d_AspectFillArea3d (*myDrawer->ShadingAspect()->Aspect().get());
aFillAspect->SetInteriorStyle (Aspect_IS_POINT);
// create separate group for frame elements
Handle(Graphic3d_Group) aFrameGroup = Prs3d_Root::NewGroup (thePresentation);
aFrameGroup->AddPrimitiveArray (aFrame);
aFrameGroup->SetGroupPrimitivesAspect (aFillAspect);
// create separate group for text elements
Handle(Graphic3d_Group) aTextGroup = Prs3d_Root::NewGroup (thePresentation);
TCollection_ExtendedString aString ("YOU SHOULD SEE THIS TEXT", Standard_True);
Prs3d_Text::Draw (thePresentation, myDrawer->TextAspect(), aString, gp_Ax2 (gp::Origin(), gp::DZ()));
}
virtual void ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/,
const Standard_Integer /*theMode*/) Standard_OVERRIDE {}
};
static Standard_Integer OCC27700 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgNb*/, const char** /*theArgVec*/)
{
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
if (aContext.IsNull())
{
std::cout << "Error: no view available, call 'vinit' before!" << std::endl;
return 1;
}
Handle(OCC27700_Text) aPresentation = new OCC27700_Text();
aContext->Display (aPresentation);
return 0;
}
//========================================================================
//function : Commands_19
//purpose :
//========================================================================
void QABugs::Commands_19(Draw_Interpretor& theCommands) { void QABugs::Commands_19(Draw_Interpretor& theCommands) {
const char *group = "QABugs"; const char *group = "QABugs";
@ -5301,6 +5366,8 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
theCommands.Add ("OCC27523", theCommands.Add ("OCC27523",
"OCC27523: Checks recomputation of deactivated selection mode after object's redisplaying", "OCC27523: Checks recomputation of deactivated selection mode after object's redisplaying",
__FILE__, OCC27523, group); __FILE__, OCC27523, group);
theCommands.Add ("OCC27700",
"OCC27700: Checks drawing text after setting interior style",
__FILE__, OCC27700, group);
return; return;
} }

16
tests/bugs/vis/bug27700 Normal file
View File

@ -0,0 +1,16 @@
puts "========"
puts "CR27700"
puts "========"
puts ""
############################################################################################
puts "Visualization - glPolygonMode() used for frame drawing affects label text shading"
############################################################################################
vclear
vinit View1
OCC27700
vtop
vfit
vdump $imagedir/${casename}.png