1 // Created on: 2011-10-25
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <OpenGl_GlCore11.hxx>
18 #include <OpenGl_Display.hxx>
29 #define DASH_DOT_LS 0xFF18
30 #define DASH_LS 0xFFC0
31 #define DASH_DDOT_LS 0xFF24
33 static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] =
105 //TEL_HS_CROSS_SPARSE
350 //TEL_HS_DIAG_45_SPARSE
385 //TEL_HS_DIAG_135_SPARSE
420 //TEL_HS_HORIZONTAL_SPARSE
455 //TEL_HS_VERTICAL_SPARSE
492 /*----------------------------------------------------------------------*/
495 void OpenGl_Display::InitAttributes ()
497 // Return if already initialized
498 if (myLinestyleBase) return;
500 myLinestyleBase = glGenLists(5);
504 glNewList( (GLuint)myLinestyleBase+(GLuint)Aspect_TOL_DASH, GL_COMPILE );
505 glLineStipple(1, DASH_LS );
508 glNewList( (GLuint)myLinestyleBase+(GLuint)Aspect_TOL_DOT, GL_COMPILE );
509 glLineStipple(1, DOT_LS );
512 glNewList( (GLuint)myLinestyleBase+(GLuint)Aspect_TOL_DOTDASH, GL_COMPILE );
513 glLineStipple(1, DASH_DOT_LS );
516 glNewList( (GLuint)myLinestyleBase+(GLuint)Aspect_TOL_USERDEFINED, GL_COMPILE );
517 glLineStipple(1, DASH_DDOT_LS );
522 * need 32x32 stipple patterns
524 const int nbi = sizeof(myInteriors)/(32*sizeof(unsigned int));
525 myPatternBase = glGenLists(TEL_HS_USER_DEF_START);
527 for( i = 1; i < TEL_HS_USER_DEF_START; i++ )
529 glNewList( (GLuint)myPatternBase + i, GL_COMPILE );
530 glPolygonStipple((const GLubyte *) (myInteriors[i<nbi? i : 0]));
534 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
537 /*----------------------------------------------------------------------*/
539 void OpenGl_Display::SetTypeOfLine (const Aspect_TypeOfLine AType) const
541 if (AType != Aspect_TOL_SOLID)
543 glCallList((GLuint)myLinestyleBase+(GLuint)AType);
544 glEnable( GL_LINE_STIPPLE );
546 gl2psEnable( GL2PS_LINE_STIPPLE );
551 glDisable( GL_LINE_STIPPLE );
553 gl2psDisable( GL2PS_LINE_STIPPLE );
558 /*----------------------------------------------------------------------*/
560 void OpenGl_Display::SetTypeOfHatch (const int AType) const
564 glCallList((GLuint)myPatternBase+(GLuint)AType);
565 glEnable( GL_POLYGON_STIPPLE );
568 glDisable( GL_POLYGON_STIPPLE );
571 /*----------------------------------------------------------------------*/