0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / OpenGl / OpenGl_AspectsProgram.hxx
1 // Copyright (c) 2019 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _OpenGl_AspectsProgram_Header
15 #define _OpenGl_AspectsProgram_Header
16
17 #include <Graphic3d_ShaderProgram.hxx>
18
19 class Graphic3d_Aspects;
20 class OpenGl_Context;
21 class OpenGl_ShaderProgram;
22
23 //! OpenGl resources for custom shading program.
24 class OpenGl_AspectsProgram
25 {
26 public:
27   DEFINE_STANDARD_ALLOC
28 public:
29   //! Empty constructor.
30   OpenGl_AspectsProgram() : myIsShaderReady (false) {}
31
32   //! Return shading program.
33   const Handle(OpenGl_ShaderProgram)& ShaderProgram (const Handle(OpenGl_Context)& theCtx,
34                                                      const Handle(Graphic3d_ShaderProgram)& theShader)
35   {
36     if (!myIsShaderReady)
37     {
38       build (theCtx, theShader);
39       myIsShaderReady = true;
40     }
41     return myShaderProgram;
42   }
43
44   //! Update shader resource up-to-date state.
45   Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
46
47   //! Release resource.
48   Standard_EXPORT void Release (OpenGl_Context* theCtx);
49
50 private:
51
52   //! Build shader resource.
53   Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
54                               const Handle(Graphic3d_ShaderProgram)& theShader);
55
56 private:
57
58   Handle(OpenGl_ShaderProgram) myShaderProgram;
59   TCollection_AsciiString      myShaderProgramId;
60   Standard_Boolean             myIsShaderReady;
61 };
62
63 #endif // _OpenGl_Aspects_Header