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 | ||
eaac0866 | 62 | Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE; |
63 | Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE; | |
64 | ||
65 | //! Update presentation aspects parameters after their modification. | |
66 | virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); } | |
2166f0fa | 67 | |
30f0ad28 | 68 | protected: |
69 | ||
70 | //! OpenGl resources | |
71 | mutable struct Resources | |
72 | { | |
73 | public: | |
74 | Resources() : myIsShaderReady (Standard_False) {} | |
75 | ||
76 | Standard_Boolean IsShaderReady() const { return myIsShaderReady; } | |
f85399e5 | 77 | void SetShaderReady() { myIsShaderReady = Standard_True; } |
78 | void ResetShaderReadiness() { myIsShaderReady = Standard_False; } | |
30f0ad28 | 79 | |
8625ef7e | 80 | Standard_EXPORT void BuildShader (const Handle(OpenGl_Context)& theCtx, |
595a42a4 | 81 | const Handle(Graphic3d_ShaderProgram)& theShader); |
30f0ad28 | 82 | |
83 | Handle(OpenGl_ShaderProgram) ShaderProgram; | |
84 | TCollection_AsciiString ShaderProgramId; | |
85 | ||
86 | private: | |
87 | ||
88 | Standard_Boolean myIsShaderReady; | |
89 | ||
90 | } myResources; | |
2166f0fa | 91 | |
b6472664 | 92 | Handle(Graphic3d_AspectText3d) myAspect; |
93 | ||
5e27df78 | 94 | public: |
95 | ||
1c35b92f | 96 | DEFINE_STANDARD_ALLOC |
5e27df78 | 97 | |
2166f0fa SK |
98 | }; |
99 | ||
a174a3c5 | 100 | #endif // OpenGl_AspectText_Header |