changed: gcc8 base update
[opensg.git] / Source / System / State / Shader / Chunks / OSGShaderProgramVariableChunk.inl
blob2b5cdb94a2e7e0dcc166dc653278db8886a84c9f
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *               Copyright (C) 2000-2006 by the OpenSG Forum                 *
6  *                                                                           *
7  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
8  *                                                                           *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
11  *                                License                                    *
12  *                                                                           *
13  * This library is free software; you can redistribute it and/or modify it   *
14  * under the terms of the GNU Library General Public License as published    *
15  * by the Free Software Foundation, version 2.                               *
16  *                                                                           *
17  * This library is distributed in the hope that it will be useful, but       *
18  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
20  * Library General Public License for more details.                          *
21  *                                                                           *
22  * You should have received a copy of the GNU Library General Public         *
23  * License along with this library; if not, write to the Free Software       *
24  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
25  *                                                                           *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
28  *                                Changes                                    *
29  *                                                                           *
30  *                                                                           *
31  *                                                                           *
32  *                                                                           *
33  *                                                                           *
34  *                                                                           *
35 \*---------------------------------------------------------------------------*/
37 //---------------------------------------------------------------------------
38 //  Includes
39 //---------------------------------------------------------------------------
41 OSG_BEGIN_NAMESPACE
43 inline
44 const StateChunkClass *ShaderProgramVariableChunk::getStaticClass(void)
46     return &ShaderProgramVariableChunk::_class;
49 inline
50 UInt32 ShaderProgramVariableChunk::getStaticClassId(void)
52     return getStaticClass()->getId();
55 template<class ValueT> inline
56 bool ShaderProgramVariableChunk::addUniformVariable(const Char8  *name, 
57                                                     const ValueT &value)
59     if(_sfVariables.getValue() == NULL)
60     {
61         ShaderProgramVariablesUnrecPtr pParam = 
62             ShaderProgramVariables::create();
64         setVariables(pParam);
65     }
67 #if 0
68     return _sfVariables.getValue()->addUniformVariable(
69         name, 
70         value,
71         editMFVariableLocations(),
72         NULL                     );
73 #else
74     return _sfVariables.getValue()->addUniformVariable(
75         name, 
76         value,
77         NULL,
78         NULL);
79 #endif
82 template<class ValueT> inline
83 bool ShaderProgramVariableChunk::updateUniformVariable(const Char8  *name, 
84                                                        const ValueT &value)
86     if(_sfVariables.getValue() == NULL)
87     {
88         ShaderProgramVariablesUnrecPtr pParam = 
89             ShaderProgramVariables::create();
91         setVariables(pParam);
92     }
94     return _sfVariables.getValue()->updateUniformVariable(name, value);
97 template<class ValueT>
98 bool ShaderProgramVariableChunk::getUniformVariable(const Char8  *name, 
99                                                           ValueT &value)
101     if(_sfVariables.getValue() != NULL)
102     {
103         return _sfVariables.getValue()->getUniformVariable(name, value);
104     }
106     return false;
109 inline
110 bool ShaderProgramVariableChunk::addUniformBlock(const Char8  *name, 
111                                                        UInt32  value)
113     if(_sfVariables.getValue() == NULL)
114     {
115         ShaderProgramVariablesUnrecPtr pParam = 
116             ShaderProgramVariables::create();
118         setVariables(pParam);
119     }
121 #if 0
122     return _sfVariables.getValue()->addUniformBlock(
123         name, 
124         value,
125         editMFBlockLocations(),
126         NULL                     );
127 #else
128     return _sfVariables.getValue()->addUniformBlock(
129         name, 
130         value,
131         NULL,
132         NULL                     );
133 #endif
136 inline
137 bool ShaderProgramVariableChunk::updateUniformBlock(const Char8  *name, 
138                                                               UInt32  value)
140     if(_sfVariables.getValue() == NULL)
141     {
142         ShaderProgramVariablesUnrecPtr pParam = 
143             ShaderProgramVariables::create();
145         setVariables(pParam);
146     }
148     return _sfVariables.getValue()->updateUniformBlock(name, value);
151 inline
152 bool ShaderProgramVariableChunk::getUniformBlock(const Char8  *name, 
153                                                            UInt32 &value)
155     if(_sfVariables.getValue() != NULL)
156     {
157         return _sfVariables.getValue()->getUniformBlock(name, value);
158     }
160     return false;
163 inline
164 bool ShaderProgramVariableChunk::addShaderStorageBlock(const Char8  *name, 
165                                                              UInt32  value)
167     if(_sfVariables.getValue() == NULL)
168     {
169         ShaderProgramVariablesUnrecPtr pParam = 
170             ShaderProgramVariables::create();
172         setVariables(pParam);
173     }
175 #if 0
176     return _sfVariables.getValue()->addShaderStorageBlock(
177         name, 
178         value,
179         editMFBlockLocations(),
180         NULL                     );
181 #else
182     return _sfVariables.getValue()->addShaderStorageBlock(
183         name, 
184         value,
185         NULL,
186         NULL                     );
187 #endif
190 inline
191 bool ShaderProgramVariableChunk::updateShaderStorageBlock(const Char8  *name, 
192                                                                 UInt32  value)
194     if(_sfVariables.getValue() == NULL)
195     {
196         ShaderProgramVariablesUnrecPtr pParam = 
197             ShaderProgramVariables::create();
199         setVariables(pParam);
200     }
202     return _sfVariables.getValue()->updateShaderStorageBlock(name, value);
205 inline
206 bool ShaderProgramVariableChunk::getShaderStorageBlock(const Char8  *name, 
207                                                              UInt32 &value)
209     if(_sfVariables.getValue() != NULL)
210     {
211         return _sfVariables.getValue()->getShaderStorageBlock(name, value);
212     }
214     return false;
217 inline
218 UInt16 ShaderProgramVariableChunk::getVariableId(void)
220     return _uiVarId;
223 inline
224 void ShaderProgramVariableChunk::addDestroyedFunctor(
225     ChangedFunctor func,
226     std::string    createSymbol)
228     ChangedFunctorCallback oTmp;
230     oTmp._func         = func;
231     oTmp._createSymbol = createSymbol;
233     _mfDestroyedFunctors.push_back(oTmp);
236 template<class FunctorT> inline
237 void ShaderProgramVariableChunk::subDestroyedFunctor(FunctorT func)
239     MFChangedFunctorCallback::iterator       cfIt = 
240         _mfDestroyedFunctors.begin();
242     MFChangedFunctorCallback::const_iterator cfEnd= 
243         _mfDestroyedFunctors.end();
245     for(; cfIt != cfEnd; ++cfIt)
246     {
247         if(cfIt->_func == func)
248             break;
249     }
251     if(cfIt != cfEnd)
252         _mfDestroyedFunctors.erase(cfIt);
255 template<class FunctorT> inline
256 bool ShaderProgramVariableChunk::hasDestroyedFunctor(FunctorT func)
258     bool returnValue = false;
260     MFChangedFunctorCallback::iterator       cfIt = 
261         _mfDestroyedFunctors.begin();
263     MFChangedFunctorCallback::const_iterator cfEnd= 
264         _mfDestroyedFunctors.end();
267     for(; cfIt != cfEnd; ++cfIt)
268     {
269         if(cfIt->_func == func)
270         {
271             returnValue = true;
272             break;
273         }
274     }
275     
276     return returnValue;
279 inline 
280 void ShaderProgramVariableChunk::clearDestroyedFunctors(void)
282     _mfDestroyedFunctors.clear();
285 OSG_END_NAMESPACE