Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 09:18:29

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()
0031       : myIsShaderReady(false)
0032   {
0033   }
0034 
0035   //! Return shading program.
0036   const occ::handle<OpenGl_ShaderProgram>& ShaderProgram(
0037     const occ::handle<OpenGl_Context>&          theCtx,
0038     const occ::handle<Graphic3d_ShaderProgram>& theShader)
0039   {
0040     if (!myIsShaderReady)
0041     {
0042       build(theCtx, theShader);
0043       myIsShaderReady = true;
0044     }
0045     return myShaderProgram;
0046   }
0047 
0048   //! Update shader resource up-to-date state.
0049   Standard_EXPORT void UpdateRediness(const occ::handle<Graphic3d_Aspects>& theAspect);
0050 
0051   //! Release resource.
0052   Standard_EXPORT void Release(OpenGl_Context* theCtx);
0053 
0054 private:
0055   //! Build shader resource.
0056   Standard_EXPORT void build(const occ::handle<OpenGl_Context>&          theCtx,
0057                              const occ::handle<Graphic3d_ShaderProgram>& theShader);
0058 
0059 private:
0060   occ::handle<OpenGl_ShaderProgram> myShaderProgram;
0061   TCollection_AsciiString           myShaderProgramId;
0062   bool                              myIsShaderReady;
0063 };
0064 
0065 #endif // _OpenGl_Aspects_Header