1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
7 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
35 \*---------------------------------------------------------------------------*/
37 //---------------------------------------------------------------------------
39 //---------------------------------------------------------------------------
44 const StateChunkClass *ShaderProgramVariableChunk::getStaticClass(void)
46 return &ShaderProgramVariableChunk::_class;
50 UInt32 ShaderProgramVariableChunk::getStaticClassId(void)
52 return getStaticClass()->getId();
55 template<class ValueT> inline
56 bool ShaderProgramVariableChunk::addUniformVariable(const Char8 *name,
59 if(_sfVariables.getValue() == NULL)
61 ShaderProgramVariablesUnrecPtr pParam =
62 ShaderProgramVariables::create();
68 return _sfVariables.getValue()->addUniformVariable(
71 editMFVariableLocations(),
74 return _sfVariables.getValue()->addUniformVariable(
82 template<class ValueT> inline
83 bool ShaderProgramVariableChunk::updateUniformVariable(const Char8 *name,
86 if(_sfVariables.getValue() == NULL)
88 ShaderProgramVariablesUnrecPtr pParam =
89 ShaderProgramVariables::create();
94 return _sfVariables.getValue()->updateUniformVariable(name, value);
97 template<class ValueT>
98 bool ShaderProgramVariableChunk::getUniformVariable(const Char8 *name,
101 if(_sfVariables.getValue() != NULL)
103 return _sfVariables.getValue()->getUniformVariable(name, value);
110 bool ShaderProgramVariableChunk::addUniformBlock(const Char8 *name,
113 if(_sfVariables.getValue() == NULL)
115 ShaderProgramVariablesUnrecPtr pParam =
116 ShaderProgramVariables::create();
118 setVariables(pParam);
122 return _sfVariables.getValue()->addUniformBlock(
125 editMFBlockLocations(),
128 return _sfVariables.getValue()->addUniformBlock(
137 bool ShaderProgramVariableChunk::updateUniformBlock(const Char8 *name,
140 if(_sfVariables.getValue() == NULL)
142 ShaderProgramVariablesUnrecPtr pParam =
143 ShaderProgramVariables::create();
145 setVariables(pParam);
148 return _sfVariables.getValue()->updateUniformBlock(name, value);
152 bool ShaderProgramVariableChunk::getUniformBlock(const Char8 *name,
155 if(_sfVariables.getValue() != NULL)
157 return _sfVariables.getValue()->getUniformBlock(name, value);
164 bool ShaderProgramVariableChunk::addShaderStorageBlock(const Char8 *name,
167 if(_sfVariables.getValue() == NULL)
169 ShaderProgramVariablesUnrecPtr pParam =
170 ShaderProgramVariables::create();
172 setVariables(pParam);
176 return _sfVariables.getValue()->addShaderStorageBlock(
179 editMFBlockLocations(),
182 return _sfVariables.getValue()->addShaderStorageBlock(
191 bool ShaderProgramVariableChunk::updateShaderStorageBlock(const Char8 *name,
194 if(_sfVariables.getValue() == NULL)
196 ShaderProgramVariablesUnrecPtr pParam =
197 ShaderProgramVariables::create();
199 setVariables(pParam);
202 return _sfVariables.getValue()->updateShaderStorageBlock(name, value);
206 bool ShaderProgramVariableChunk::getShaderStorageBlock(const Char8 *name,
209 if(_sfVariables.getValue() != NULL)
211 return _sfVariables.getValue()->getShaderStorageBlock(name, value);
218 UInt16 ShaderProgramVariableChunk::getVariableId(void)
224 void ShaderProgramVariableChunk::addDestroyedFunctor(
226 std::string createSymbol)
228 ChangedFunctorCallback oTmp;
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)
247 if(cfIt->_func == func)
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)
269 if(cfIt->_func == func)
280 void ShaderProgramVariableChunk::clearDestroyedFunctors(void)
282 _mfDestroyedFunctors.clear();