Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-10 09:17:47

0001 // Created on: 2014-10-08
0002 // Created by: Kirill Gavrilov
0003 // Copyright (c) 2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _OpenGl_SetOfShaderPrograms_HeaderFile
0017 #define _OpenGl_SetOfShaderPrograms_HeaderFile
0018 
0019 #include <Graphic3d_ShaderFlags.hxx>
0020 #include <Graphic3d_TypeOfShadingModel.hxx>
0021 #include <NCollection_DataMap.hxx>
0022 
0023 class OpenGl_ShaderProgram;
0024 
0025 //! Alias to programs array of predefined length
0026 class OpenGl_SetOfPrograms : public Standard_Transient
0027 {
0028   DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfPrograms, Standard_Transient)
0029 public:
0030   //! Empty constructor
0031   OpenGl_SetOfPrograms() {}
0032 
0033   //! Access program by index
0034   Handle(OpenGl_ShaderProgram)& ChangeValue(Standard_Integer theProgramBits)
0035   {
0036     return myPrograms[theProgramBits];
0037   }
0038 
0039 protected:
0040   Handle(OpenGl_ShaderProgram) myPrograms[Graphic3d_ShaderFlags_NB]; //!< programs array
0041 };
0042 
0043 //! Alias to 2D programs array of predefined length
0044 class OpenGl_SetOfShaderPrograms : public Standard_Transient
0045 {
0046   DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfShaderPrograms, Standard_Transient)
0047 public:
0048   //! Empty constructor
0049   OpenGl_SetOfShaderPrograms() {}
0050 
0051   //! Constructor
0052   OpenGl_SetOfShaderPrograms(const Handle(OpenGl_SetOfPrograms)& thePrograms)
0053   {
0054     for (Standard_Integer aSetIter = 0; aSetIter < Graphic3d_TypeOfShadingModel_NB - 1; ++aSetIter)
0055     {
0056       myPrograms[aSetIter] = thePrograms;
0057     }
0058   }
0059 
0060   //! Access program by index
0061   Handle(OpenGl_ShaderProgram)& ChangeValue(Graphic3d_TypeOfShadingModel theShadingModel,
0062                                             Standard_Integer             theProgramBits)
0063   {
0064     Handle(OpenGl_SetOfPrograms)& aSet = myPrograms[theShadingModel - 1];
0065     if (aSet.IsNull())
0066     {
0067       aSet = new OpenGl_SetOfPrograms();
0068     }
0069     return aSet->ChangeValue(theProgramBits);
0070   }
0071 
0072 protected:
0073   // clang-format off
0074   Handle(OpenGl_SetOfPrograms) myPrograms[Graphic3d_TypeOfShadingModel_NB - 1]; //!< programs array, excluding Graphic3d_TypeOfShadingModel_Unlit
0075   // clang-format on
0076 };
0077 
0078 typedef NCollection_DataMap<TCollection_AsciiString, Handle(OpenGl_SetOfShaderPrograms)>
0079   OpenGl_MapOfShaderPrograms;
0080 
0081 #endif // _OpenGl_SetOfShaderPrograms_HeaderFile