0024752: Visualization - inherit OpenGl_Group from Graphic3d_Group
[occt.git] / src / OpenGl / OpenGl_AspectLine.hxx
CommitLineData
b311480e 1// Created on: 2011-07-13
2// Created by: Sergey ZERCHANINOV
973c2be1 3// Copyright (c) 2011-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
2166f0fa
SK
16#ifndef _OpenGl_AspectLine_Header
17#define _OpenGl_AspectLine_Header
18
30f0ad28 19#include <TCollection_AsciiString.hxx>
20
bf75be98 21#include <InterfaceGraphic_Graphic3d.hxx>
2166f0fa 22#include <Aspect_TypeOfLine.hxx>
b64d84be 23#include <Graphic3d_CAspectLine.hxx>
2166f0fa 24
30f0ad28 25#include <Handle_OpenGl_ShaderProgram.hxx>
26
2166f0fa
SK
27#include <OpenGl_Element.hxx>
28
29class OpenGl_AspectLine : public OpenGl_Element
30{
31 public:
32
33 OpenGl_AspectLine ();
34 OpenGl_AspectLine (const OpenGl_AspectLine &AnOther);
2166f0fa 35
fd4a6963 36 void SetAspect (const CALL_DEF_CONTEXTLINE &theAspect);
2166f0fa
SK
37
38 const TEL_COLOUR & Color() const { return myColor; }
39 Aspect_TypeOfLine Type() const { return myType; }
40 float Width() const { return myWidth; }
41
30f0ad28 42 //! Init and return OpenGl shader program resource.
43 //! @return shader program resource.
44 const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Workspace)& theWorkspace) const
45 {
46 if (!myResources.IsShaderReady())
47 {
48 myResources.BuildShader (theWorkspace, myShaderProgram);
49 myResources.SetShaderReady();
50 }
51
52 return myResources.ShaderProgram;
53 }
54
5e27df78 55 virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
56 virtual void Release (const Handle(OpenGl_Context)& theContext);
2166f0fa 57
30f0ad28 58protected:
59
60 TEL_COLOUR myColor;
61 Aspect_TypeOfLine myType;
62 float myWidth;
63 Handle(Graphic3d_ShaderProgram) myShaderProgram;
64
65protected:
66
67 //! OpenGl resources
68 mutable struct Resources
69 {
70 public:
71 Resources() : myIsShaderReady (Standard_False) {}
72
73 Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
f85399e5 74 void SetShaderReady() { myIsShaderReady = Standard_True; }
75 void ResetShaderReadiness() { myIsShaderReady = Standard_False; }
30f0ad28 76
77 void BuildShader (const Handle(OpenGl_Workspace)& theWS, const Handle(Graphic3d_ShaderProgram)& theShader);
78
79 Handle(OpenGl_ShaderProgram) ShaderProgram;
80 TCollection_AsciiString ShaderProgramId;
81
82 private:
83
84 Standard_Boolean myIsShaderReady;
2166f0fa 85
30f0ad28 86 } myResources;
2166f0fa
SK
87
88 public:
1c35b92f 89 DEFINE_STANDARD_ALLOC
2166f0fa
SK
90};
91
92#endif //_OpenGl_AspectLine_Header