#include <OpenGl_LineAttributes.hxx>
#include <OpenGl_Context.hxx>
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_LineAttributes,OpenGl_Resource)
+
static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] =
{
- //TEL_HS_SOLID
+ // Aspect_HS_SOLID
{
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF
},
- //TEL_HS_CROSS
+ // Aspect_HS_GRID_DIAGONAL
{
0xFFFFFFFF,
0xBBBBBBBB,
0xEEEEEEEE,
0xBBBBBBBB
},
- //TEL_HS_CROSS_SPARSE
+ // Aspect_HS_GRID_DIAGONAL_WIDE
{
0x81818181,
0x24242424,
0x18181818,
0x42424242
},
- //TEL_HS_GRID
+ // Aspect_HS_GRID
{
0xFFFFFFFF,
0x88888888,
0xFFFFFFFF,
0x88888888
},
- //TEL_HS_GRID_SPARSE
+ // Aspect_HS_GRID_WIDE
{
0xFFFFFFFF,
0x80808080,
0x80808080,
0x80808080
},
- //TEL_HS_DIAG_45
+ // Aspect_HS_DIAGONAL_45
{
0x88888888,
0x22222222,
0x88888888,
0x22222222
},
- //TEL_HS_DIAG_135
+ // Aspect_HS_DIAGONAL_135
{
0x11111111,
0x44444444,
0x11111111,
0x44444444
},
- //TEL_HS_HORIZONTAL
+ // Aspect_HS_HORIZONTAL
{
0xFFFFFFFF,
0x00000000,
0xFFFFFFFF,
0x00000000
},
- //TEL_HS_VERTICAL
+ // Aspect_HS_VERTICAL
{
0x11111111,
0x11111111,
0x11111111,
0x11111111
},
- //TEL_HS_DIAG_45_SPARSE
+ // Aspect_HS_DIAGONAL_45_WIDE
{
0x80808080,
0x20202020,
0x08080808,
0x02020202
},
- //TEL_HS_DIAG_135_SPARSE
+ // Aspect_HS_DIAGONAL_135_WIDE
{
0x01010101,
0x04040404,
0x10101010,
0x40404040
},
- //TEL_HS_HORIZONTAL_SPARSE
+ // Aspect_HS_HORIZONTAL_WIDE
{
0xFFFFFFFF,
0x00000000,
0x00000000,
0x00000000
},
- //TEL_HS_VERTICAL_SPARSE
+ // Aspect_HS_VERTICAL_WIDE
{
0x10101010,
0x10101010,
}
};
-
// =======================================================================
// function : OpenGl_LineAttributes
// purpose :
// =======================================================================
OpenGl_LineAttributes::OpenGl_LineAttributes()
-: myPatternBase(0)
+: myPatternBase (0),
+ myTypeOfHatch (0),
+ myIsEnabled (true)
{
//
}
// Delete surface patterns
if (myPatternBase != 0)
{
+#if !defined(GL_ES_VERSION_2_0)
if (theGlCtx->IsValid())
{
- #if !defined(GL_ES_VERSION_2_0)
- glDeleteLists ((GLuint )myPatternBase, TEL_HS_USER_DEF_START);
- #endif
+ theGlCtx->core11->glDeleteLists ((GLuint )myPatternBase, TEL_HS_USER_DEF_START);
}
+#else
+ (void )theGlCtx;
+#endif
myPatternBase = 0;
}
}
// function : Init
// purpose :
// =======================================================================
-void OpenGl_LineAttributes::Init (const Handle(OpenGl_Context)& theGlCtx)
+void OpenGl_LineAttributes::Init (const OpenGl_Context* theGlCtx)
{
// Return if already initialized
if (myPatternBase != 0)
myPatternBase = glGenLists(TEL_HS_USER_DEF_START);
for (int i = 1; i < TEL_HS_USER_DEF_START; i++)
{
- glNewList ((GLuint )myPatternBase + i, GL_COMPILE);
- glPolygonStipple ((const GLubyte* )myInteriors[i < nbi ? i : 0]);
- glEndList();
+ theGlCtx->core11->glNewList ((GLuint )myPatternBase + i, GL_COMPILE);
+ theGlCtx->core11->glPolygonStipple ((const GLubyte* )myInteriors[i < nbi ? i : 0]);
+ theGlCtx->core11->glEndList();
}
+#else
+ (void )theGlCtx;
#endif
}
// function : SetTypeOfHatch
// purpose :
// =======================================================================
-void OpenGl_LineAttributes::SetTypeOfHatch (const int theType) const
+int OpenGl_LineAttributes::SetTypeOfHatch (const OpenGl_Context* theGlCtx, const int theType)
{
+ // Return if not initialized
+ if (myPatternBase == 0)
+ {
+ return 0;
+ }
+
+ const int anOldType = myTypeOfHatch;
+
#if !defined(GL_ES_VERSION_2_0)
if (theType != 0)
{
- glCallList ((GLuint )myPatternBase + (GLuint )theType);
- glEnable (GL_POLYGON_STIPPLE);
+ theGlCtx->core11->glCallList ((GLuint )myPatternBase + (GLuint )theType);
+
+ if (myIsEnabled)
+ {
+ theGlCtx->core11fwd->glEnable (GL_POLYGON_STIPPLE);
+ }
+ }
+ else
+ {
+ theGlCtx->core11fwd->glDisable (GL_POLYGON_STIPPLE);
+ }
+#else
+ (void )theGlCtx;
+#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
- glDisable (GL_POLYGON_STIPPLE);
+ {
+ theGlCtx->core11fwd->glDisable (GL_POLYGON_STIPPLE);
+ }
+#else
+ (void )theGlCtx;
#endif
+ myIsEnabled = theToEnable;
+
+ return anOldIsEnabled;
}