Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-07-13 |
2 | // Created by: Sergey ZERCHANINOV | |
a174a3c5 | 3 | // Copyright (c) 2011-2013 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_AspectText_Header |
17 | #define OpenGl_AspectText_Header | |
18 | ||
eeaaaefb | 19 | #include <Font_FontAspect.hxx> |
b6472664 | 20 | #include <Graphic3d_AspectText3d.hxx> |
2166f0fa | 21 | |
a174a3c5 | 22 | #include <TCollection_AsciiString.hxx> |
23 | ||
2166f0fa SK |
24 | #include <OpenGl_Element.hxx> |
25 | ||
c04c30b3 | 26 | class OpenGl_ShaderProgram; |
27 | ||
a174a3c5 | 28 | //! Text representation parameters |
2166f0fa SK |
29 | class OpenGl_AspectText : public OpenGl_Element |
30 | { | |
2166f0fa | 31 | |
5e27df78 | 32 | public: |
33 | ||
b6472664 | 34 | //! Empty constructor. |
6a240ff8 | 35 | Standard_EXPORT OpenGl_AspectText(); |
a174a3c5 | 36 | |
b6472664 | 37 | //! Create and assign parameters. |
38 | Standard_EXPORT OpenGl_AspectText (const Handle(Graphic3d_AspectText3d)& theAspect); | |
a174a3c5 | 39 | |
b6472664 | 40 | //! Destructor. |
41 | Standard_EXPORT virtual ~OpenGl_AspectText(); | |
a174a3c5 | 42 | |
b6472664 | 43 | //! Return text aspect. |
44 | const Handle(Graphic3d_AspectText3d)& Aspect() const { return myAspect; } | |
a174a3c5 | 45 | |
b6472664 | 46 | //! Assign new parameters. |
47 | Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectText3d)& theAspect); | |
2166f0fa | 48 | |
30f0ad28 | 49 | //! Init and return OpenGl shader program resource. |
50 | //! @return shader program resource. | |
8625ef7e | 51 | const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const |
30f0ad28 | 52 | { |
53 | if (!myResources.IsShaderReady()) | |
54 | { | |
b6472664 | 55 | myResources.BuildShader (theCtx, myAspect->ShaderProgram()); |
30f0ad28 | 56 | myResources.SetShaderReady(); |
57 | } | |
58 | ||
59 | return myResources.ShaderProgram; | |
60 | } | |
61 | ||
6a240ff8 | 62 | Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; |
10b9c7df | 63 | Standard_EXPORT virtual void Release (OpenGl_Context* theContext); |
2166f0fa | 64 | |
30f0ad28 | 65 | protected: |
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 | |
8625ef7e | 77 | Standard_EXPORT void BuildShader (const Handle(OpenGl_Context)& theCtx, |
595a42a4 | 78 | const Handle(Graphic3d_ShaderProgram)& theShader); |
30f0ad28 | 79 | |
80 | Handle(OpenGl_ShaderProgram) ShaderProgram; | |
81 | TCollection_AsciiString ShaderProgramId; | |
82 | ||
83 | private: | |
84 | ||
85 | Standard_Boolean myIsShaderReady; | |
86 | ||
87 | } myResources; | |
2166f0fa | 88 | |
b6472664 | 89 | Handle(Graphic3d_AspectText3d) myAspect; |
90 | ||
5e27df78 | 91 | public: |
92 | ||
1c35b92f | 93 | DEFINE_STANDARD_ALLOC |
5e27df78 | 94 | |
2166f0fa SK |
95 | }; |
96 | ||
a174a3c5 | 97 | #endif // OpenGl_AspectText_Header |