1 // Created on: 2011-07-13
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 #ifndef _OpenGl_AspectLine_Header
17 #define _OpenGl_AspectLine_Header
19 #include <TCollection_AsciiString.hxx>
21 #include <InterfaceGraphic_Graphic3d.hxx>
22 #include <Aspect_TypeOfLine.hxx>
24 #include <Handle_OpenGl_ShaderProgram.hxx>
26 #include <OpenGl_Element.hxx>
28 class OpenGl_AspectLine : public OpenGl_Element
33 OpenGl_AspectLine (const OpenGl_AspectLine &AnOther);
35 void SetAspect (const CALL_DEF_CONTEXTLINE &theAspect);
37 const TEL_COLOUR & Color() const { return myColor; }
38 Aspect_TypeOfLine Type() const { return myType; }
39 float Width() const { return myWidth; }
41 //! Init and return OpenGl shader program resource.
42 //! @return shader program resource.
43 const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Workspace)& theWorkspace) const
45 if (!myResources.IsShaderReady())
47 myResources.BuildShader (theWorkspace, myShaderProgram);
48 myResources.SetShaderReady();
51 return myResources.ShaderProgram;
54 virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
55 virtual void Release (const Handle(OpenGl_Context)& theContext);
60 Aspect_TypeOfLine myType;
62 Handle(Graphic3d_ShaderProgram) myShaderProgram;
67 mutable struct Resources
70 Resources() : myIsShaderReady (Standard_False) {}
72 Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
73 void SetShaderReady() { myIsShaderReady = Standard_True; }
74 void ResetShaderReadiness() { myIsShaderReady = Standard_False; }
76 void BuildShader (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_ShaderProgram)& theShader);
78 Handle(OpenGl_ShaderProgram) ShaderProgram;
79 TCollection_AsciiString ShaderProgramId;
83 Standard_Boolean myIsShaderReady;
91 #endif //_OpenGl_AspectLine_Header