Back to home page

EIC code displayed by LXR

 
 

    


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

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 
0031   //! Empty constructor
0032   OpenGl_SetOfPrograms() {}
0033 
0034   //! Access program by index
0035   Handle(OpenGl_ShaderProgram)& ChangeValue (Standard_Integer theProgramBits) { return myPrograms[theProgramBits]; }
0036 
0037 protected:
0038   Handle(OpenGl_ShaderProgram) myPrograms[Graphic3d_ShaderFlags_NB]; //!< programs array
0039 };
0040 
0041 //! Alias to 2D programs array of predefined length
0042 class OpenGl_SetOfShaderPrograms : public Standard_Transient
0043 {
0044   DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfShaderPrograms, Standard_Transient)
0045 public:
0046 
0047   //! Empty constructor
0048   OpenGl_SetOfShaderPrograms() {}
0049 
0050   //! Constructor
0051   OpenGl_SetOfShaderPrograms (const Handle(OpenGl_SetOfPrograms)& thePrograms)
0052   {
0053     for (Standard_Integer aSetIter = 0; aSetIter < Graphic3d_TypeOfShadingModel_NB - 1; ++aSetIter)
0054     {
0055       myPrograms[aSetIter] = thePrograms;
0056     }
0057   }
0058 
0059   //! Access program by index
0060   Handle(OpenGl_ShaderProgram)& ChangeValue (Graphic3d_TypeOfShadingModel theShadingModel,
0061                                              Standard_Integer theProgramBits)
0062   {
0063     Handle(OpenGl_SetOfPrograms)& aSet = myPrograms[theShadingModel - 1];
0064     if (aSet.IsNull())
0065     {
0066       aSet = new OpenGl_SetOfPrograms();
0067     }
0068     return aSet->ChangeValue (theProgramBits);
0069   }
0070 
0071 protected:
0072   Handle(OpenGl_SetOfPrograms) myPrograms[Graphic3d_TypeOfShadingModel_NB - 1]; //!< programs array, excluding Graphic3d_TypeOfShadingModel_Unlit
0073 };
0074 
0075 typedef NCollection_DataMap<TCollection_AsciiString, Handle(OpenGl_SetOfShaderPrograms)> OpenGl_MapOfShaderPrograms;
0076 
0077 #endif // _OpenGl_SetOfShaderPrograms_HeaderFile