1 // Created on: 2011-10-25
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
21 #include <OpenGl_GlCore11.hxx>
23 #include <OpenGl_Display.hxx>
34 #define DASH_DOT_LS 0xFF18
35 #define DASH_LS 0xFFC0
36 #define DASH_DDOT_LS 0xFF24
38 static const unsigned int myInteriors[TEL_HS_USER_DEF_START][32] =
110 //TEL_HS_CROSS_SPARSE
355 //TEL_HS_DIAG_45_SPARSE
390 //TEL_HS_DIAG_135_SPARSE
425 //TEL_HS_HORIZONTAL_SPARSE
460 //TEL_HS_VERTICAL_SPARSE
497 /*----------------------------------------------------------------------*/
500 void OpenGl_Display::InitAttributes ()
502 // Return if already initialized
503 if (myLinestyleBase) return;
505 myLinestyleBase = glGenLists(5);
509 glNewList( (GLuint)myLinestyleBase+(GLuint)Aspect_TOL_DASH, GL_COMPILE );
510 glLineStipple(1, DASH_LS );
513 glNewList( (GLuint)myLinestyleBase+(GLuint)Aspect_TOL_DOT, GL_COMPILE );
514 glLineStipple(1, DOT_LS );
517 glNewList( (GLuint)myLinestyleBase+(GLuint)Aspect_TOL_DOTDASH, GL_COMPILE );
518 glLineStipple(1, DASH_DOT_LS );
521 glNewList( (GLuint)myLinestyleBase+(GLuint)Aspect_TOL_USERDEFINED, GL_COMPILE );
522 glLineStipple(1, DASH_DDOT_LS );
527 * need 32x32 stipple patterns
529 const int nbi = sizeof(myInteriors)/(32*sizeof(unsigned int));
530 myPatternBase = glGenLists(TEL_HS_USER_DEF_START);
532 for( i = 1; i < TEL_HS_USER_DEF_START; i++ )
534 glNewList( (GLuint)myPatternBase + i, GL_COMPILE );
535 glPolygonStipple((const GLubyte *) (myInteriors[i<nbi? i : 0]));
539 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
542 /*----------------------------------------------------------------------*/
544 void OpenGl_Display::SetTypeOfLine (const Aspect_TypeOfLine AType) const
546 if (AType != Aspect_TOL_SOLID)
548 glCallList((GLuint)myLinestyleBase+(GLuint)AType);
549 glEnable( GL_LINE_STIPPLE );
551 gl2psEnable( GL2PS_LINE_STIPPLE );
556 glDisable( GL_LINE_STIPPLE );
558 gl2psDisable( GL2PS_LINE_STIPPLE );
563 /*----------------------------------------------------------------------*/
565 void OpenGl_Display::SetTypeOfHatch (const int AType) const
569 glCallList((GLuint)myPatternBase+(GLuint)AType);
570 glEnable( GL_POLYGON_STIPPLE );
573 glDisable( GL_POLYGON_STIPPLE );
576 /*----------------------------------------------------------------------*/