256f9ac0 |
1 | // Created on: 2014-10-08 |
2 | // Created by: Kirill Gavrilov |
3 | // Copyright (c) 2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _OpenGl_SetOfShaderPrograms_HeaderFile |
17 | #define _OpenGl_SetOfShaderPrograms_HeaderFile |
18 | |
4bf072e4 |
19 | #include <Graphic3d_ShaderFlags.hxx> |
dc89236f |
20 | #include <Graphic3d_TypeOfShadingModel.hxx> |
256f9ac0 |
21 | #include <NCollection_DataMap.hxx> |
256f9ac0 |
22 | |
4bf072e4 |
23 | class OpenGl_ShaderProgram; |
256f9ac0 |
24 | |
25 | //! Alias to programs array of predefined length |
6ef0d6f1 |
26 | class OpenGl_SetOfPrograms : public Standard_Transient |
27 | { |
28 | DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfPrograms, Standard_Transient) |
29 | public: |
30 | |
31 | //! Empty constructor |
32 | OpenGl_SetOfPrograms() {} |
33 | |
34 | //! Access program by index |
35 | Handle(OpenGl_ShaderProgram)& ChangeValue (Standard_Integer theProgramBits) { return myPrograms[theProgramBits]; } |
36 | |
37 | protected: |
4bf072e4 |
38 | Handle(OpenGl_ShaderProgram) myPrograms[Graphic3d_ShaderFlags_NB]; //!< programs array |
6ef0d6f1 |
39 | }; |
40 | |
41 | //! Alias to 2D programs array of predefined length |
256f9ac0 |
42 | class OpenGl_SetOfShaderPrograms : public Standard_Transient |
43 | { |
dc89236f |
44 | DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfShaderPrograms, Standard_Transient) |
256f9ac0 |
45 | public: |
46 | |
47 | //! Empty constructor |
48 | OpenGl_SetOfShaderPrograms() {} |
49 | |
6ef0d6f1 |
50 | //! Constructor |
51 | OpenGl_SetOfShaderPrograms (const Handle(OpenGl_SetOfPrograms)& thePrograms) |
52 | { |
53 | for (Standard_Integer aSetIter = 0; aSetIter < Graphic3d_TypeOfShadingModel_NB - 1; ++aSetIter) |
54 | { |
55 | myPrograms[aSetIter] = thePrograms; |
56 | } |
57 | } |
58 | |
256f9ac0 |
59 | //! Access program by index |
dc89236f |
60 | Handle(OpenGl_ShaderProgram)& ChangeValue (Graphic3d_TypeOfShadingModel theShadingModel, |
61 | Standard_Integer theProgramBits) |
62 | { |
6ef0d6f1 |
63 | Handle(OpenGl_SetOfPrograms)& aSet = myPrograms[theShadingModel - 1]; |
64 | if (aSet.IsNull()) |
65 | { |
66 | aSet = new OpenGl_SetOfPrograms(); |
67 | } |
68 | return aSet->ChangeValue (theProgramBits); |
dc89236f |
69 | } |
256f9ac0 |
70 | |
71 | protected: |
6ef0d6f1 |
72 | Handle(OpenGl_SetOfPrograms) myPrograms[Graphic3d_TypeOfShadingModel_NB - 1]; //!< programs array, excluding Graphic3d_TOSM_UNLIT |
256f9ac0 |
73 | }; |
74 | |
256f9ac0 |
75 | typedef NCollection_DataMap<TCollection_AsciiString, Handle(OpenGl_SetOfShaderPrograms)> OpenGl_MapOfShaderPrograms; |
76 | |
77 | #endif // _OpenGl_SetOfShaderPrograms_HeaderFile |