Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:21

0001 // Copyright (c) 2019 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _OpenGl_AspectsProgram_Header
0015 #define _OpenGl_AspectsProgram_Header
0016 
0017 #include <Graphic3d_ShaderProgram.hxx>
0018 
0019 class Graphic3d_Aspects;
0020 class OpenGl_Context;
0021 class OpenGl_ShaderProgram;
0022 
0023 //! OpenGl resources for custom shading program.
0024 class OpenGl_AspectsProgram
0025 {
0026 public:
0027   DEFINE_STANDARD_ALLOC
0028 public:
0029   //! Empty constructor.
0030   OpenGl_AspectsProgram() : myIsShaderReady (false) {}
0031 
0032   //! Return shading program.
0033   const Handle(OpenGl_ShaderProgram)& ShaderProgram (const Handle(OpenGl_Context)& theCtx,
0034                                                      const Handle(Graphic3d_ShaderProgram)& theShader)
0035   {
0036     if (!myIsShaderReady)
0037     {
0038       build (theCtx, theShader);
0039       myIsShaderReady = true;
0040     }
0041     return myShaderProgram;
0042   }
0043 
0044   //! Update shader resource up-to-date state.
0045   Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
0046 
0047   //! Release resource.
0048   Standard_EXPORT void Release (OpenGl_Context* theCtx);
0049 
0050 private:
0051 
0052   //! Build shader resource.
0053   Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
0054                               const Handle(Graphic3d_ShaderProgram)& theShader);
0055 
0056 private:
0057 
0058   Handle(OpenGl_ShaderProgram) myShaderProgram;
0059   TCollection_AsciiString      myShaderProgramId;
0060   Standard_Boolean             myIsShaderReady;
0061 };
0062 
0063 #endif // _OpenGl_Aspects_Header