1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
42 ** This file is automatically generated. **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
47 ** Do not change this file, changes should be done in the derived **
48 ** class ShaderProgram!
50 *****************************************************************************
51 \*****************************************************************************/
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
61 #include "OSGConfig.h"
64 #include "OSGGL.h" // ShaderType default header
65 #include "OSGChangedFunctorMFields.h" // DestroyedFunctors default header
67 #include "OSGShaderProgramVariables.h" // Variables Class
68 #include "OSGFieldContainer.h" // Parents Class
70 #include "OSGShaderProgramBase.h"
71 #include "OSGShaderProgram.h"
73 #include <boost/bind.hpp>
77 /***************************************************************************\
79 \***************************************************************************/
81 /*! \class OSG::ShaderProgram
85 /***************************************************************************\
86 * Field Documentation *
87 \***************************************************************************/
89 /*! \var GLenum ShaderProgramBase::_sfShaderType
93 /*! \var std::string ShaderProgramBase::_sfProgram
97 /*! \var std::string ShaderProgramBase::_sfDefines
101 /*! \var UInt32 ShaderProgramBase::_sfGLId
105 /*! \var ShaderProgramVariables * ShaderProgramBase::_sfVariables
106 fragment program object
109 /*! \var std::string ShaderProgramBase::_mfFeedbackVaryings
113 /*! \var ShaderParameter ShaderProgramBase::_mfParameter
117 /*! \var ShaderAttribute ShaderProgramBase::_mfAttributes
121 /*! \var bool ShaderProgramBase::_sfCgFrontEnd
125 /*! \var bool ShaderProgramBase::_sfPointSize
126 Flag to set whether the shader can change the point size.
129 /*! \var FieldContainer * ShaderProgramBase::_mfParents
133 /*! \var ChangedFunctorCallback ShaderProgramBase::_mfDestroyedFunctors
138 /***************************************************************************\
139 * FieldType/FieldTrait Instantiation *
140 \***************************************************************************/
142 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
143 PointerType FieldTraits
<ShaderProgram
*, nsOSG
>::_type(
146 ShaderProgram::getClassType(),
150 OSG_FIELDTRAITS_GETTYPE_NS(ShaderProgram
*, nsOSG
)
152 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
156 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
160 /***************************************************************************\
161 * Field Description *
162 \***************************************************************************/
164 void ShaderProgramBase::classDescInserter(TypeObject
&oType
)
166 FieldDescriptionBase
*pDesc
= NULL
;
169 pDesc
= new SFGLenum::Description(
170 SFGLenum::getClassType(),
173 ShaderTypeFieldId
, ShaderTypeFieldMask
,
175 (Field::SFDefaultFlags
| Field::FStdAccess
),
176 static_cast<FieldEditMethodSig
>(&ShaderProgram::editHandleShaderType
),
177 static_cast<FieldGetMethodSig
>(&ShaderProgram::getHandleShaderType
));
179 oType
.addInitialDesc(pDesc
);
181 pDesc
= new SFString::Description(
182 SFString::getClassType(),
185 ProgramFieldId
, ProgramFieldMask
,
187 (Field::SFDefaultFlags
| Field::FStdAccess
),
188 static_cast<FieldEditMethodSig
>(&ShaderProgram::editHandleProgram
),
189 static_cast<FieldGetMethodSig
>(&ShaderProgram::getHandleProgram
));
191 oType
.addInitialDesc(pDesc
);
193 pDesc
= new SFString::Description(
194 SFString::getClassType(),
197 DefinesFieldId
, DefinesFieldMask
,
199 (Field::SFDefaultFlags
| Field::FStdAccess
),
200 static_cast<FieldEditMethodSig
>(&ShaderProgram::editHandleDefines
),
201 static_cast<FieldGetMethodSig
>(&ShaderProgram::getHandleDefines
));
203 oType
.addInitialDesc(pDesc
);
205 pDesc
= new SFUInt32::Description(
206 SFUInt32::getClassType(),
209 GLIdFieldId
, GLIdFieldMask
,
211 (Field::FClusterLocal
),
212 static_cast<FieldEditMethodSig
>(&ShaderProgram::editHandleGLId
),
213 static_cast<FieldGetMethodSig
>(&ShaderProgram::getHandleGLId
));
215 oType
.addInitialDesc(pDesc
);
217 pDesc
= new SFUnrecChildShaderProgramVariablesPtr::Description(
218 SFUnrecChildShaderProgramVariablesPtr::getClassType(),
220 "fragment program object\n",
221 VariablesFieldId
, VariablesFieldMask
,
223 (Field::SFDefaultFlags
| Field::FStdAccess
),
224 static_cast<FieldEditMethodSig
>(&ShaderProgram::editHandleVariables
),
225 static_cast<FieldGetMethodSig
>(&ShaderProgram::getHandleVariables
));
227 oType
.addInitialDesc(pDesc
);
229 pDesc
= new MFString::Description(
230 MFString::getClassType(),
233 FeedbackVaryingsFieldId
, FeedbackVaryingsFieldMask
,
235 (Field::MFDefaultFlags
| Field::FStdAccess
),
236 static_cast<FieldEditMethodSig
>(&ShaderProgram::editHandleFeedbackVaryings
),
237 static_cast<FieldGetMethodSig
>(&ShaderProgram::getHandleFeedbackVaryings
));
239 oType
.addInitialDesc(pDesc
);
241 pDesc
= new MFShaderParameter::Description(
242 MFShaderParameter::getClassType(),
245 ParameterFieldId
, ParameterFieldMask
,
247 (Field::MFDefaultFlags
| Field::FStdAccess
),
248 static_cast<FieldEditMethodSig
>(&ShaderProgram::editHandleParameter
),
249 static_cast<FieldGetMethodSig
>(&ShaderProgram::getHandleParameter
));
251 oType
.addInitialDesc(pDesc
);
253 pDesc
= new MFShaderAttribute::Description(
254 MFShaderAttribute::getClassType(),
257 AttributesFieldId
, AttributesFieldMask
,
259 (Field::MFDefaultFlags
| Field::FStdAccess
),
260 static_cast<FieldEditMethodSig
>(&ShaderProgram::editHandleAttributes
),
261 static_cast<FieldGetMethodSig
>(&ShaderProgram::getHandleAttributes
));
263 oType
.addInitialDesc(pDesc
);
265 pDesc
= new SFBool::Description(
266 SFBool::getClassType(),
269 CgFrontEndFieldId
, CgFrontEndFieldMask
,
271 (Field::SFDefaultFlags
| Field::FStdAccess
),
272 static_cast<FieldEditMethodSig
>(&ShaderProgram::editHandleCgFrontEnd
),
273 static_cast<FieldGetMethodSig
>(&ShaderProgram::getHandleCgFrontEnd
));
275 oType
.addInitialDesc(pDesc
);
277 pDesc
= new SFBool::Description(
278 SFBool::getClassType(),
280 "Flag to set whether the shader can change the point size.\n",
281 PointSizeFieldId
, PointSizeFieldMask
,
283 (Field::SFDefaultFlags
| Field::FStdAccess
),
284 static_cast<FieldEditMethodSig
>(&ShaderProgram::editHandlePointSize
),
285 static_cast<FieldGetMethodSig
>(&ShaderProgram::getHandlePointSize
));
287 oType
.addInitialDesc(pDesc
);
289 pDesc
= new MFParentFieldContainerPtr::Description(
290 MFParentFieldContainerPtr::getClassType(),
293 ParentsFieldId
, ParentsFieldMask
,
295 (Field::FClusterLocal
),
296 static_cast <FieldEditMethodSig
>(&ShaderProgram::invalidEditField
),
297 static_cast <FieldGetMethodSig
>(&ShaderProgram::invalidGetField
));
299 oType
.addInitialDesc(pDesc
);
301 pDesc
= new MFChangedFunctorCallback::Description(
302 MFChangedFunctorCallback::getClassType(),
305 DestroyedFunctorsFieldId
, DestroyedFunctorsFieldMask
,
307 (Field::FClusterLocal
),
308 static_cast <FieldEditMethodSig
>(&ShaderProgram::invalidEditField
),
309 static_cast <FieldGetMethodSig
>(&ShaderProgram::invalidGetField
));
311 oType
.addInitialDesc(pDesc
);
315 ShaderProgramBase::TypeObject
ShaderProgramBase::_type(
316 ShaderProgramBase::getClassname(),
317 Inherited::getClassname(),
320 reinterpret_cast<PrototypeCreateF
>(&ShaderProgramBase::createEmptyLocal
),
321 reinterpret_cast<InitContainerF
>(&ShaderProgram::initMethod
),
322 reinterpret_cast<ExitContainerF
>(&ShaderProgram::exitMethod
),
323 reinterpret_cast<InitalInsertDescFunc
>(
324 reinterpret_cast<void *>(&ShaderProgram::classDescInserter
)),
327 "<?xml version=\"1.0\"?>\n"
330 " name=\"ShaderProgram\"\n"
331 " parent=\"FieldContainer\"\n"
332 " library=\"System\"\n"
333 " structure=\"concrete\"\n"
334 " pointerfieldtypes=\"both\"\n"
335 " systemcomponent=\"true\"\n"
336 " parentsystemcomponent=\"true\"\n"
337 " decoratable=\"false\"\n"
338 " useLocalIncludes=\"false\"\n"
339 " docGroupBase=\"GrpSystemShader\"\n"
343 " name=\"shaderType\"\n"
345 " cardinality=\"single\"\n"
346 " visibility=\"external\"\n"
347 " defaultValue=\"GL_NONE\"\n"
348 " defaultHeader=\""OSGGL.h"\"\n"
349 " access=\"public\"\n"
354 " name=\"program\"\n"
355 " type=\"std::string\"\n"
356 " cardinality=\"single\"\n"
357 " visibility=\"external\"\n"
358 " access=\"public\"\n"
363 " name=\"defines\"\n"
364 " type=\"std::string\"\n"
365 " cardinality=\"single\"\n"
366 " visibility=\"external\"\n"
367 " access=\"public\"\n"
374 " cardinality=\"single\"\n"
375 " visibility=\"internal\"\n"
376 " access=\"public\"\n"
377 " defaultValue=\"0\"\n"
378 " fieldFlags=\"FClusterLocal\"\n"
383 " name=\"variables\"\n"
384 " type=\"ShaderProgramVariables\"\n"
385 " cardinality=\"single\"\n"
386 " visibility=\"external\"\n"
387 " access=\"public\"\n"
388 " category=\"childpointer\"\n"
389 " childParentType=\"FieldContainer\"\n"
390 " linkParentField=\"Parents\"\n"
392 " fragment program object\n"
396 " name=\"feedbackVaryings\"\n"
397 " type=\"std::string\"\n"
398 " cardinality=\"multi\"\n"
399 " visibility=\"external\"\n"
400 " access=\"public\"\n"
405 " name=\"parameter\"\n"
406 " type=\"ShaderParameter\"\n"
407 " cardinality=\"multi\"\n"
408 " visibility=\"external\"\n"
409 " access=\"public\"\n"
414 " name=\"attributes\"\n"
415 " type=\"ShaderAttribute\"\n"
416 " cardinality=\"multi\"\n"
417 " visibility=\"external\"\n"
418 " access=\"public\"\n"
423 " name=\"cgFrontEnd\"\n"
425 " cardinality=\"single\"\n"
426 " visibility=\"external\"\n"
427 " defaultValue=\"false\"\n"
428 " access=\"public\"\n"
433 " name=\"pointSize\"\n"
435 " cardinality=\"single\"\n"
436 " visibility=\"external\"\n"
437 " defaultValue=\"false\"\n"
438 " access=\"public\"\n"
440 " Flag to set whether the shader can change the point size.\n"
444 " name=\"parents\"\n"
445 " type=\"FieldContainer\"\n"
446 " cardinality=\"multi\"\n"
447 " visibility=\"internal\"\n"
449 " category=\"parentpointer\"\n"
450 " fieldFlags=\"FClusterLocal\"\n"
455 " name=\"destroyedFunctors\"\n"
456 " type=\"ChangedFunctorCallback\"\n"
457 " cardinality=\"multi\"\n"
458 " visibility=\"internal\"\n"
460 " defaultHeader=\"OSGChangedFunctorMFields.h\"\n"
461 " fieldFlags=\"FClusterLocal\"\n"
465 "</FieldContainer>\n",
469 /*------------------------------ get -----------------------------------*/
471 FieldContainerType
&ShaderProgramBase::getType(void)
476 const FieldContainerType
&ShaderProgramBase::getType(void) const
481 UInt32
ShaderProgramBase::getContainerSize(void) const
483 return sizeof(ShaderProgram
);
486 /*------------------------- decorator get ------------------------------*/
489 SFGLenum
*ShaderProgramBase::editSFShaderType(void)
491 editSField(ShaderTypeFieldMask
);
493 return &_sfShaderType
;
496 const SFGLenum
*ShaderProgramBase::getSFShaderType(void) const
498 return &_sfShaderType
;
502 SFString
*ShaderProgramBase::editSFProgram(void)
504 editSField(ProgramFieldMask
);
509 const SFString
*ShaderProgramBase::getSFProgram(void) const
515 SFString
*ShaderProgramBase::editSFDefines(void)
517 editSField(DefinesFieldMask
);
522 const SFString
*ShaderProgramBase::getSFDefines(void) const
528 SFUInt32
*ShaderProgramBase::editSFGLId(void)
530 editSField(GLIdFieldMask
);
535 const SFUInt32
*ShaderProgramBase::getSFGLId(void) const
541 //! Get the ShaderProgram::_sfVariables field.
542 const SFUnrecChildShaderProgramVariablesPtr
*ShaderProgramBase::getSFVariables(void) const
544 return &_sfVariables
;
547 SFUnrecChildShaderProgramVariablesPtr
*ShaderProgramBase::editSFVariables (void)
549 editSField(VariablesFieldMask
);
551 return &_sfVariables
;
554 //! Get the value of the ShaderProgram::_sfVariables field.
555 ShaderProgramVariables
* ShaderProgramBase::getVariables(void) const
557 return _sfVariables
.getValue();
560 //! Set the value of the ShaderProgram::_sfVariables field.
561 void ShaderProgramBase::setVariables(ShaderProgramVariables
* const value
)
563 editSField(VariablesFieldMask
);
565 _sfVariables
.setValue(value
);
569 MFString
*ShaderProgramBase::editMFFeedbackVaryings(void)
571 editMField(FeedbackVaryingsFieldMask
, _mfFeedbackVaryings
);
573 return &_mfFeedbackVaryings
;
576 const MFString
*ShaderProgramBase::getMFFeedbackVaryings(void) const
578 return &_mfFeedbackVaryings
;
582 MFShaderParameter
*ShaderProgramBase::editMFParameter(void)
584 editMField(ParameterFieldMask
, _mfParameter
);
586 return &_mfParameter
;
589 const MFShaderParameter
*ShaderProgramBase::getMFParameter(void) const
591 return &_mfParameter
;
595 MFShaderAttribute
*ShaderProgramBase::editMFAttributes(void)
597 editMField(AttributesFieldMask
, _mfAttributes
);
599 return &_mfAttributes
;
602 const MFShaderAttribute
*ShaderProgramBase::getMFAttributes(void) const
604 return &_mfAttributes
;
608 SFBool
*ShaderProgramBase::editSFCgFrontEnd(void)
610 editSField(CgFrontEndFieldMask
);
612 return &_sfCgFrontEnd
;
615 const SFBool
*ShaderProgramBase::getSFCgFrontEnd(void) const
617 return &_sfCgFrontEnd
;
621 SFBool
*ShaderProgramBase::editSFPointSize(void)
623 editSField(PointSizeFieldMask
);
625 return &_sfPointSize
;
628 const SFBool
*ShaderProgramBase::getSFPointSize(void) const
630 return &_sfPointSize
;
640 /*------------------------------ access -----------------------------------*/
642 SizeT
ShaderProgramBase::getBinSize(ConstFieldMaskArg whichField
)
644 SizeT returnValue
= Inherited::getBinSize(whichField
);
646 if(FieldBits::NoField
!= (ShaderTypeFieldMask
& whichField
))
648 returnValue
+= _sfShaderType
.getBinSize();
650 if(FieldBits::NoField
!= (ProgramFieldMask
& whichField
))
652 returnValue
+= _sfProgram
.getBinSize();
654 if(FieldBits::NoField
!= (DefinesFieldMask
& whichField
))
656 returnValue
+= _sfDefines
.getBinSize();
658 if(FieldBits::NoField
!= (GLIdFieldMask
& whichField
))
660 returnValue
+= _sfGLId
.getBinSize();
662 if(FieldBits::NoField
!= (VariablesFieldMask
& whichField
))
664 returnValue
+= _sfVariables
.getBinSize();
666 if(FieldBits::NoField
!= (FeedbackVaryingsFieldMask
& whichField
))
668 returnValue
+= _mfFeedbackVaryings
.getBinSize();
670 if(FieldBits::NoField
!= (ParameterFieldMask
& whichField
))
672 returnValue
+= _mfParameter
.getBinSize();
674 if(FieldBits::NoField
!= (AttributesFieldMask
& whichField
))
676 returnValue
+= _mfAttributes
.getBinSize();
678 if(FieldBits::NoField
!= (CgFrontEndFieldMask
& whichField
))
680 returnValue
+= _sfCgFrontEnd
.getBinSize();
682 if(FieldBits::NoField
!= (PointSizeFieldMask
& whichField
))
684 returnValue
+= _sfPointSize
.getBinSize();
686 if(FieldBits::NoField
!= (ParentsFieldMask
& whichField
))
688 returnValue
+= _mfParents
.getBinSize();
690 if(FieldBits::NoField
!= (DestroyedFunctorsFieldMask
& whichField
))
692 returnValue
+= _mfDestroyedFunctors
.getBinSize();
698 void ShaderProgramBase::copyToBin(BinaryDataHandler
&pMem
,
699 ConstFieldMaskArg whichField
)
701 Inherited::copyToBin(pMem
, whichField
);
703 if(FieldBits::NoField
!= (ShaderTypeFieldMask
& whichField
))
705 _sfShaderType
.copyToBin(pMem
);
707 if(FieldBits::NoField
!= (ProgramFieldMask
& whichField
))
709 _sfProgram
.copyToBin(pMem
);
711 if(FieldBits::NoField
!= (DefinesFieldMask
& whichField
))
713 _sfDefines
.copyToBin(pMem
);
715 if(FieldBits::NoField
!= (GLIdFieldMask
& whichField
))
717 _sfGLId
.copyToBin(pMem
);
719 if(FieldBits::NoField
!= (VariablesFieldMask
& whichField
))
721 _sfVariables
.copyToBin(pMem
);
723 if(FieldBits::NoField
!= (FeedbackVaryingsFieldMask
& whichField
))
725 _mfFeedbackVaryings
.copyToBin(pMem
);
727 if(FieldBits::NoField
!= (ParameterFieldMask
& whichField
))
729 _mfParameter
.copyToBin(pMem
);
731 if(FieldBits::NoField
!= (AttributesFieldMask
& whichField
))
733 _mfAttributes
.copyToBin(pMem
);
735 if(FieldBits::NoField
!= (CgFrontEndFieldMask
& whichField
))
737 _sfCgFrontEnd
.copyToBin(pMem
);
739 if(FieldBits::NoField
!= (PointSizeFieldMask
& whichField
))
741 _sfPointSize
.copyToBin(pMem
);
743 if(FieldBits::NoField
!= (ParentsFieldMask
& whichField
))
745 _mfParents
.copyToBin(pMem
);
747 if(FieldBits::NoField
!= (DestroyedFunctorsFieldMask
& whichField
))
749 _mfDestroyedFunctors
.copyToBin(pMem
);
753 void ShaderProgramBase::copyFromBin(BinaryDataHandler
&pMem
,
754 ConstFieldMaskArg whichField
)
756 Inherited::copyFromBin(pMem
, whichField
);
758 if(FieldBits::NoField
!= (ShaderTypeFieldMask
& whichField
))
760 editSField(ShaderTypeFieldMask
);
761 _sfShaderType
.copyFromBin(pMem
);
763 if(FieldBits::NoField
!= (ProgramFieldMask
& whichField
))
765 editSField(ProgramFieldMask
);
766 _sfProgram
.copyFromBin(pMem
);
768 if(FieldBits::NoField
!= (DefinesFieldMask
& whichField
))
770 editSField(DefinesFieldMask
);
771 _sfDefines
.copyFromBin(pMem
);
773 if(FieldBits::NoField
!= (GLIdFieldMask
& whichField
))
775 editSField(GLIdFieldMask
);
776 _sfGLId
.copyFromBin(pMem
);
778 if(FieldBits::NoField
!= (VariablesFieldMask
& whichField
))
780 editSField(VariablesFieldMask
);
781 _sfVariables
.copyFromBin(pMem
);
783 if(FieldBits::NoField
!= (FeedbackVaryingsFieldMask
& whichField
))
785 editMField(FeedbackVaryingsFieldMask
, _mfFeedbackVaryings
);
786 _mfFeedbackVaryings
.copyFromBin(pMem
);
788 if(FieldBits::NoField
!= (ParameterFieldMask
& whichField
))
790 editMField(ParameterFieldMask
, _mfParameter
);
791 _mfParameter
.copyFromBin(pMem
);
793 if(FieldBits::NoField
!= (AttributesFieldMask
& whichField
))
795 editMField(AttributesFieldMask
, _mfAttributes
);
796 _mfAttributes
.copyFromBin(pMem
);
798 if(FieldBits::NoField
!= (CgFrontEndFieldMask
& whichField
))
800 editSField(CgFrontEndFieldMask
);
801 _sfCgFrontEnd
.copyFromBin(pMem
);
803 if(FieldBits::NoField
!= (PointSizeFieldMask
& whichField
))
805 editSField(PointSizeFieldMask
);
806 _sfPointSize
.copyFromBin(pMem
);
808 if(FieldBits::NoField
!= (ParentsFieldMask
& whichField
))
810 editMField(ParentsFieldMask
, _mfParents
);
811 _mfParents
.copyFromBin(pMem
);
813 if(FieldBits::NoField
!= (DestroyedFunctorsFieldMask
& whichField
))
815 editMField(DestroyedFunctorsFieldMask
, _mfDestroyedFunctors
);
816 _mfDestroyedFunctors
.copyFromBin(pMem
);
820 //! create a new instance of the class
821 ShaderProgramTransitPtr
ShaderProgramBase::createLocal(BitVector bFlags
)
823 ShaderProgramTransitPtr fc
;
825 if(getClassType().getPrototype() != NULL
)
827 FieldContainerTransitPtr tmpPtr
=
828 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
830 fc
= dynamic_pointer_cast
<ShaderProgram
>(tmpPtr
);
836 //! create a new instance of the class, copy the container flags
837 ShaderProgramTransitPtr
ShaderProgramBase::createDependent(BitVector bFlags
)
839 ShaderProgramTransitPtr fc
;
841 if(getClassType().getPrototype() != NULL
)
843 FieldContainerTransitPtr tmpPtr
=
844 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
846 fc
= dynamic_pointer_cast
<ShaderProgram
>(tmpPtr
);
852 //! create a new instance of the class
853 ShaderProgramTransitPtr
ShaderProgramBase::create(void)
855 ShaderProgramTransitPtr fc
;
857 if(getClassType().getPrototype() != NULL
)
859 FieldContainerTransitPtr tmpPtr
=
860 getClassType().getPrototype()-> shallowCopy();
862 fc
= dynamic_pointer_cast
<ShaderProgram
>(tmpPtr
);
868 ShaderProgram
*ShaderProgramBase::createEmptyLocal(BitVector bFlags
)
870 ShaderProgram
*returnValue
;
872 newPtr
<ShaderProgram
>(returnValue
, bFlags
);
874 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
879 //! create an empty new instance of the class, do not copy the prototype
880 ShaderProgram
*ShaderProgramBase::createEmpty(void)
882 ShaderProgram
*returnValue
;
884 newPtr
<ShaderProgram
>(returnValue
, Thread::getCurrentLocalFlags());
886 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
887 ~Thread::getCurrentLocalFlags();
893 FieldContainerTransitPtr
ShaderProgramBase::shallowCopyLocal(
894 BitVector bFlags
) const
896 ShaderProgram
*tmpPtr
;
898 newPtr(tmpPtr
, dynamic_cast<const ShaderProgram
*>(this), bFlags
);
900 FieldContainerTransitPtr
returnValue(tmpPtr
);
902 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
907 FieldContainerTransitPtr
ShaderProgramBase::shallowCopyDependent(
908 BitVector bFlags
) const
910 ShaderProgram
*tmpPtr
;
912 newPtr(tmpPtr
, dynamic_cast<const ShaderProgram
*>(this), ~bFlags
);
914 FieldContainerTransitPtr
returnValue(tmpPtr
);
916 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
921 FieldContainerTransitPtr
ShaderProgramBase::shallowCopy(void) const
923 ShaderProgram
*tmpPtr
;
926 dynamic_cast<const ShaderProgram
*>(this),
927 Thread::getCurrentLocalFlags());
929 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
931 FieldContainerTransitPtr
returnValue(tmpPtr
);
939 /*------------------------- constructors ----------------------------------*/
941 ShaderProgramBase::ShaderProgramBase(void) :
943 _sfShaderType (GLenum(GL_NONE
)),
949 ShaderProgramVariables::ParentsFieldId
),
950 _mfFeedbackVaryings (),
953 _sfCgFrontEnd (bool(false)),
954 _sfPointSize (bool(false)),
956 _mfDestroyedFunctors ()
960 ShaderProgramBase::ShaderProgramBase(const ShaderProgramBase
&source
) :
962 _sfShaderType (source
._sfShaderType
),
963 _sfProgram (source
._sfProgram
),
964 _sfDefines (source
._sfDefines
),
965 _sfGLId (source
._sfGLId
),
968 ShaderProgramVariables::ParentsFieldId
),
969 _mfFeedbackVaryings (source
._mfFeedbackVaryings
),
970 _mfParameter (source
._mfParameter
),
971 _mfAttributes (source
._mfAttributes
),
972 _sfCgFrontEnd (source
._sfCgFrontEnd
),
973 _sfPointSize (source
._sfPointSize
),
975 _mfDestroyedFunctors (source
._mfDestroyedFunctors
)
980 /*-------------------------- destructors ----------------------------------*/
982 ShaderProgramBase::~ShaderProgramBase(void)
985 /*-------------------------------------------------------------------------*/
988 bool ShaderProgramBase::linkParent(
989 FieldContainer
* const pParent
,
990 UInt16
const childFieldId
,
991 UInt16
const parentFieldId
)
993 if(parentFieldId
== ParentsFieldId
)
995 FieldContainer
* pTypedParent
=
996 dynamic_cast< FieldContainer
* >(pParent
);
998 if(pTypedParent
!= NULL
)
1000 editMField(ParentsFieldMask
, _mfParents
);
1002 _mfParents
.push_back(pTypedParent
, childFieldId
);
1010 return Inherited::linkParent(pParent
, childFieldId
, parentFieldId
);
1013 bool ShaderProgramBase::unlinkParent(
1014 FieldContainer
* const pParent
,
1015 UInt16
const parentFieldId
)
1017 if(parentFieldId
== ParentsFieldId
)
1019 FieldContainer
* pTypedParent
=
1020 dynamic_cast< FieldContainer
* >(pParent
);
1022 if(pTypedParent
!= NULL
)
1024 Int32 iParentIdx
= _mfParents
.findIndex(pTypedParent
);
1026 if(iParentIdx
!= -1)
1028 editMField(ParentsFieldMask
, _mfParents
);
1030 _mfParents
.erase(iParentIdx
);
1035 SWARNING
<< "Child ([" << this
1036 << "] id [" << this->getId()
1037 << "] type [" << this->getType().getCName()
1038 << "] parentFieldId [" << parentFieldId
1039 << "]) - Parent ([" << pParent
1040 << "] id [" << pParent
->getId()
1041 << "] type [" << pParent
->getType().getCName()
1042 << "]): link inconsistent!"
1051 return Inherited::unlinkParent(pParent
, parentFieldId
);
1055 /*-------------------------------------------------------------------------*/
1058 bool ShaderProgramBase::unlinkChild(
1059 FieldContainer
* const pChild
,
1060 UInt16
const childFieldId
)
1062 if(childFieldId
== VariablesFieldId
)
1064 ShaderProgramVariables
* pTypedChild
=
1065 dynamic_cast<ShaderProgramVariables
*>(pChild
);
1067 if(pTypedChild
!= NULL
)
1069 if(_sfVariables
.getValue() == pTypedChild
)
1071 editSField(VariablesFieldMask
);
1073 _sfVariables
.setValue(NULL
);
1078 SWARNING
<< "Parent ([" << this
1079 << "] id [" << this->getId()
1080 << "] type [" << this->getType().getCName()
1081 << "] childFieldId [" << childFieldId
1082 << "]) - Child ([" << pChild
1083 << "] id [" << pChild
->getId()
1084 << "] type [" << pChild
->getType().getCName()
1085 << "]): link inconsistent!"
1095 return Inherited::unlinkChild(pChild
, childFieldId
);
1098 void ShaderProgramBase::onCreate(const ShaderProgram
*source
)
1100 Inherited::onCreate(source
);
1104 ShaderProgram
*pThis
= static_cast<ShaderProgram
*>(this);
1106 pThis
->setVariables(source
->getVariables());
1110 GetFieldHandlePtr
ShaderProgramBase::getHandleShaderType (void) const
1112 SFGLenum::GetHandlePtr
returnValue(
1113 new SFGLenum::GetHandle(
1115 this->getType().getFieldDesc(ShaderTypeFieldId
),
1116 const_cast<ShaderProgramBase
*>(this)));
1121 EditFieldHandlePtr
ShaderProgramBase::editHandleShaderType (void)
1123 SFGLenum::EditHandlePtr
returnValue(
1124 new SFGLenum::EditHandle(
1126 this->getType().getFieldDesc(ShaderTypeFieldId
),
1130 editSField(ShaderTypeFieldMask
);
1135 GetFieldHandlePtr
ShaderProgramBase::getHandleProgram (void) const
1137 SFString::GetHandlePtr
returnValue(
1138 new SFString::GetHandle(
1140 this->getType().getFieldDesc(ProgramFieldId
),
1141 const_cast<ShaderProgramBase
*>(this)));
1146 EditFieldHandlePtr
ShaderProgramBase::editHandleProgram (void)
1148 SFString::EditHandlePtr
returnValue(
1149 new SFString::EditHandle(
1151 this->getType().getFieldDesc(ProgramFieldId
),
1155 editSField(ProgramFieldMask
);
1160 GetFieldHandlePtr
ShaderProgramBase::getHandleDefines (void) const
1162 SFString::GetHandlePtr
returnValue(
1163 new SFString::GetHandle(
1165 this->getType().getFieldDesc(DefinesFieldId
),
1166 const_cast<ShaderProgramBase
*>(this)));
1171 EditFieldHandlePtr
ShaderProgramBase::editHandleDefines (void)
1173 SFString::EditHandlePtr
returnValue(
1174 new SFString::EditHandle(
1176 this->getType().getFieldDesc(DefinesFieldId
),
1180 editSField(DefinesFieldMask
);
1185 GetFieldHandlePtr
ShaderProgramBase::getHandleGLId (void) const
1187 SFUInt32::GetHandlePtr
returnValue(
1188 new SFUInt32::GetHandle(
1190 this->getType().getFieldDesc(GLIdFieldId
),
1191 const_cast<ShaderProgramBase
*>(this)));
1196 EditFieldHandlePtr
ShaderProgramBase::editHandleGLId (void)
1198 SFUInt32::EditHandlePtr
returnValue(
1199 new SFUInt32::EditHandle(
1201 this->getType().getFieldDesc(GLIdFieldId
),
1205 editSField(GLIdFieldMask
);
1210 GetFieldHandlePtr
ShaderProgramBase::getHandleVariables (void) const
1212 SFUnrecChildShaderProgramVariablesPtr::GetHandlePtr
returnValue(
1213 new SFUnrecChildShaderProgramVariablesPtr::GetHandle(
1215 this->getType().getFieldDesc(VariablesFieldId
),
1216 const_cast<ShaderProgramBase
*>(this)));
1221 EditFieldHandlePtr
ShaderProgramBase::editHandleVariables (void)
1223 SFUnrecChildShaderProgramVariablesPtr::EditHandlePtr
returnValue(
1224 new SFUnrecChildShaderProgramVariablesPtr::EditHandle(
1226 this->getType().getFieldDesc(VariablesFieldId
),
1229 returnValue
->setSetMethod(
1230 boost::bind(&ShaderProgram::setVariables
,
1231 static_cast<ShaderProgram
*>(this), _1
));
1233 editSField(VariablesFieldMask
);
1238 GetFieldHandlePtr
ShaderProgramBase::getHandleFeedbackVaryings (void) const
1240 MFString::GetHandlePtr
returnValue(
1241 new MFString::GetHandle(
1242 &_mfFeedbackVaryings
,
1243 this->getType().getFieldDesc(FeedbackVaryingsFieldId
),
1244 const_cast<ShaderProgramBase
*>(this)));
1249 EditFieldHandlePtr
ShaderProgramBase::editHandleFeedbackVaryings(void)
1251 MFString::EditHandlePtr
returnValue(
1252 new MFString::EditHandle(
1253 &_mfFeedbackVaryings
,
1254 this->getType().getFieldDesc(FeedbackVaryingsFieldId
),
1258 editMField(FeedbackVaryingsFieldMask
, _mfFeedbackVaryings
);
1263 GetFieldHandlePtr
ShaderProgramBase::getHandleParameter (void) const
1265 MFShaderParameter::GetHandlePtr
returnValue(
1266 new MFShaderParameter::GetHandle(
1268 this->getType().getFieldDesc(ParameterFieldId
),
1269 const_cast<ShaderProgramBase
*>(this)));
1274 EditFieldHandlePtr
ShaderProgramBase::editHandleParameter (void)
1276 MFShaderParameter::EditHandlePtr
returnValue(
1277 new MFShaderParameter::EditHandle(
1279 this->getType().getFieldDesc(ParameterFieldId
),
1283 editMField(ParameterFieldMask
, _mfParameter
);
1288 GetFieldHandlePtr
ShaderProgramBase::getHandleAttributes (void) const
1290 MFShaderAttribute::GetHandlePtr
returnValue(
1291 new MFShaderAttribute::GetHandle(
1293 this->getType().getFieldDesc(AttributesFieldId
),
1294 const_cast<ShaderProgramBase
*>(this)));
1299 EditFieldHandlePtr
ShaderProgramBase::editHandleAttributes (void)
1301 MFShaderAttribute::EditHandlePtr
returnValue(
1302 new MFShaderAttribute::EditHandle(
1304 this->getType().getFieldDesc(AttributesFieldId
),
1308 editMField(AttributesFieldMask
, _mfAttributes
);
1313 GetFieldHandlePtr
ShaderProgramBase::getHandleCgFrontEnd (void) const
1315 SFBool::GetHandlePtr
returnValue(
1316 new SFBool::GetHandle(
1318 this->getType().getFieldDesc(CgFrontEndFieldId
),
1319 const_cast<ShaderProgramBase
*>(this)));
1324 EditFieldHandlePtr
ShaderProgramBase::editHandleCgFrontEnd (void)
1326 SFBool::EditHandlePtr
returnValue(
1327 new SFBool::EditHandle(
1329 this->getType().getFieldDesc(CgFrontEndFieldId
),
1333 editSField(CgFrontEndFieldMask
);
1338 GetFieldHandlePtr
ShaderProgramBase::getHandlePointSize (void) const
1340 SFBool::GetHandlePtr
returnValue(
1341 new SFBool::GetHandle(
1343 this->getType().getFieldDesc(PointSizeFieldId
),
1344 const_cast<ShaderProgramBase
*>(this)));
1349 EditFieldHandlePtr
ShaderProgramBase::editHandlePointSize (void)
1351 SFBool::EditHandlePtr
returnValue(
1352 new SFBool::EditHandle(
1354 this->getType().getFieldDesc(PointSizeFieldId
),
1358 editSField(PointSizeFieldMask
);
1363 GetFieldHandlePtr
ShaderProgramBase::getHandleParents (void) const
1365 MFParentFieldContainerPtr::GetHandlePtr returnValue
;
1370 EditFieldHandlePtr
ShaderProgramBase::editHandleParents (void)
1372 EditFieldHandlePtr returnValue
;
1377 GetFieldHandlePtr
ShaderProgramBase::getHandleDestroyedFunctors (void) const
1379 MFChangedFunctorCallback::GetHandlePtr returnValue
;
1384 EditFieldHandlePtr
ShaderProgramBase::editHandleDestroyedFunctors(void)
1386 EditFieldHandlePtr returnValue
;
1392 #ifdef OSG_MT_CPTR_ASPECT
1393 void ShaderProgramBase::execSyncV( FieldContainer
&oFrom
,
1394 ConstFieldMaskArg whichField
,
1395 AspectOffsetStore
&oOffsets
,
1396 ConstFieldMaskArg syncMode
,
1397 const UInt32 uiSyncInfo
)
1399 ShaderProgram
*pThis
= static_cast<ShaderProgram
*>(this);
1401 pThis
->execSync(static_cast<ShaderProgram
*>(&oFrom
),
1410 #ifdef OSG_MT_CPTR_ASPECT
1411 FieldContainer
*ShaderProgramBase::createAspectCopy(
1412 const FieldContainer
*pRefAspect
) const
1414 ShaderProgram
*returnValue
;
1416 newAspectCopy(returnValue
,
1417 dynamic_cast<const ShaderProgram
*>(pRefAspect
),
1418 dynamic_cast<const ShaderProgram
*>(this));
1424 void ShaderProgramBase::resolveLinks(void)
1426 Inherited::resolveLinks();
1428 static_cast<ShaderProgram
*>(this)->setVariables(NULL
);
1430 #ifdef OSG_MT_CPTR_ASPECT
1431 AspectOffsetStore oOffsets
;
1433 _pAspectStore
->fillOffsetArray(oOffsets
, this);
1436 #ifdef OSG_MT_CPTR_ASPECT
1437 _mfFeedbackVaryings
.terminateShare(Thread::getCurrentAspect(),
1440 #ifdef OSG_MT_CPTR_ASPECT
1441 _mfParameter
.terminateShare(Thread::getCurrentAspect(),
1444 #ifdef OSG_MT_CPTR_ASPECT
1445 _mfAttributes
.terminateShare(Thread::getCurrentAspect(),
1448 #ifdef OSG_MT_CPTR_ASPECT
1449 _mfDestroyedFunctors
.terminateShare(Thread::getCurrentAspect(),