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_LineAttributes.hxx>
19 #include <OpenGl_Context.hxx>
21 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_LineAttributes,OpenGl_Resource)
23 // =======================================================================
24 // function : OpenGl_LineAttributes
26 // =======================================================================
27 OpenGl_LineAttributes::OpenGl_LineAttributes()
32 // =======================================================================
33 // function : ~OpenGl_LineAttributes
35 // =======================================================================
36 OpenGl_LineAttributes::~OpenGl_LineAttributes()
41 // =======================================================================
44 // =======================================================================
45 void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx)
47 #if !defined(GL_ES_VERSION_2_0)
49 && theGlCtx->IsValid())
51 for (OpenGl_MapOfHatchStylesAndIds::Iterator anIter (myStyles); anIter.More(); anIter.Next())
53 theGlCtx->core11ffp->glDeleteLists ((GLuint)anIter.Value(), 1);
62 // =======================================================================
65 // =======================================================================
66 unsigned int OpenGl_LineAttributes::init (const OpenGl_Context* theGlCtx,
67 const Handle(Graphic3d_HatchStyle)& theStyle)
69 #if !defined(GL_ES_VERSION_2_0)
70 const unsigned int aListId = theGlCtx->core11ffp->glGenLists(1);
71 theGlCtx->core11ffp->glNewList ((GLuint)aListId, GL_COMPILE);
72 theGlCtx->core11ffp->glPolygonStipple ((const GLubyte*)theStyle->Pattern());
73 theGlCtx->core11ffp->glEndList();
82 // =======================================================================
83 // function : SetTypeOfHatch
85 // =======================================================================
86 bool OpenGl_LineAttributes::SetTypeOfHatch (const OpenGl_Context* theGlCtx,
87 const Handle(Graphic3d_HatchStyle)& theStyle)
90 || theStyle->HatchType() == Aspect_HS_SOLID
91 || theGlCtx->core11ffp == NULL)
96 unsigned int aGpuListId = 0;
97 if (!myStyles.Find (theStyle, aGpuListId))
99 aGpuListId = init (theGlCtx, theStyle);
100 myStyles.Bind (theStyle, aGpuListId);
103 #if !defined(GL_ES_VERSION_2_0)
104 theGlCtx->core11ffp->glCallList ((GLuint)aGpuListId);