Current state variables have been moved out from OpenGl_LineAttributes to OpenGl_Context.
myPBRSpecIBLMapTexUnit (Graphic3d_TextureUnit_PbrIblSpecular),
myFrameStats (new OpenGl_FrameStats()),
myActiveMockTextures (0),
+ myActiveHatchType (Aspect_HS_SOLID),
+ myHatchIsEnabled (false),
#if !defined(GL_ES_VERSION_2_0)
myPointSpriteOrig (GL_UPPER_LEFT),
myRenderMode (GL_RENDER),
// =======================================================================
bool OpenGl_Context::SetPolygonHatchEnabled (const bool theIsEnabled)
{
- if (myHatchStyles.IsNull())
+ if (core11 == NULL)
{
return false;
}
- else if (myHatchStyles->IsEnabled() == theIsEnabled)
+ else if (myHatchIsEnabled == theIsEnabled)
{
return theIsEnabled;
}
- return myHatchStyles->SetEnabled (this, theIsEnabled);
+ const bool anOldIsEnabled = myHatchIsEnabled;
+#if !defined(GL_ES_VERSION_2_0)
+ if (theIsEnabled
+ && myActiveHatchType != Aspect_HS_SOLID)
+ {
+ core11fwd->glEnable (GL_POLYGON_STIPPLE);
+ }
+ else
+ {
+ core11fwd->glDisable (GL_POLYGON_STIPPLE);
+ }
+#endif
+ myHatchIsEnabled = theIsEnabled;
+ return anOldIsEnabled;
}
// =======================================================================
// =======================================================================
Standard_Integer OpenGl_Context::SetPolygonHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle)
{
- if (theStyle.IsNull())
+ const Standard_Integer aNewStyle = !theStyle.IsNull() ? theStyle->HatchType() : Aspect_HS_SOLID;
+ if (myActiveHatchType == aNewStyle
+ || core11 == NULL)
{
- return 0;
+ return myActiveHatchType;
}
- if (myHatchStyles.IsNull())
+#if !defined(GL_ES_VERSION_2_0)
+ if (aNewStyle == Aspect_HS_SOLID)
{
- if (!GetResource ("OpenGl_LineAttributes", myHatchStyles))
+ if (myHatchIsEnabled)
{
- // share and register for release once the resource is no longer used
- myHatchStyles = new OpenGl_LineAttributes();
- ShareResource ("OpenGl_LineAttributes", myHatchStyles);
+ core11fwd->glDisable (GL_POLYGON_STIPPLE);
}
+ return myActiveHatchType;
}
- if (myHatchStyles->TypeOfHatch() == theStyle->HatchType())
+
+ if (myHatchStyles.IsNull()
+ && !GetResource ("OpenGl_LineAttributes", myHatchStyles))
{
- return theStyle->HatchType();
+ // share and register for release once the resource is no longer used
+ myHatchStyles = new OpenGl_LineAttributes();
+ ShareResource ("OpenGl_LineAttributes", myHatchStyles);
}
- return myHatchStyles->SetTypeOfHatch (this, theStyle);
+ const Standard_Integer anOldType = myActiveHatchType;
+ myActiveHatchType = aNewStyle;
+ myHatchStyles->SetTypeOfHatch (this, theStyle);
+ if (myHatchIsEnabled
+ && anOldType == Aspect_HS_SOLID)
+ {
+ core11fwd->glEnable (GL_POLYGON_STIPPLE);
+ }
+ return anOldType;
+#else
+ return myActiveHatchType;
+#endif
}
// =======================================================================
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;
- }
+ bool IsPolygonHatchEnabled() const { return myHatchIsEnabled; }
//! Sets enabled state of polygon hatching rasterization
//! without affecting currently selected hatching pattern.
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();
- }
+ Standard_Integer PolygonHatchStyle() const { return myActiveHatchType; }
//! Sets polygon hatch pattern.
//! Zero-index value is a default alias for solid filling.
Standard_Integer myActiveMockTextures; //!< currently active mock sampler objects
Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object
Handle(OpenGl_LineAttributes) myHatchStyles; //!< resource holding predefined hatch styles patterns
+ Standard_Integer myActiveHatchType; //!< currently activated type of polygon hatch
+ Standard_Boolean myHatchIsEnabled; //!< current enabled state of polygon hatching rasterization
Handle(OpenGl_Texture) myTextureRgbaBlack;//!< mock black texture returning (0, 0, 0, 0)
Handle(OpenGl_Texture) myTextureRgbaWhite;//!< mock white texture returning (1, 1, 1, 1)
Standard_Integer myViewport[4]; //!< current viewport
// purpose :
// =======================================================================
OpenGl_LineAttributes::OpenGl_LineAttributes()
-: myTypeOfHatch (0),
- myIsEnabled (true)
{
//
}
// =======================================================================
void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx)
{
- // Delete surface patterns
#if !defined(GL_ES_VERSION_2_0)
- if (theGlCtx != NULL && theGlCtx->IsValid())
+ if (theGlCtx != NULL
+ && theGlCtx->IsValid())
{
for (OpenGl_MapOfHatchStylesAndIds::Iterator anIter (myStyles); anIter.More(); anIter.Next())
{
}
}
#else
- (void )theGlCtx;
+ (void )theGlCtx;
#endif
- myStyles.Clear();
+ myStyles.Clear();
}
// =======================================================================
const Handle(Graphic3d_HatchStyle)& theStyle)
{
#if !defined(GL_ES_VERSION_2_0)
- if (theGlCtx->core11 == NULL)
- {
- return 0;
- }
-
- const unsigned int aListId = glGenLists(1);
+ const unsigned int aListId = theGlCtx->core11->glGenLists(1);
theGlCtx->core11->glNewList ((GLuint)aListId, GL_COMPILE);
theGlCtx->core11->glPolygonStipple ((const GLubyte*)theStyle->Pattern());
theGlCtx->core11->glEndList();
// function : SetTypeOfHatch
// purpose :
// =======================================================================
-int OpenGl_LineAttributes::SetTypeOfHatch (const OpenGl_Context* theGlCtx,
- const Handle(Graphic3d_HatchStyle)& theStyle)
+bool OpenGl_LineAttributes::SetTypeOfHatch (const OpenGl_Context* theGlCtx,
+ const Handle(Graphic3d_HatchStyle)& theStyle)
{
- // Return if not initialized
- if (theStyle.IsNull())
+ if (theStyle.IsNull()
+ || theStyle->HatchType() == Aspect_HS_SOLID
+ || theGlCtx->core11 == NULL)
{
- return 0;
+ return false;
}
- const int anOldType = myTypeOfHatch;
-
unsigned int aGpuListId = 0;
if (!myStyles.Find (theStyle, aGpuListId))
{
}
#if !defined(GL_ES_VERSION_2_0)
- if (theGlCtx->core11 == NULL)
- {
- return 0;
- }
- else if (theStyle->HatchType() != 0)
- {
- theGlCtx->core11->glCallList ((GLuint)aGpuListId);
-
- if (myIsEnabled)
- {
- theGlCtx->core11fwd->glEnable (GL_POLYGON_STIPPLE);
- }
- }
- else
- {
- theGlCtx->core11fwd->glDisable (GL_POLYGON_STIPPLE);
- }
-#else
- (void )theGlCtx;
-#endif
- myTypeOfHatch = theStyle->HatchType();
-
- return anOldType;
-}
-
-// =======================================================================
-// function : SetEnabled
-// purpose :
-// =======================================================================
-bool OpenGl_LineAttributes::SetEnabled (const OpenGl_Context* theGlCtx,
- const bool theToEnable)
-{
- // Return if not initialized
- if (myStyles.IsEmpty())
- {
- return false;
- }
-
- const bool anOldIsEnabled = myIsEnabled;
-
-#if !defined(GL_ES_VERSION_2_0)
- if (theGlCtx->core11 == NULL)
- {
- return 0;
- }
- else if (theToEnable)
- {
- if (myTypeOfHatch != 0)
- {
- theGlCtx->core11fwd->glEnable (GL_POLYGON_STIPPLE);
- }
- }
- else
- {
- theGlCtx->core11fwd->glDisable (GL_POLYGON_STIPPLE);
- }
-#else
- (void )theGlCtx;
+ theGlCtx->core11->glCallList ((GLuint)aGpuListId);
#endif
- myIsEnabled = theToEnable;
-
- return anOldIsEnabled;
+ return true;
}
#include <OpenGl_Resource.hxx>
-#include <Aspect_TypeOfLine.hxx>
-#include <Aspect_TypeOfMarker.hxx>
-#include <Font_FontAspect.hxx>
#include <Graphic3d_HatchStyle.hxx>
#include <NCollection_DataMap.hxx>
class OpenGl_Context;
-//! 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.
+DEFINE_STANDARD_HANDLE(OpenGl_LineAttributes, OpenGl_Resource)
+
+//! Utility class to manage OpenGL resources of polygon hatching styles.
+//! @note the implementation is not supported by Core Profile and by ES version.
class OpenGl_LineAttributes : public OpenGl_Resource
{
+ DEFINE_STANDARD_RTTIEXT(OpenGl_LineAttributes, OpenGl_Resource)
public:
//! Default constructor.
- //! By default the parameters are:
- //! - IsEnabled (true),
- //! - TypeOfHatch (0).
Standard_EXPORT OpenGl_LineAttributes();
//! Default destructor.
//! Returns estimated GPU memory usage - not implemented.
virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; }
- //! Index of currently selected type of hatch.
- int TypeOfHatch() const { return myTypeOfHatch; }
-
//! Sets type of the hatch.
- Standard_EXPORT int SetTypeOfHatch (const OpenGl_Context* theGlCtx,
- const Handle(Graphic3d_HatchStyle)& theStyle);
-
- //! Current enabled state of the hatching rasterization.
- bool IsEnabled() const { return myIsEnabled; }
-
- //! Turns on/off the hatching rasterization rasterization.
- Standard_EXPORT bool SetEnabled (const OpenGl_Context* theGlCtx, const bool theToEnable);
+ Standard_EXPORT bool SetTypeOfHatch (const OpenGl_Context* theGlCtx,
+ const Handle(Graphic3d_HatchStyle)& theStyle);
-protected:
+private:
unsigned int init (const OpenGl_Context* theGlCtx,
const Handle(Graphic3d_HatchStyle)& theStyle);
protected:
- int myTypeOfHatch; //!< Currently activated type of hatch
- bool myIsEnabled; //!< Current enabled state of hatching rasterization.
OpenGl_MapOfHatchStylesAndIds myStyles; //!< Hatch patterns
-public:
-
- DEFINE_STANDARD_RTTIEXT(OpenGl_LineAttributes,OpenGl_Resource)
};
-DEFINE_STANDARD_HANDLE(OpenGl_LineAttributes, OpenGl_Resource)
-
#endif // _OpenGl_LineAttributes_Header
--- /dev/null
+puts "============"
+puts "0031702: Visualization, TKOpenGl - hatching interior is ignored in second View within the Viewer"
+puts "============"
+puts ""
+
+pload MODELING VISUALIZATION
+vclear
+vclose *
+vinit v1/v1
+box b1 100 200 300
+vdisplay -dispMode 1 b1
+vfit
+vaspects b1 -interior hatch
+if { [vreadpixel 201 200 -rgb -name] != "BLACK" } { puts "Error: no hatching in first view" }
+vdump ${imagedir}/${casename}_v1.png
+
+vinit v2/v1
+box b2 100 200 300
+vdisplay -dispMode 1 b2
+vfit
+vaspects b2 -interior hatch
+if { [vreadpixel 201 200 -rgb -name] != "BLACK" } { puts "Error: no hatching in second view" }
+vdump ${imagedir}/${casename}_v2.png