changed: gcc8 base update
[opensg.git] / Source / System / State / Shader / SHL / OSGSimpleSHLChunkBase.cpp
blob84e3496d754ad591b47a21242c18245e901f2d13
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
41 ** **
42 ** This file is automatically generated. **
43 ** **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
46 ** **
47 ** Do not change this file, changes should be done in the derived **
48 ** class SimpleSHLChunk!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #ifdef WIN32
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
59 #endif
61 #include "OSGConfig.h"
65 #include "OSGShaderProgramVariables.h" // Variables Class
67 #include "OSGSimpleSHLChunkBase.h"
68 #include "OSGSimpleSHLChunk.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::SimpleSHLChunk
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var std::string SimpleSHLChunkBase::_sfVertexProgram
87 vertex program source
90 /*! \var std::string SimpleSHLChunkBase::_sfTessControlProgram
91 tessalation control program source
94 /*! \var std::string SimpleSHLChunkBase::_sfTessEvaluationProgram
95 tessalation eval program source
98 /*! \var std::string SimpleSHLChunkBase::_sfGeometryProgram
99 geometry program source
102 /*! \var std::string SimpleSHLChunkBase::_sfFragmentProgram
103 fragment program source
106 /*! \var bool SimpleSHLChunkBase::_sfCgFrontEnd
110 /*! \var ShaderProgramVariables * SimpleSHLChunkBase::_sfVariables
111 fragment program object
114 /*! \var Int32 SimpleSHLChunkBase::_mfVariableLocations
115 fragment program object
118 /*! \var Int32 SimpleSHLChunkBase::_mfProceduralVariableLocations
119 fragment program object
122 /*! \var UInt32 SimpleSHLChunkBase::_sfGLId
126 /*! \var bool SimpleSHLChunkBase::_sfPointSize
127 Flag to set whether the shader can change the point size.
131 /***************************************************************************\
132 * FieldType/FieldTrait Instantiation *
133 \***************************************************************************/
135 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
136 PointerType FieldTraits<SimpleSHLChunk *, nsOSG>::_type(
137 "SimpleSHLChunkPtr",
138 "ShaderProgramChunkPtr",
139 SimpleSHLChunk::getClassType(),
140 nsOSG);
141 #endif
143 OSG_FIELDTRAITS_GETTYPE_NS(SimpleSHLChunk *, nsOSG)
145 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
146 SimpleSHLChunk *,
147 nsOSG)
149 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
150 SimpleSHLChunk *,
151 nsOSG)
153 /***************************************************************************\
154 * Field Description *
155 \***************************************************************************/
157 void SimpleSHLChunkBase::classDescInserter(TypeObject &oType)
159 FieldDescriptionBase *pDesc = NULL;
162 pDesc = new SFString::Description(
163 SFString::getClassType(),
164 "vertexProgram",
165 "vertex program source\n",
166 VertexProgramFieldId, VertexProgramFieldMask,
167 false,
168 (Field::SFDefaultFlags | Field::FStdAccess),
169 static_cast<FieldEditMethodSig>(&SimpleSHLChunk::editHandleVertexProgram),
170 static_cast<FieldGetMethodSig >(&SimpleSHLChunk::getHandleVertexProgram));
172 oType.addInitialDesc(pDesc);
174 pDesc = new SFString::Description(
175 SFString::getClassType(),
176 "tessControlProgram",
177 "tessalation control program source\n",
178 TessControlProgramFieldId, TessControlProgramFieldMask,
179 false,
180 (Field::SFDefaultFlags | Field::FStdAccess),
181 static_cast<FieldEditMethodSig>(&SimpleSHLChunk::editHandleTessControlProgram),
182 static_cast<FieldGetMethodSig >(&SimpleSHLChunk::getHandleTessControlProgram));
184 oType.addInitialDesc(pDesc);
186 pDesc = new SFString::Description(
187 SFString::getClassType(),
188 "tessEvaluationProgram",
189 "tessalation eval program source\n",
190 TessEvaluationProgramFieldId, TessEvaluationProgramFieldMask,
191 false,
192 (Field::SFDefaultFlags | Field::FStdAccess),
193 static_cast<FieldEditMethodSig>(&SimpleSHLChunk::editHandleTessEvaluationProgram),
194 static_cast<FieldGetMethodSig >(&SimpleSHLChunk::getHandleTessEvaluationProgram));
196 oType.addInitialDesc(pDesc);
198 pDesc = new SFString::Description(
199 SFString::getClassType(),
200 "geometryProgram",
201 "geometry program source\n",
202 GeometryProgramFieldId, GeometryProgramFieldMask,
203 false,
204 (Field::SFDefaultFlags | Field::FStdAccess),
205 static_cast<FieldEditMethodSig>(&SimpleSHLChunk::editHandleGeometryProgram),
206 static_cast<FieldGetMethodSig >(&SimpleSHLChunk::getHandleGeometryProgram));
208 oType.addInitialDesc(pDesc);
210 pDesc = new SFString::Description(
211 SFString::getClassType(),
212 "fragmentProgram",
213 "fragment program source\n",
214 FragmentProgramFieldId, FragmentProgramFieldMask,
215 false,
216 (Field::SFDefaultFlags | Field::FStdAccess),
217 static_cast<FieldEditMethodSig>(&SimpleSHLChunk::editHandleFragmentProgram),
218 static_cast<FieldGetMethodSig >(&SimpleSHLChunk::getHandleFragmentProgram));
220 oType.addInitialDesc(pDesc);
222 pDesc = new SFBool::Description(
223 SFBool::getClassType(),
224 "cgFrontEnd",
226 CgFrontEndFieldId, CgFrontEndFieldMask,
227 false,
228 (Field::SFDefaultFlags | Field::FStdAccess),
229 static_cast<FieldEditMethodSig>(&SimpleSHLChunk::editHandleCgFrontEnd),
230 static_cast<FieldGetMethodSig >(&SimpleSHLChunk::getHandleCgFrontEnd));
232 oType.addInitialDesc(pDesc);
234 pDesc = new SFUnrecChildShaderProgramVariablesPtr::Description(
235 SFUnrecChildShaderProgramVariablesPtr::getClassType(),
236 "variables",
237 "fragment program object\n",
238 VariablesFieldId, VariablesFieldMask,
239 false,
240 (Field::SFDefaultFlags | Field::FStdAccess),
241 static_cast<FieldEditMethodSig>(&SimpleSHLChunk::editHandleVariables),
242 static_cast<FieldGetMethodSig >(&SimpleSHLChunk::getHandleVariables));
244 oType.addInitialDesc(pDesc);
246 pDesc = new MFInt32::Description(
247 MFInt32::getClassType(),
248 "variableLocations",
249 "fragment program object\n",
250 VariableLocationsFieldId, VariableLocationsFieldMask,
251 true,
252 (Field::MFDefaultFlags | Field::FStdAccess),
253 static_cast<FieldEditMethodSig>(&SimpleSHLChunk::editHandleVariableLocations),
254 static_cast<FieldGetMethodSig >(&SimpleSHLChunk::getHandleVariableLocations));
256 oType.addInitialDesc(pDesc);
258 pDesc = new MFInt32::Description(
259 MFInt32::getClassType(),
260 "proceduralVariableLocations",
261 "fragment program object\n",
262 ProceduralVariableLocationsFieldId, ProceduralVariableLocationsFieldMask,
263 true,
264 (Field::MFDefaultFlags | Field::FStdAccess),
265 static_cast<FieldEditMethodSig>(&SimpleSHLChunk::editHandleProceduralVariableLocations),
266 static_cast<FieldGetMethodSig >(&SimpleSHLChunk::getHandleProceduralVariableLocations));
268 oType.addInitialDesc(pDesc);
270 pDesc = new SFUInt32::Description(
271 SFUInt32::getClassType(),
272 "GLId",
274 GLIdFieldId, GLIdFieldMask,
275 true,
276 (Field::FClusterLocal),
277 static_cast<FieldEditMethodSig>(&SimpleSHLChunk::editHandleGLId),
278 static_cast<FieldGetMethodSig >(&SimpleSHLChunk::getHandleGLId));
280 oType.addInitialDesc(pDesc);
282 pDesc = new SFBool::Description(
283 SFBool::getClassType(),
284 "pointSize",
285 "Flag to set whether the shader can change the point size.\n",
286 PointSizeFieldId, PointSizeFieldMask,
287 false,
288 (Field::SFDefaultFlags | Field::FStdAccess),
289 static_cast<FieldEditMethodSig>(&SimpleSHLChunk::editHandlePointSize),
290 static_cast<FieldGetMethodSig >(&SimpleSHLChunk::getHandlePointSize));
292 oType.addInitialDesc(pDesc);
296 SimpleSHLChunkBase::TypeObject SimpleSHLChunkBase::_type(
297 SimpleSHLChunkBase::getClassname(),
298 Inherited::getClassname(),
299 "NULL",
300 nsOSG, //Namespace
301 reinterpret_cast<PrototypeCreateF>(&SimpleSHLChunkBase::createEmptyLocal),
302 reinterpret_cast<InitContainerF>(&SimpleSHLChunk::initMethod),
303 reinterpret_cast<ExitContainerF>(&SimpleSHLChunk::exitMethod),
304 reinterpret_cast<InitalInsertDescFunc>(
305 reinterpret_cast<void *>(&SimpleSHLChunk::classDescInserter)),
306 false,
308 "<?xml version=\"1.0\"?>\n"
309 "\n"
310 "<FieldContainer\n"
311 " name=\"SimpleSHLChunk\"\n"
312 " parent=\"ShaderProgramChunk\"\n"
313 " library=\"System\"\n"
314 " pointerfieldtypes=\"both\"\n"
315 " structure=\"concrete\"\n"
316 " systemcomponent=\"true\"\n"
317 " parentsystemcomponent=\"true\"\n"
318 " decoratable=\"false\"\n"
319 " useLocalIncludes=\"false\"\n"
320 " docGroupBase=\"GrpSystemShader\"\n"
321 " >\n"
322 " <Field\n"
323 " name=\"vertexProgram\"\n"
324 " type=\"std::string\"\n"
325 " cardinality=\"single\"\n"
326 " visibility=\"external\"\n"
327 " access=\"public\"\n"
328 " >\n"
329 "\tvertex program source\n"
330 " </Field>\n"
331 " <Field\n"
332 " name=\"tessControlProgram\"\n"
333 " type=\"std::string\"\n"
334 " cardinality=\"single\"\n"
335 " visibility=\"external\"\n"
336 " access=\"public\"\n"
337 " >\n"
338 "\ttessalation control program source\n"
339 " </Field>\n"
340 " <Field\n"
341 " name=\"tessEvaluationProgram\"\n"
342 " type=\"std::string\"\n"
343 " cardinality=\"single\"\n"
344 " visibility=\"external\"\n"
345 " access=\"public\"\n"
346 " >\n"
347 "\ttessalation eval program source\n"
348 " </Field>\n"
349 " <Field\n"
350 " name=\"geometryProgram\"\n"
351 " type=\"std::string\"\n"
352 " cardinality=\"single\"\n"
353 " visibility=\"external\"\n"
354 " access=\"public\"\n"
355 " >\n"
356 "\tgeometry program source\n"
357 " </Field>\n"
358 " <Field\n"
359 " name=\"fragmentProgram\"\n"
360 " type=\"std::string\"\n"
361 " cardinality=\"single\"\n"
362 " visibility=\"external\"\n"
363 " access=\"public\"\n"
364 " >\n"
365 "\tfragment program source\n"
366 " </Field>\n"
367 "\n"
368 " <Field\n"
369 " name=\"cgFrontEnd\"\n"
370 " type=\"bool\"\n"
371 " cardinality=\"single\"\n"
372 " visibility=\"external\"\n"
373 " defaultValue=\"false\"\n"
374 " access=\"public\"\n"
375 " >\n"
376 " </Field>\n"
377 "\n"
378 " <Field\n"
379 " name=\"variables\"\n"
380 " type=\"ShaderProgramVariables\"\n"
381 " cardinality=\"single\"\n"
382 " visibility=\"external\"\n"
383 " access=\"public\"\n"
384 " category=\"childpointer\"\n"
385 " childParentType=\"FieldContainer\"\n"
386 " linkParentField=\"Parents\"\n"
387 " >\n"
388 "\tfragment program object\n"
389 " </Field>\n"
390 " <Field\n"
391 " name=\"variableLocations\"\n"
392 " type=\"Int32\"\n"
393 " cardinality=\"multi\"\n"
394 " visibility=\"internal\"\n"
395 " access=\"protected\"\n"
396 " >\n"
397 "\tfragment program object\n"
398 " </Field>\n"
399 " <Field\n"
400 " name=\"proceduralVariableLocations\"\n"
401 " type=\"Int32\"\n"
402 " cardinality=\"multi\"\n"
403 " visibility=\"internal\"\n"
404 " access=\"protected\"\n"
405 " >\n"
406 "\tfragment program object\n"
407 " </Field>\n"
408 " \n"
409 " <Field\n"
410 " name=\"GLId\"\n"
411 " type=\"UInt32\"\n"
412 " cardinality=\"single\"\n"
413 " visibility=\"internal\"\n"
414 " access=\"public\"\n"
415 " defaultValue=\"0\"\n"
416 " fieldFlags=\"FClusterLocal\"\n"
417 " >\n"
418 " </Field>\n"
419 "\n"
420 " <Field\n"
421 " name=\"pointSize\"\n"
422 " type=\"bool\"\n"
423 " cardinality=\"single\"\n"
424 " visibility=\"external\"\n"
425 " defaultValue=\"false\"\n"
426 " access=\"public\"\n"
427 " >\n"
428 "\tFlag to set whether the shader can change the point size.\n"
429 " </Field>\n"
430 "\n"
431 "</FieldContainer>\n",
435 /*------------------------------ get -----------------------------------*/
437 FieldContainerType &SimpleSHLChunkBase::getType(void)
439 return _type;
442 const FieldContainerType &SimpleSHLChunkBase::getType(void) const
444 return _type;
447 UInt32 SimpleSHLChunkBase::getContainerSize(void) const
449 return sizeof(SimpleSHLChunk);
452 /*------------------------- decorator get ------------------------------*/
455 SFString *SimpleSHLChunkBase::editSFVertexProgram(void)
457 editSField(VertexProgramFieldMask);
459 return &_sfVertexProgram;
462 const SFString *SimpleSHLChunkBase::getSFVertexProgram(void) const
464 return &_sfVertexProgram;
468 SFString *SimpleSHLChunkBase::editSFTessControlProgram(void)
470 editSField(TessControlProgramFieldMask);
472 return &_sfTessControlProgram;
475 const SFString *SimpleSHLChunkBase::getSFTessControlProgram(void) const
477 return &_sfTessControlProgram;
481 SFString *SimpleSHLChunkBase::editSFTessEvaluationProgram(void)
483 editSField(TessEvaluationProgramFieldMask);
485 return &_sfTessEvaluationProgram;
488 const SFString *SimpleSHLChunkBase::getSFTessEvaluationProgram(void) const
490 return &_sfTessEvaluationProgram;
494 SFString *SimpleSHLChunkBase::editSFGeometryProgram(void)
496 editSField(GeometryProgramFieldMask);
498 return &_sfGeometryProgram;
501 const SFString *SimpleSHLChunkBase::getSFGeometryProgram(void) const
503 return &_sfGeometryProgram;
507 SFString *SimpleSHLChunkBase::editSFFragmentProgram(void)
509 editSField(FragmentProgramFieldMask);
511 return &_sfFragmentProgram;
514 const SFString *SimpleSHLChunkBase::getSFFragmentProgram(void) const
516 return &_sfFragmentProgram;
520 SFBool *SimpleSHLChunkBase::editSFCgFrontEnd(void)
522 editSField(CgFrontEndFieldMask);
524 return &_sfCgFrontEnd;
527 const SFBool *SimpleSHLChunkBase::getSFCgFrontEnd(void) const
529 return &_sfCgFrontEnd;
533 //! Get the SimpleSHLChunk::_sfVariables field.
534 const SFUnrecChildShaderProgramVariablesPtr *SimpleSHLChunkBase::getSFVariables(void) const
536 return &_sfVariables;
539 SFUnrecChildShaderProgramVariablesPtr *SimpleSHLChunkBase::editSFVariables (void)
541 editSField(VariablesFieldMask);
543 return &_sfVariables;
546 //! Get the value of the SimpleSHLChunk::_sfVariables field.
547 ShaderProgramVariables * SimpleSHLChunkBase::getVariables(void) const
549 return _sfVariables.getValue();
552 //! Set the value of the SimpleSHLChunk::_sfVariables field.
553 void SimpleSHLChunkBase::setVariables(ShaderProgramVariables * const value)
555 editSField(VariablesFieldMask);
557 _sfVariables.setValue(value);
561 MFInt32 *SimpleSHLChunkBase::editMFVariableLocations(void)
563 editMField(VariableLocationsFieldMask, _mfVariableLocations);
565 return &_mfVariableLocations;
568 const MFInt32 *SimpleSHLChunkBase::getMFVariableLocations(void) const
570 return &_mfVariableLocations;
574 MFInt32 *SimpleSHLChunkBase::editMFProceduralVariableLocations(void)
576 editMField(ProceduralVariableLocationsFieldMask, _mfProceduralVariableLocations);
578 return &_mfProceduralVariableLocations;
581 const MFInt32 *SimpleSHLChunkBase::getMFProceduralVariableLocations(void) const
583 return &_mfProceduralVariableLocations;
587 SFUInt32 *SimpleSHLChunkBase::editSFGLId(void)
589 editSField(GLIdFieldMask);
591 return &_sfGLId;
594 const SFUInt32 *SimpleSHLChunkBase::getSFGLId(void) const
596 return &_sfGLId;
600 SFBool *SimpleSHLChunkBase::editSFPointSize(void)
602 editSField(PointSizeFieldMask);
604 return &_sfPointSize;
607 const SFBool *SimpleSHLChunkBase::getSFPointSize(void) const
609 return &_sfPointSize;
617 /*------------------------------ access -----------------------------------*/
619 SizeT SimpleSHLChunkBase::getBinSize(ConstFieldMaskArg whichField)
621 SizeT returnValue = Inherited::getBinSize(whichField);
623 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
625 returnValue += _sfVertexProgram.getBinSize();
627 if(FieldBits::NoField != (TessControlProgramFieldMask & whichField))
629 returnValue += _sfTessControlProgram.getBinSize();
631 if(FieldBits::NoField != (TessEvaluationProgramFieldMask & whichField))
633 returnValue += _sfTessEvaluationProgram.getBinSize();
635 if(FieldBits::NoField != (GeometryProgramFieldMask & whichField))
637 returnValue += _sfGeometryProgram.getBinSize();
639 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
641 returnValue += _sfFragmentProgram.getBinSize();
643 if(FieldBits::NoField != (CgFrontEndFieldMask & whichField))
645 returnValue += _sfCgFrontEnd.getBinSize();
647 if(FieldBits::NoField != (VariablesFieldMask & whichField))
649 returnValue += _sfVariables.getBinSize();
651 if(FieldBits::NoField != (VariableLocationsFieldMask & whichField))
653 returnValue += _mfVariableLocations.getBinSize();
655 if(FieldBits::NoField != (ProceduralVariableLocationsFieldMask & whichField))
657 returnValue += _mfProceduralVariableLocations.getBinSize();
659 if(FieldBits::NoField != (GLIdFieldMask & whichField))
661 returnValue += _sfGLId.getBinSize();
663 if(FieldBits::NoField != (PointSizeFieldMask & whichField))
665 returnValue += _sfPointSize.getBinSize();
668 return returnValue;
671 void SimpleSHLChunkBase::copyToBin(BinaryDataHandler &pMem,
672 ConstFieldMaskArg whichField)
674 Inherited::copyToBin(pMem, whichField);
676 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
678 _sfVertexProgram.copyToBin(pMem);
680 if(FieldBits::NoField != (TessControlProgramFieldMask & whichField))
682 _sfTessControlProgram.copyToBin(pMem);
684 if(FieldBits::NoField != (TessEvaluationProgramFieldMask & whichField))
686 _sfTessEvaluationProgram.copyToBin(pMem);
688 if(FieldBits::NoField != (GeometryProgramFieldMask & whichField))
690 _sfGeometryProgram.copyToBin(pMem);
692 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
694 _sfFragmentProgram.copyToBin(pMem);
696 if(FieldBits::NoField != (CgFrontEndFieldMask & whichField))
698 _sfCgFrontEnd.copyToBin(pMem);
700 if(FieldBits::NoField != (VariablesFieldMask & whichField))
702 _sfVariables.copyToBin(pMem);
704 if(FieldBits::NoField != (VariableLocationsFieldMask & whichField))
706 _mfVariableLocations.copyToBin(pMem);
708 if(FieldBits::NoField != (ProceduralVariableLocationsFieldMask & whichField))
710 _mfProceduralVariableLocations.copyToBin(pMem);
712 if(FieldBits::NoField != (GLIdFieldMask & whichField))
714 _sfGLId.copyToBin(pMem);
716 if(FieldBits::NoField != (PointSizeFieldMask & whichField))
718 _sfPointSize.copyToBin(pMem);
722 void SimpleSHLChunkBase::copyFromBin(BinaryDataHandler &pMem,
723 ConstFieldMaskArg whichField)
725 Inherited::copyFromBin(pMem, whichField);
727 if(FieldBits::NoField != (VertexProgramFieldMask & whichField))
729 editSField(VertexProgramFieldMask);
730 _sfVertexProgram.copyFromBin(pMem);
732 if(FieldBits::NoField != (TessControlProgramFieldMask & whichField))
734 editSField(TessControlProgramFieldMask);
735 _sfTessControlProgram.copyFromBin(pMem);
737 if(FieldBits::NoField != (TessEvaluationProgramFieldMask & whichField))
739 editSField(TessEvaluationProgramFieldMask);
740 _sfTessEvaluationProgram.copyFromBin(pMem);
742 if(FieldBits::NoField != (GeometryProgramFieldMask & whichField))
744 editSField(GeometryProgramFieldMask);
745 _sfGeometryProgram.copyFromBin(pMem);
747 if(FieldBits::NoField != (FragmentProgramFieldMask & whichField))
749 editSField(FragmentProgramFieldMask);
750 _sfFragmentProgram.copyFromBin(pMem);
752 if(FieldBits::NoField != (CgFrontEndFieldMask & whichField))
754 editSField(CgFrontEndFieldMask);
755 _sfCgFrontEnd.copyFromBin(pMem);
757 if(FieldBits::NoField != (VariablesFieldMask & whichField))
759 editSField(VariablesFieldMask);
760 _sfVariables.copyFromBin(pMem);
762 if(FieldBits::NoField != (VariableLocationsFieldMask & whichField))
764 editMField(VariableLocationsFieldMask, _mfVariableLocations);
765 _mfVariableLocations.copyFromBin(pMem);
767 if(FieldBits::NoField != (ProceduralVariableLocationsFieldMask & whichField))
769 editMField(ProceduralVariableLocationsFieldMask, _mfProceduralVariableLocations);
770 _mfProceduralVariableLocations.copyFromBin(pMem);
772 if(FieldBits::NoField != (GLIdFieldMask & whichField))
774 editSField(GLIdFieldMask);
775 _sfGLId.copyFromBin(pMem);
777 if(FieldBits::NoField != (PointSizeFieldMask & whichField))
779 editSField(PointSizeFieldMask);
780 _sfPointSize.copyFromBin(pMem);
784 //! create a new instance of the class
785 SimpleSHLChunkTransitPtr SimpleSHLChunkBase::createLocal(BitVector bFlags)
787 SimpleSHLChunkTransitPtr fc;
789 if(getClassType().getPrototype() != NULL)
791 FieldContainerTransitPtr tmpPtr =
792 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
794 fc = dynamic_pointer_cast<SimpleSHLChunk>(tmpPtr);
797 return fc;
800 //! create a new instance of the class, copy the container flags
801 SimpleSHLChunkTransitPtr SimpleSHLChunkBase::createDependent(BitVector bFlags)
803 SimpleSHLChunkTransitPtr fc;
805 if(getClassType().getPrototype() != NULL)
807 FieldContainerTransitPtr tmpPtr =
808 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
810 fc = dynamic_pointer_cast<SimpleSHLChunk>(tmpPtr);
813 return fc;
816 //! create a new instance of the class
817 SimpleSHLChunkTransitPtr SimpleSHLChunkBase::create(void)
819 SimpleSHLChunkTransitPtr fc;
821 if(getClassType().getPrototype() != NULL)
823 FieldContainerTransitPtr tmpPtr =
824 getClassType().getPrototype()-> shallowCopy();
826 fc = dynamic_pointer_cast<SimpleSHLChunk>(tmpPtr);
829 return fc;
832 SimpleSHLChunk *SimpleSHLChunkBase::createEmptyLocal(BitVector bFlags)
834 SimpleSHLChunk *returnValue;
836 newPtr<SimpleSHLChunk>(returnValue, bFlags);
838 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
840 return returnValue;
843 //! create an empty new instance of the class, do not copy the prototype
844 SimpleSHLChunk *SimpleSHLChunkBase::createEmpty(void)
846 SimpleSHLChunk *returnValue;
848 newPtr<SimpleSHLChunk>(returnValue, Thread::getCurrentLocalFlags());
850 returnValue->_pFieldFlags->_bNamespaceMask &=
851 ~Thread::getCurrentLocalFlags();
853 return returnValue;
857 FieldContainerTransitPtr SimpleSHLChunkBase::shallowCopyLocal(
858 BitVector bFlags) const
860 SimpleSHLChunk *tmpPtr;
862 newPtr(tmpPtr, dynamic_cast<const SimpleSHLChunk *>(this), bFlags);
864 FieldContainerTransitPtr returnValue(tmpPtr);
866 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
868 return returnValue;
871 FieldContainerTransitPtr SimpleSHLChunkBase::shallowCopyDependent(
872 BitVector bFlags) const
874 SimpleSHLChunk *tmpPtr;
876 newPtr(tmpPtr, dynamic_cast<const SimpleSHLChunk *>(this), ~bFlags);
878 FieldContainerTransitPtr returnValue(tmpPtr);
880 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
882 return returnValue;
885 FieldContainerTransitPtr SimpleSHLChunkBase::shallowCopy(void) const
887 SimpleSHLChunk *tmpPtr;
889 newPtr(tmpPtr,
890 dynamic_cast<const SimpleSHLChunk *>(this),
891 Thread::getCurrentLocalFlags());
893 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
895 FieldContainerTransitPtr returnValue(tmpPtr);
897 return returnValue;
903 /*------------------------- constructors ----------------------------------*/
905 SimpleSHLChunkBase::SimpleSHLChunkBase(void) :
906 Inherited(),
907 _sfVertexProgram (),
908 _sfTessControlProgram (),
909 _sfTessEvaluationProgram (),
910 _sfGeometryProgram (),
911 _sfFragmentProgram (),
912 _sfCgFrontEnd (bool(false)),
913 _sfVariables (this,
914 VariablesFieldId,
915 ShaderProgramVariables::ParentsFieldId),
916 _mfVariableLocations (),
917 _mfProceduralVariableLocations(),
918 _sfGLId (UInt32(0)),
919 _sfPointSize (bool(false))
923 SimpleSHLChunkBase::SimpleSHLChunkBase(const SimpleSHLChunkBase &source) :
924 Inherited(source),
925 _sfVertexProgram (source._sfVertexProgram ),
926 _sfTessControlProgram (source._sfTessControlProgram ),
927 _sfTessEvaluationProgram (source._sfTessEvaluationProgram ),
928 _sfGeometryProgram (source._sfGeometryProgram ),
929 _sfFragmentProgram (source._sfFragmentProgram ),
930 _sfCgFrontEnd (source._sfCgFrontEnd ),
931 _sfVariables (this,
932 VariablesFieldId,
933 ShaderProgramVariables::ParentsFieldId),
934 _mfVariableLocations (source._mfVariableLocations ),
935 _mfProceduralVariableLocations(source._mfProceduralVariableLocations),
936 _sfGLId (source._sfGLId ),
937 _sfPointSize (source._sfPointSize )
942 /*-------------------------- destructors ----------------------------------*/
944 SimpleSHLChunkBase::~SimpleSHLChunkBase(void)
948 /*-------------------------------------------------------------------------*/
949 /* Child linking */
951 bool SimpleSHLChunkBase::unlinkChild(
952 FieldContainer * const pChild,
953 UInt16 const childFieldId)
955 if(childFieldId == VariablesFieldId)
957 ShaderProgramVariables * pTypedChild =
958 dynamic_cast<ShaderProgramVariables *>(pChild);
960 if(pTypedChild != NULL)
962 if(_sfVariables.getValue() == pTypedChild)
964 editSField(VariablesFieldMask);
966 _sfVariables.setValue(NULL);
968 return true;
971 SWARNING << "Parent ([" << this
972 << "] id [" << this->getId()
973 << "] type [" << this->getType().getCName()
974 << "] childFieldId [" << childFieldId
975 << "]) - Child ([" << pChild
976 << "] id [" << pChild->getId()
977 << "] type [" << pChild->getType().getCName()
978 << "]): link inconsistent!"
979 << std::endl;
981 return false;
984 return false;
988 return Inherited::unlinkChild(pChild, childFieldId);
991 void SimpleSHLChunkBase::onCreate(const SimpleSHLChunk *source)
993 Inherited::onCreate(source);
995 if(source != NULL)
997 SimpleSHLChunk *pThis = static_cast<SimpleSHLChunk *>(this);
999 pThis->setVariables(source->getVariables());
1003 GetFieldHandlePtr SimpleSHLChunkBase::getHandleVertexProgram (void) const
1005 SFString::GetHandlePtr returnValue(
1006 new SFString::GetHandle(
1007 &_sfVertexProgram,
1008 this->getType().getFieldDesc(VertexProgramFieldId),
1009 const_cast<SimpleSHLChunkBase *>(this)));
1011 return returnValue;
1014 EditFieldHandlePtr SimpleSHLChunkBase::editHandleVertexProgram (void)
1016 SFString::EditHandlePtr returnValue(
1017 new SFString::EditHandle(
1018 &_sfVertexProgram,
1019 this->getType().getFieldDesc(VertexProgramFieldId),
1020 this));
1023 editSField(VertexProgramFieldMask);
1025 return returnValue;
1028 GetFieldHandlePtr SimpleSHLChunkBase::getHandleTessControlProgram (void) const
1030 SFString::GetHandlePtr returnValue(
1031 new SFString::GetHandle(
1032 &_sfTessControlProgram,
1033 this->getType().getFieldDesc(TessControlProgramFieldId),
1034 const_cast<SimpleSHLChunkBase *>(this)));
1036 return returnValue;
1039 EditFieldHandlePtr SimpleSHLChunkBase::editHandleTessControlProgram(void)
1041 SFString::EditHandlePtr returnValue(
1042 new SFString::EditHandle(
1043 &_sfTessControlProgram,
1044 this->getType().getFieldDesc(TessControlProgramFieldId),
1045 this));
1048 editSField(TessControlProgramFieldMask);
1050 return returnValue;
1053 GetFieldHandlePtr SimpleSHLChunkBase::getHandleTessEvaluationProgram (void) const
1055 SFString::GetHandlePtr returnValue(
1056 new SFString::GetHandle(
1057 &_sfTessEvaluationProgram,
1058 this->getType().getFieldDesc(TessEvaluationProgramFieldId),
1059 const_cast<SimpleSHLChunkBase *>(this)));
1061 return returnValue;
1064 EditFieldHandlePtr SimpleSHLChunkBase::editHandleTessEvaluationProgram(void)
1066 SFString::EditHandlePtr returnValue(
1067 new SFString::EditHandle(
1068 &_sfTessEvaluationProgram,
1069 this->getType().getFieldDesc(TessEvaluationProgramFieldId),
1070 this));
1073 editSField(TessEvaluationProgramFieldMask);
1075 return returnValue;
1078 GetFieldHandlePtr SimpleSHLChunkBase::getHandleGeometryProgram (void) const
1080 SFString::GetHandlePtr returnValue(
1081 new SFString::GetHandle(
1082 &_sfGeometryProgram,
1083 this->getType().getFieldDesc(GeometryProgramFieldId),
1084 const_cast<SimpleSHLChunkBase *>(this)));
1086 return returnValue;
1089 EditFieldHandlePtr SimpleSHLChunkBase::editHandleGeometryProgram(void)
1091 SFString::EditHandlePtr returnValue(
1092 new SFString::EditHandle(
1093 &_sfGeometryProgram,
1094 this->getType().getFieldDesc(GeometryProgramFieldId),
1095 this));
1098 editSField(GeometryProgramFieldMask);
1100 return returnValue;
1103 GetFieldHandlePtr SimpleSHLChunkBase::getHandleFragmentProgram (void) const
1105 SFString::GetHandlePtr returnValue(
1106 new SFString::GetHandle(
1107 &_sfFragmentProgram,
1108 this->getType().getFieldDesc(FragmentProgramFieldId),
1109 const_cast<SimpleSHLChunkBase *>(this)));
1111 return returnValue;
1114 EditFieldHandlePtr SimpleSHLChunkBase::editHandleFragmentProgram(void)
1116 SFString::EditHandlePtr returnValue(
1117 new SFString::EditHandle(
1118 &_sfFragmentProgram,
1119 this->getType().getFieldDesc(FragmentProgramFieldId),
1120 this));
1123 editSField(FragmentProgramFieldMask);
1125 return returnValue;
1128 GetFieldHandlePtr SimpleSHLChunkBase::getHandleCgFrontEnd (void) const
1130 SFBool::GetHandlePtr returnValue(
1131 new SFBool::GetHandle(
1132 &_sfCgFrontEnd,
1133 this->getType().getFieldDesc(CgFrontEndFieldId),
1134 const_cast<SimpleSHLChunkBase *>(this)));
1136 return returnValue;
1139 EditFieldHandlePtr SimpleSHLChunkBase::editHandleCgFrontEnd (void)
1141 SFBool::EditHandlePtr returnValue(
1142 new SFBool::EditHandle(
1143 &_sfCgFrontEnd,
1144 this->getType().getFieldDesc(CgFrontEndFieldId),
1145 this));
1148 editSField(CgFrontEndFieldMask);
1150 return returnValue;
1153 GetFieldHandlePtr SimpleSHLChunkBase::getHandleVariables (void) const
1155 SFUnrecChildShaderProgramVariablesPtr::GetHandlePtr returnValue(
1156 new SFUnrecChildShaderProgramVariablesPtr::GetHandle(
1157 &_sfVariables,
1158 this->getType().getFieldDesc(VariablesFieldId),
1159 const_cast<SimpleSHLChunkBase *>(this)));
1161 return returnValue;
1164 EditFieldHandlePtr SimpleSHLChunkBase::editHandleVariables (void)
1166 SFUnrecChildShaderProgramVariablesPtr::EditHandlePtr returnValue(
1167 new SFUnrecChildShaderProgramVariablesPtr::EditHandle(
1168 &_sfVariables,
1169 this->getType().getFieldDesc(VariablesFieldId),
1170 this));
1172 returnValue->setSetMethod(
1173 boost::bind(&SimpleSHLChunk::setVariables,
1174 static_cast<SimpleSHLChunk *>(this), _1));
1176 editSField(VariablesFieldMask);
1178 return returnValue;
1181 GetFieldHandlePtr SimpleSHLChunkBase::getHandleVariableLocations (void) const
1183 MFInt32::GetHandlePtr returnValue(
1184 new MFInt32::GetHandle(
1185 &_mfVariableLocations,
1186 this->getType().getFieldDesc(VariableLocationsFieldId),
1187 const_cast<SimpleSHLChunkBase *>(this)));
1189 return returnValue;
1192 EditFieldHandlePtr SimpleSHLChunkBase::editHandleVariableLocations(void)
1194 MFInt32::EditHandlePtr returnValue(
1195 new MFInt32::EditHandle(
1196 &_mfVariableLocations,
1197 this->getType().getFieldDesc(VariableLocationsFieldId),
1198 this));
1201 editMField(VariableLocationsFieldMask, _mfVariableLocations);
1203 return returnValue;
1206 GetFieldHandlePtr SimpleSHLChunkBase::getHandleProceduralVariableLocations (void) const
1208 MFInt32::GetHandlePtr returnValue(
1209 new MFInt32::GetHandle(
1210 &_mfProceduralVariableLocations,
1211 this->getType().getFieldDesc(ProceduralVariableLocationsFieldId),
1212 const_cast<SimpleSHLChunkBase *>(this)));
1214 return returnValue;
1217 EditFieldHandlePtr SimpleSHLChunkBase::editHandleProceduralVariableLocations(void)
1219 MFInt32::EditHandlePtr returnValue(
1220 new MFInt32::EditHandle(
1221 &_mfProceduralVariableLocations,
1222 this->getType().getFieldDesc(ProceduralVariableLocationsFieldId),
1223 this));
1226 editMField(ProceduralVariableLocationsFieldMask, _mfProceduralVariableLocations);
1228 return returnValue;
1231 GetFieldHandlePtr SimpleSHLChunkBase::getHandleGLId (void) const
1233 SFUInt32::GetHandlePtr returnValue(
1234 new SFUInt32::GetHandle(
1235 &_sfGLId,
1236 this->getType().getFieldDesc(GLIdFieldId),
1237 const_cast<SimpleSHLChunkBase *>(this)));
1239 return returnValue;
1242 EditFieldHandlePtr SimpleSHLChunkBase::editHandleGLId (void)
1244 SFUInt32::EditHandlePtr returnValue(
1245 new SFUInt32::EditHandle(
1246 &_sfGLId,
1247 this->getType().getFieldDesc(GLIdFieldId),
1248 this));
1251 editSField(GLIdFieldMask);
1253 return returnValue;
1256 GetFieldHandlePtr SimpleSHLChunkBase::getHandlePointSize (void) const
1258 SFBool::GetHandlePtr returnValue(
1259 new SFBool::GetHandle(
1260 &_sfPointSize,
1261 this->getType().getFieldDesc(PointSizeFieldId),
1262 const_cast<SimpleSHLChunkBase *>(this)));
1264 return returnValue;
1267 EditFieldHandlePtr SimpleSHLChunkBase::editHandlePointSize (void)
1269 SFBool::EditHandlePtr returnValue(
1270 new SFBool::EditHandle(
1271 &_sfPointSize,
1272 this->getType().getFieldDesc(PointSizeFieldId),
1273 this));
1276 editSField(PointSizeFieldMask);
1278 return returnValue;
1282 #ifdef OSG_MT_CPTR_ASPECT
1283 void SimpleSHLChunkBase::execSyncV( FieldContainer &oFrom,
1284 ConstFieldMaskArg whichField,
1285 AspectOffsetStore &oOffsets,
1286 ConstFieldMaskArg syncMode,
1287 const UInt32 uiSyncInfo)
1289 SimpleSHLChunk *pThis = static_cast<SimpleSHLChunk *>(this);
1291 pThis->execSync(static_cast<SimpleSHLChunk *>(&oFrom),
1292 whichField,
1293 oOffsets,
1294 syncMode,
1295 uiSyncInfo);
1297 #endif
1300 #ifdef OSG_MT_CPTR_ASPECT
1301 FieldContainer *SimpleSHLChunkBase::createAspectCopy(
1302 const FieldContainer *pRefAspect) const
1304 SimpleSHLChunk *returnValue;
1306 newAspectCopy(returnValue,
1307 dynamic_cast<const SimpleSHLChunk *>(pRefAspect),
1308 dynamic_cast<const SimpleSHLChunk *>(this));
1310 return returnValue;
1312 #endif
1314 void SimpleSHLChunkBase::resolveLinks(void)
1316 Inherited::resolveLinks();
1318 static_cast<SimpleSHLChunk *>(this)->setVariables(NULL);
1320 #ifdef OSG_MT_CPTR_ASPECT
1321 AspectOffsetStore oOffsets;
1323 _pAspectStore->fillOffsetArray(oOffsets, this);
1324 #endif
1326 #ifdef OSG_MT_CPTR_ASPECT
1327 _mfVariableLocations.terminateShare(Thread::getCurrentAspect(),
1328 oOffsets);
1329 #endif
1330 #ifdef OSG_MT_CPTR_ASPECT
1331 _mfProceduralVariableLocations.terminateShare(Thread::getCurrentAspect(),
1332 oOffsets);
1333 #endif
1337 OSG_END_NAMESPACE