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 ShaderProgramChunk!
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" // GeometryInputType default header
65 #include "OSGGL.h" // GeometryOutputType default header
67 #include "OSGShaderProgram.h" // VertexShader Class
69 #include "OSGShaderProgramChunkBase.h"
70 #include "OSGShaderProgramChunk.h"
72 #include <boost/bind.hpp>
76 /***************************************************************************\
78 \***************************************************************************/
80 /*! \class OSG::ShaderProgramChunk
84 /***************************************************************************\
85 * Field Documentation *
86 \***************************************************************************/
88 /*! \var ShaderProgram * ShaderProgramChunkBase::_mfVertexShader
89 fragment program object
92 /*! \var ShaderProgram * ShaderProgramChunkBase::_mfTessControlShader
93 fragment program object
96 /*! \var ShaderProgram * ShaderProgramChunkBase::_mfTessEvaluationShader
97 fragment program object
100 /*! \var ShaderProgram * ShaderProgramChunkBase::_mfGeometryShader
101 fragment program object
104 /*! \var ShaderProgram * ShaderProgramChunkBase::_mfFragmentShader
105 fragment program object
108 /*! \var UInt32 ShaderProgramChunkBase::_sfGeometryVerticesOut
112 /*! \var GLenum ShaderProgramChunkBase::_sfGeometryInputType
116 /*! \var GLenum ShaderProgramChunkBase::_sfGeometryOutputType
121 /***************************************************************************\
122 * FieldType/FieldTrait Instantiation *
123 \***************************************************************************/
125 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
126 PointerType FieldTraits
<ShaderProgramChunk
*, nsOSG
>::_type(
127 "ShaderProgramChunkPtr",
129 ShaderProgramChunk::getClassType(),
133 OSG_FIELDTRAITS_GETTYPE_NS(ShaderProgramChunk
*, nsOSG
)
135 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
136 ShaderProgramChunk
*,
139 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
140 ShaderProgramChunk
*,
143 /***************************************************************************\
144 * Field Description *
145 \***************************************************************************/
147 void ShaderProgramChunkBase::classDescInserter(TypeObject
&oType
)
149 FieldDescriptionBase
*pDesc
= NULL
;
152 pDesc
= new MFUnrecShaderProgramPtr::Description(
153 MFUnrecShaderProgramPtr::getClassType(),
155 "fragment program object\n",
156 VertexShaderFieldId
, VertexShaderFieldMask
,
158 (Field::MFDefaultFlags
| Field::FStdAccess
),
159 static_cast<FieldEditMethodSig
>(&ShaderProgramChunk::editHandleVertexShader
),
160 static_cast<FieldGetMethodSig
>(&ShaderProgramChunk::getHandleVertexShader
));
162 oType
.addInitialDesc(pDesc
);
164 pDesc
= new MFUnrecShaderProgramPtr::Description(
165 MFUnrecShaderProgramPtr::getClassType(),
167 "fragment program object\n",
168 TessControlShaderFieldId
, TessControlShaderFieldMask
,
170 (Field::MFDefaultFlags
| Field::FStdAccess
),
171 static_cast<FieldEditMethodSig
>(&ShaderProgramChunk::editHandleTessControlShader
),
172 static_cast<FieldGetMethodSig
>(&ShaderProgramChunk::getHandleTessControlShader
));
174 oType
.addInitialDesc(pDesc
);
176 pDesc
= new MFUnrecShaderProgramPtr::Description(
177 MFUnrecShaderProgramPtr::getClassType(),
178 "tessEvaluationShader",
179 "fragment program object\n",
180 TessEvaluationShaderFieldId
, TessEvaluationShaderFieldMask
,
182 (Field::MFDefaultFlags
| Field::FStdAccess
),
183 static_cast<FieldEditMethodSig
>(&ShaderProgramChunk::editHandleTessEvaluationShader
),
184 static_cast<FieldGetMethodSig
>(&ShaderProgramChunk::getHandleTessEvaluationShader
));
186 oType
.addInitialDesc(pDesc
);
188 pDesc
= new MFUnrecShaderProgramPtr::Description(
189 MFUnrecShaderProgramPtr::getClassType(),
191 "fragment program object\n",
192 GeometryShaderFieldId
, GeometryShaderFieldMask
,
194 (Field::MFDefaultFlags
| Field::FStdAccess
),
195 static_cast<FieldEditMethodSig
>(&ShaderProgramChunk::editHandleGeometryShader
),
196 static_cast<FieldGetMethodSig
>(&ShaderProgramChunk::getHandleGeometryShader
));
198 oType
.addInitialDesc(pDesc
);
200 pDesc
= new MFUnrecShaderProgramPtr::Description(
201 MFUnrecShaderProgramPtr::getClassType(),
203 "fragment program object\n",
204 FragmentShaderFieldId
, FragmentShaderFieldMask
,
206 (Field::MFDefaultFlags
| Field::FStdAccess
),
207 static_cast<FieldEditMethodSig
>(&ShaderProgramChunk::editHandleFragmentShader
),
208 static_cast<FieldGetMethodSig
>(&ShaderProgramChunk::getHandleFragmentShader
));
210 oType
.addInitialDesc(pDesc
);
212 pDesc
= new SFUInt32::Description(
213 SFUInt32::getClassType(),
214 "geometryVerticesOut",
216 GeometryVerticesOutFieldId
, GeometryVerticesOutFieldMask
,
218 (Field::SFDefaultFlags
| Field::FStdAccess
),
219 static_cast<FieldEditMethodSig
>(&ShaderProgramChunk::editHandleGeometryVerticesOut
),
220 static_cast<FieldGetMethodSig
>(&ShaderProgramChunk::getHandleGeometryVerticesOut
));
222 oType
.addInitialDesc(pDesc
);
224 pDesc
= new SFGLenum::Description(
225 SFGLenum::getClassType(),
228 GeometryInputTypeFieldId
, GeometryInputTypeFieldMask
,
230 (Field::SFDefaultFlags
| Field::FStdAccess
),
231 static_cast<FieldEditMethodSig
>(&ShaderProgramChunk::editHandleGeometryInputType
),
232 static_cast<FieldGetMethodSig
>(&ShaderProgramChunk::getHandleGeometryInputType
));
234 oType
.addInitialDesc(pDesc
);
236 pDesc
= new SFGLenum::Description(
237 SFGLenum::getClassType(),
238 "geometryOutputType",
240 GeometryOutputTypeFieldId
, GeometryOutputTypeFieldMask
,
242 (Field::SFDefaultFlags
| Field::FStdAccess
),
243 static_cast<FieldEditMethodSig
>(&ShaderProgramChunk::editHandleGeometryOutputType
),
244 static_cast<FieldGetMethodSig
>(&ShaderProgramChunk::getHandleGeometryOutputType
));
246 oType
.addInitialDesc(pDesc
);
250 ShaderProgramChunkBase::TypeObject
ShaderProgramChunkBase::_type(
251 ShaderProgramChunkBase::getClassname(),
252 Inherited::getClassname(),
255 reinterpret_cast<PrototypeCreateF
>(&ShaderProgramChunkBase::createEmptyLocal
),
256 reinterpret_cast<InitContainerF
>(&ShaderProgramChunk::initMethod
),
257 reinterpret_cast<ExitContainerF
>(&ShaderProgramChunk::exitMethod
),
258 reinterpret_cast<InitalInsertDescFunc
>(
259 reinterpret_cast<void *>(&ShaderProgramChunk::classDescInserter
)),
262 "<?xml version=\"1.0\"?>\n"
265 " name=\"ShaderProgramChunk\"\n"
266 " parent=\"StateChunk\"\n"
267 " library=\"System\"\n"
268 " pointerfieldtypes=\"both\"\n"
269 " structure=\"concrete\"\n"
270 " systemcomponent=\"true\"\n"
271 " parentsystemcomponent=\"true\"\n"
272 " decoratable=\"false\"\n"
273 " useLocalIncludes=\"false\"\n"
274 " docGroupBase=\"GrpSystemShader\"\n"
277 "\t name=\"vertexShader\"\n"
278 "\t type=\"ShaderProgram\"\n"
279 "\t cardinality=\"multi\"\n"
280 "\t visibility=\"external\"\n"
281 "\t access=\"public\"\n"
282 " category=\"pointer\"\n"
284 " pushToFieldAs=\"addVertexShader\"\n"
285 " removeFromMFieldIndexAs=\"subVertexShader\"\n"
286 " clearFieldAs=\"clearVertexShaders\" \n"
288 "\tfragment program object\n"
291 "\t name=\"tessControlShader\"\n"
292 "\t type=\"ShaderProgram\"\n"
293 "\t cardinality=\"multi\"\n"
294 "\t visibility=\"external\"\n"
295 "\t access=\"public\"\n"
296 " category=\"pointer\"\n"
298 " pushToFieldAs=\"addTessControlShader\"\n"
299 " removeFromMFieldIndexAs=\"subTessControlShader\"\n"
300 " clearFieldAs=\"clearTessControlShaders\" \n"
302 "\tfragment program object\n"
305 "\t name=\"tessEvaluationShader\"\n"
306 "\t type=\"ShaderProgram\"\n"
307 "\t cardinality=\"multi\"\n"
308 "\t visibility=\"external\"\n"
309 "\t access=\"public\"\n"
310 " category=\"pointer\"\n"
312 " pushToFieldAs=\"addTessEvaluationShader\"\n"
313 " removeFromMFieldIndexAs=\"subTessEvaluationShader\"\n"
314 " clearFieldAs=\"clearTessEvaluationShaders\" \n"
316 "\tfragment program object\n"
319 "\t name=\"geometryShader\"\n"
320 "\t type=\"ShaderProgram\"\n"
321 "\t cardinality=\"multi\"\n"
322 "\t visibility=\"external\"\n"
323 "\t access=\"public\"\n"
324 " category=\"pointer\"\n"
326 " pushToFieldAs=\"addGeometryShader\"\n"
327 " removeFromMFieldIndexAs=\"subGeometryShader\"\n"
328 " clearFieldAs=\"clearGeometryShaders\" \n"
330 "\tfragment program object\n"
333 "\t name=\"fragmentShader\"\n"
334 "\t type=\"ShaderProgram\"\n"
335 "\t cardinality=\"multi\"\n"
336 "\t visibility=\"external\"\n"
337 "\t access=\"public\"\n"
338 " category=\"pointer\"\n"
340 " pushToFieldAs=\"addFragmentShader\"\n"
341 " removeFromMFieldIndexAs=\"subFragmentShader\"\n"
342 " clearFieldAs=\"clearFragmentShaders\" \n"
344 "\tfragment program object\n"
348 "\t name=\"geometryVerticesOut\"\n"
349 "\t type=\"UInt32\"\n"
350 "\t cardinality=\"single\"\n"
351 "\t visibility=\"external\"\n"
352 "\t defaultValue=\"0\"\n"
356 "\t name=\"geometryInputType\"\n"
357 "\t type=\"GLenum\"\n"
358 "\t cardinality=\"single\"\n"
359 "\t visibility=\"external\"\n"
360 "\t defaultValue=\"GL_TRIANGLES\"\n"
361 "\t defaultHeader=\""OSGGL.h"\"\n"
365 "\t name=\"geometryOutputType\"\n"
366 "\t type=\"GLenum\"\n"
367 "\t cardinality=\"single\"\n"
368 "\t visibility=\"external\"\n"
369 "\t defaultValue=\"GL_TRIANGLE_STRIP\"\n"
370 "\t defaultHeader=\""OSGGL.h"\"\n"
374 "</FieldContainer>\n",
378 /*------------------------------ get -----------------------------------*/
380 FieldContainerType
&ShaderProgramChunkBase::getType(void)
385 const FieldContainerType
&ShaderProgramChunkBase::getType(void) const
390 UInt32
ShaderProgramChunkBase::getContainerSize(void) const
392 return sizeof(ShaderProgramChunk
);
395 /*------------------------- decorator get ------------------------------*/
398 //! Get the ShaderProgramChunk::_mfVertexShader field.
399 const MFUnrecShaderProgramPtr
*ShaderProgramChunkBase::getMFVertexShader(void) const
401 return &_mfVertexShader
;
404 MFUnrecShaderProgramPtr
*ShaderProgramChunkBase::editMFVertexShader (void)
406 editMField(VertexShaderFieldMask
, _mfVertexShader
);
408 return &_mfVertexShader
;
410 ShaderProgram
* ShaderProgramChunkBase::getVertexShader(const UInt32 index
) const
412 return _mfVertexShader
[index
];
415 //! Get the ShaderProgramChunk::_mfTessControlShader field.
416 const MFUnrecShaderProgramPtr
*ShaderProgramChunkBase::getMFTessControlShader(void) const
418 return &_mfTessControlShader
;
421 MFUnrecShaderProgramPtr
*ShaderProgramChunkBase::editMFTessControlShader(void)
423 editMField(TessControlShaderFieldMask
, _mfTessControlShader
);
425 return &_mfTessControlShader
;
427 ShaderProgram
* ShaderProgramChunkBase::getTessControlShader(const UInt32 index
) const
429 return _mfTessControlShader
[index
];
432 //! Get the ShaderProgramChunk::_mfTessEvaluationShader field.
433 const MFUnrecShaderProgramPtr
*ShaderProgramChunkBase::getMFTessEvaluationShader(void) const
435 return &_mfTessEvaluationShader
;
438 MFUnrecShaderProgramPtr
*ShaderProgramChunkBase::editMFTessEvaluationShader(void)
440 editMField(TessEvaluationShaderFieldMask
, _mfTessEvaluationShader
);
442 return &_mfTessEvaluationShader
;
444 ShaderProgram
* ShaderProgramChunkBase::getTessEvaluationShader(const UInt32 index
) const
446 return _mfTessEvaluationShader
[index
];
449 //! Get the ShaderProgramChunk::_mfGeometryShader field.
450 const MFUnrecShaderProgramPtr
*ShaderProgramChunkBase::getMFGeometryShader(void) const
452 return &_mfGeometryShader
;
455 MFUnrecShaderProgramPtr
*ShaderProgramChunkBase::editMFGeometryShader (void)
457 editMField(GeometryShaderFieldMask
, _mfGeometryShader
);
459 return &_mfGeometryShader
;
461 ShaderProgram
* ShaderProgramChunkBase::getGeometryShader(const UInt32 index
) const
463 return _mfGeometryShader
[index
];
466 //! Get the ShaderProgramChunk::_mfFragmentShader field.
467 const MFUnrecShaderProgramPtr
*ShaderProgramChunkBase::getMFFragmentShader(void) const
469 return &_mfFragmentShader
;
472 MFUnrecShaderProgramPtr
*ShaderProgramChunkBase::editMFFragmentShader (void)
474 editMField(FragmentShaderFieldMask
, _mfFragmentShader
);
476 return &_mfFragmentShader
;
478 ShaderProgram
* ShaderProgramChunkBase::getFragmentShader(const UInt32 index
) const
480 return _mfFragmentShader
[index
];
483 SFUInt32
*ShaderProgramChunkBase::editSFGeometryVerticesOut(void)
485 editSField(GeometryVerticesOutFieldMask
);
487 return &_sfGeometryVerticesOut
;
490 const SFUInt32
*ShaderProgramChunkBase::getSFGeometryVerticesOut(void) const
492 return &_sfGeometryVerticesOut
;
496 SFGLenum
*ShaderProgramChunkBase::editSFGeometryInputType(void)
498 editSField(GeometryInputTypeFieldMask
);
500 return &_sfGeometryInputType
;
503 const SFGLenum
*ShaderProgramChunkBase::getSFGeometryInputType(void) const
505 return &_sfGeometryInputType
;
509 SFGLenum
*ShaderProgramChunkBase::editSFGeometryOutputType(void)
511 editSField(GeometryOutputTypeFieldMask
);
513 return &_sfGeometryOutputType
;
516 const SFGLenum
*ShaderProgramChunkBase::getSFGeometryOutputType(void) const
518 return &_sfGeometryOutputType
;
524 void ShaderProgramChunkBase::addVertexShader(ShaderProgram
* const value
)
526 editMField(VertexShaderFieldMask
, _mfVertexShader
);
528 _mfVertexShader
.push_back(value
);
531 void ShaderProgramChunkBase::assignVertexShader(const MFUnrecShaderProgramPtr
&value
)
533 MFUnrecShaderProgramPtr::const_iterator elemIt
=
535 MFUnrecShaderProgramPtr::const_iterator elemEnd
=
538 static_cast<ShaderProgramChunk
*>(this)->clearVertexShaders();
540 while(elemIt
!= elemEnd
)
542 this->addVertexShader(*elemIt
);
548 void ShaderProgramChunkBase::subVertexShader(UInt32 uiIndex
)
550 if(uiIndex
< _mfVertexShader
.size())
552 editMField(VertexShaderFieldMask
, _mfVertexShader
);
554 _mfVertexShader
.erase(uiIndex
);
558 void ShaderProgramChunkBase::removeObjFromVertexShader(ShaderProgram
* const value
)
560 Int32 iElemIdx
= _mfVertexShader
.findIndex(value
);
564 editMField(VertexShaderFieldMask
, _mfVertexShader
);
566 _mfVertexShader
.erase(iElemIdx
);
569 void ShaderProgramChunkBase::clearVertexShaders(void)
571 editMField(VertexShaderFieldMask
, _mfVertexShader
);
574 _mfVertexShader
.clear();
577 void ShaderProgramChunkBase::addTessControlShader(ShaderProgram
* const value
)
579 editMField(TessControlShaderFieldMask
, _mfTessControlShader
);
581 _mfTessControlShader
.push_back(value
);
584 void ShaderProgramChunkBase::assignTessControlShader(const MFUnrecShaderProgramPtr
&value
)
586 MFUnrecShaderProgramPtr::const_iterator elemIt
=
588 MFUnrecShaderProgramPtr::const_iterator elemEnd
=
591 static_cast<ShaderProgramChunk
*>(this)->clearTessControlShaders();
593 while(elemIt
!= elemEnd
)
595 this->addTessControlShader(*elemIt
);
601 void ShaderProgramChunkBase::subTessControlShader(UInt32 uiIndex
)
603 if(uiIndex
< _mfTessControlShader
.size())
605 editMField(TessControlShaderFieldMask
, _mfTessControlShader
);
607 _mfTessControlShader
.erase(uiIndex
);
611 void ShaderProgramChunkBase::removeObjFromTessControlShader(ShaderProgram
* const value
)
613 Int32 iElemIdx
= _mfTessControlShader
.findIndex(value
);
617 editMField(TessControlShaderFieldMask
, _mfTessControlShader
);
619 _mfTessControlShader
.erase(iElemIdx
);
622 void ShaderProgramChunkBase::clearTessControlShaders(void)
624 editMField(TessControlShaderFieldMask
, _mfTessControlShader
);
627 _mfTessControlShader
.clear();
630 void ShaderProgramChunkBase::addTessEvaluationShader(ShaderProgram
* const value
)
632 editMField(TessEvaluationShaderFieldMask
, _mfTessEvaluationShader
);
634 _mfTessEvaluationShader
.push_back(value
);
637 void ShaderProgramChunkBase::assignTessEvaluationShader(const MFUnrecShaderProgramPtr
&value
)
639 MFUnrecShaderProgramPtr::const_iterator elemIt
=
641 MFUnrecShaderProgramPtr::const_iterator elemEnd
=
644 static_cast<ShaderProgramChunk
*>(this)->clearTessEvaluationShaders();
646 while(elemIt
!= elemEnd
)
648 this->addTessEvaluationShader(*elemIt
);
654 void ShaderProgramChunkBase::subTessEvaluationShader(UInt32 uiIndex
)
656 if(uiIndex
< _mfTessEvaluationShader
.size())
658 editMField(TessEvaluationShaderFieldMask
, _mfTessEvaluationShader
);
660 _mfTessEvaluationShader
.erase(uiIndex
);
664 void ShaderProgramChunkBase::removeObjFromTessEvaluationShader(ShaderProgram
* const value
)
666 Int32 iElemIdx
= _mfTessEvaluationShader
.findIndex(value
);
670 editMField(TessEvaluationShaderFieldMask
, _mfTessEvaluationShader
);
672 _mfTessEvaluationShader
.erase(iElemIdx
);
675 void ShaderProgramChunkBase::clearTessEvaluationShaders(void)
677 editMField(TessEvaluationShaderFieldMask
, _mfTessEvaluationShader
);
680 _mfTessEvaluationShader
.clear();
683 void ShaderProgramChunkBase::addGeometryShader(ShaderProgram
* const value
)
685 editMField(GeometryShaderFieldMask
, _mfGeometryShader
);
687 _mfGeometryShader
.push_back(value
);
690 void ShaderProgramChunkBase::assignGeometryShader(const MFUnrecShaderProgramPtr
&value
)
692 MFUnrecShaderProgramPtr::const_iterator elemIt
=
694 MFUnrecShaderProgramPtr::const_iterator elemEnd
=
697 static_cast<ShaderProgramChunk
*>(this)->clearGeometryShaders();
699 while(elemIt
!= elemEnd
)
701 this->addGeometryShader(*elemIt
);
707 void ShaderProgramChunkBase::subGeometryShader(UInt32 uiIndex
)
709 if(uiIndex
< _mfGeometryShader
.size())
711 editMField(GeometryShaderFieldMask
, _mfGeometryShader
);
713 _mfGeometryShader
.erase(uiIndex
);
717 void ShaderProgramChunkBase::removeObjFromGeometryShader(ShaderProgram
* const value
)
719 Int32 iElemIdx
= _mfGeometryShader
.findIndex(value
);
723 editMField(GeometryShaderFieldMask
, _mfGeometryShader
);
725 _mfGeometryShader
.erase(iElemIdx
);
728 void ShaderProgramChunkBase::clearGeometryShaders(void)
730 editMField(GeometryShaderFieldMask
, _mfGeometryShader
);
733 _mfGeometryShader
.clear();
736 void ShaderProgramChunkBase::addFragmentShader(ShaderProgram
* const value
)
738 editMField(FragmentShaderFieldMask
, _mfFragmentShader
);
740 _mfFragmentShader
.push_back(value
);
743 void ShaderProgramChunkBase::assignFragmentShader(const MFUnrecShaderProgramPtr
&value
)
745 MFUnrecShaderProgramPtr::const_iterator elemIt
=
747 MFUnrecShaderProgramPtr::const_iterator elemEnd
=
750 static_cast<ShaderProgramChunk
*>(this)->clearFragmentShaders();
752 while(elemIt
!= elemEnd
)
754 this->addFragmentShader(*elemIt
);
760 void ShaderProgramChunkBase::subFragmentShader(UInt32 uiIndex
)
762 if(uiIndex
< _mfFragmentShader
.size())
764 editMField(FragmentShaderFieldMask
, _mfFragmentShader
);
766 _mfFragmentShader
.erase(uiIndex
);
770 void ShaderProgramChunkBase::removeObjFromFragmentShader(ShaderProgram
* const value
)
772 Int32 iElemIdx
= _mfFragmentShader
.findIndex(value
);
776 editMField(FragmentShaderFieldMask
, _mfFragmentShader
);
778 _mfFragmentShader
.erase(iElemIdx
);
781 void ShaderProgramChunkBase::clearFragmentShaders(void)
783 editMField(FragmentShaderFieldMask
, _mfFragmentShader
);
786 _mfFragmentShader
.clear();
791 /*------------------------------ access -----------------------------------*/
793 SizeT
ShaderProgramChunkBase::getBinSize(ConstFieldMaskArg whichField
)
795 SizeT returnValue
= Inherited::getBinSize(whichField
);
797 if(FieldBits::NoField
!= (VertexShaderFieldMask
& whichField
))
799 returnValue
+= _mfVertexShader
.getBinSize();
801 if(FieldBits::NoField
!= (TessControlShaderFieldMask
& whichField
))
803 returnValue
+= _mfTessControlShader
.getBinSize();
805 if(FieldBits::NoField
!= (TessEvaluationShaderFieldMask
& whichField
))
807 returnValue
+= _mfTessEvaluationShader
.getBinSize();
809 if(FieldBits::NoField
!= (GeometryShaderFieldMask
& whichField
))
811 returnValue
+= _mfGeometryShader
.getBinSize();
813 if(FieldBits::NoField
!= (FragmentShaderFieldMask
& whichField
))
815 returnValue
+= _mfFragmentShader
.getBinSize();
817 if(FieldBits::NoField
!= (GeometryVerticesOutFieldMask
& whichField
))
819 returnValue
+= _sfGeometryVerticesOut
.getBinSize();
821 if(FieldBits::NoField
!= (GeometryInputTypeFieldMask
& whichField
))
823 returnValue
+= _sfGeometryInputType
.getBinSize();
825 if(FieldBits::NoField
!= (GeometryOutputTypeFieldMask
& whichField
))
827 returnValue
+= _sfGeometryOutputType
.getBinSize();
833 void ShaderProgramChunkBase::copyToBin(BinaryDataHandler
&pMem
,
834 ConstFieldMaskArg whichField
)
836 Inherited::copyToBin(pMem
, whichField
);
838 if(FieldBits::NoField
!= (VertexShaderFieldMask
& whichField
))
840 _mfVertexShader
.copyToBin(pMem
);
842 if(FieldBits::NoField
!= (TessControlShaderFieldMask
& whichField
))
844 _mfTessControlShader
.copyToBin(pMem
);
846 if(FieldBits::NoField
!= (TessEvaluationShaderFieldMask
& whichField
))
848 _mfTessEvaluationShader
.copyToBin(pMem
);
850 if(FieldBits::NoField
!= (GeometryShaderFieldMask
& whichField
))
852 _mfGeometryShader
.copyToBin(pMem
);
854 if(FieldBits::NoField
!= (FragmentShaderFieldMask
& whichField
))
856 _mfFragmentShader
.copyToBin(pMem
);
858 if(FieldBits::NoField
!= (GeometryVerticesOutFieldMask
& whichField
))
860 _sfGeometryVerticesOut
.copyToBin(pMem
);
862 if(FieldBits::NoField
!= (GeometryInputTypeFieldMask
& whichField
))
864 _sfGeometryInputType
.copyToBin(pMem
);
866 if(FieldBits::NoField
!= (GeometryOutputTypeFieldMask
& whichField
))
868 _sfGeometryOutputType
.copyToBin(pMem
);
872 void ShaderProgramChunkBase::copyFromBin(BinaryDataHandler
&pMem
,
873 ConstFieldMaskArg whichField
)
875 Inherited::copyFromBin(pMem
, whichField
);
877 if(FieldBits::NoField
!= (VertexShaderFieldMask
& whichField
))
879 editMField(VertexShaderFieldMask
, _mfVertexShader
);
880 _mfVertexShader
.copyFromBin(pMem
);
882 if(FieldBits::NoField
!= (TessControlShaderFieldMask
& whichField
))
884 editMField(TessControlShaderFieldMask
, _mfTessControlShader
);
885 _mfTessControlShader
.copyFromBin(pMem
);
887 if(FieldBits::NoField
!= (TessEvaluationShaderFieldMask
& whichField
))
889 editMField(TessEvaluationShaderFieldMask
, _mfTessEvaluationShader
);
890 _mfTessEvaluationShader
.copyFromBin(pMem
);
892 if(FieldBits::NoField
!= (GeometryShaderFieldMask
& whichField
))
894 editMField(GeometryShaderFieldMask
, _mfGeometryShader
);
895 _mfGeometryShader
.copyFromBin(pMem
);
897 if(FieldBits::NoField
!= (FragmentShaderFieldMask
& whichField
))
899 editMField(FragmentShaderFieldMask
, _mfFragmentShader
);
900 _mfFragmentShader
.copyFromBin(pMem
);
902 if(FieldBits::NoField
!= (GeometryVerticesOutFieldMask
& whichField
))
904 editSField(GeometryVerticesOutFieldMask
);
905 _sfGeometryVerticesOut
.copyFromBin(pMem
);
907 if(FieldBits::NoField
!= (GeometryInputTypeFieldMask
& whichField
))
909 editSField(GeometryInputTypeFieldMask
);
910 _sfGeometryInputType
.copyFromBin(pMem
);
912 if(FieldBits::NoField
!= (GeometryOutputTypeFieldMask
& whichField
))
914 editSField(GeometryOutputTypeFieldMask
);
915 _sfGeometryOutputType
.copyFromBin(pMem
);
919 //! create a new instance of the class
920 ShaderProgramChunkTransitPtr
ShaderProgramChunkBase::createLocal(BitVector bFlags
)
922 ShaderProgramChunkTransitPtr fc
;
924 if(getClassType().getPrototype() != NULL
)
926 FieldContainerTransitPtr tmpPtr
=
927 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
929 fc
= dynamic_pointer_cast
<ShaderProgramChunk
>(tmpPtr
);
935 //! create a new instance of the class, copy the container flags
936 ShaderProgramChunkTransitPtr
ShaderProgramChunkBase::createDependent(BitVector bFlags
)
938 ShaderProgramChunkTransitPtr fc
;
940 if(getClassType().getPrototype() != NULL
)
942 FieldContainerTransitPtr tmpPtr
=
943 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
945 fc
= dynamic_pointer_cast
<ShaderProgramChunk
>(tmpPtr
);
951 //! create a new instance of the class
952 ShaderProgramChunkTransitPtr
ShaderProgramChunkBase::create(void)
954 ShaderProgramChunkTransitPtr fc
;
956 if(getClassType().getPrototype() != NULL
)
958 FieldContainerTransitPtr tmpPtr
=
959 getClassType().getPrototype()-> shallowCopy();
961 fc
= dynamic_pointer_cast
<ShaderProgramChunk
>(tmpPtr
);
967 ShaderProgramChunk
*ShaderProgramChunkBase::createEmptyLocal(BitVector bFlags
)
969 ShaderProgramChunk
*returnValue
;
971 newPtr
<ShaderProgramChunk
>(returnValue
, bFlags
);
973 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
978 //! create an empty new instance of the class, do not copy the prototype
979 ShaderProgramChunk
*ShaderProgramChunkBase::createEmpty(void)
981 ShaderProgramChunk
*returnValue
;
983 newPtr
<ShaderProgramChunk
>(returnValue
, Thread::getCurrentLocalFlags());
985 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
986 ~Thread::getCurrentLocalFlags();
992 FieldContainerTransitPtr
ShaderProgramChunkBase::shallowCopyLocal(
993 BitVector bFlags
) const
995 ShaderProgramChunk
*tmpPtr
;
997 newPtr(tmpPtr
, dynamic_cast<const ShaderProgramChunk
*>(this), bFlags
);
999 FieldContainerTransitPtr
returnValue(tmpPtr
);
1001 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
1006 FieldContainerTransitPtr
ShaderProgramChunkBase::shallowCopyDependent(
1007 BitVector bFlags
) const
1009 ShaderProgramChunk
*tmpPtr
;
1011 newPtr(tmpPtr
, dynamic_cast<const ShaderProgramChunk
*>(this), ~bFlags
);
1013 FieldContainerTransitPtr
returnValue(tmpPtr
);
1015 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
1020 FieldContainerTransitPtr
ShaderProgramChunkBase::shallowCopy(void) const
1022 ShaderProgramChunk
*tmpPtr
;
1025 dynamic_cast<const ShaderProgramChunk
*>(this),
1026 Thread::getCurrentLocalFlags());
1028 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
1030 FieldContainerTransitPtr
returnValue(tmpPtr
);
1038 /*------------------------- constructors ----------------------------------*/
1040 ShaderProgramChunkBase::ShaderProgramChunkBase(void) :
1043 _mfTessControlShader (),
1044 _mfTessEvaluationShader (),
1045 _mfGeometryShader (),
1046 _mfFragmentShader (),
1047 _sfGeometryVerticesOut (UInt32(0)),
1048 _sfGeometryInputType (GLenum(GL_TRIANGLES
)),
1049 _sfGeometryOutputType (GLenum(GL_TRIANGLE_STRIP
))
1053 ShaderProgramChunkBase::ShaderProgramChunkBase(const ShaderProgramChunkBase
&source
) :
1056 _mfTessControlShader (),
1057 _mfTessEvaluationShader (),
1058 _mfGeometryShader (),
1059 _mfFragmentShader (),
1060 _sfGeometryVerticesOut (source
._sfGeometryVerticesOut
),
1061 _sfGeometryInputType (source
._sfGeometryInputType
),
1062 _sfGeometryOutputType (source
._sfGeometryOutputType
)
1067 /*-------------------------- destructors ----------------------------------*/
1069 ShaderProgramChunkBase::~ShaderProgramChunkBase(void)
1073 void ShaderProgramChunkBase::onCreate(const ShaderProgramChunk
*source
)
1075 Inherited::onCreate(source
);
1079 ShaderProgramChunk
*pThis
= static_cast<ShaderProgramChunk
*>(this);
1081 MFUnrecShaderProgramPtr::const_iterator VertexShaderIt
=
1082 source
->_mfVertexShader
.begin();
1083 MFUnrecShaderProgramPtr::const_iterator VertexShaderEnd
=
1084 source
->_mfVertexShader
.end ();
1086 while(VertexShaderIt
!= VertexShaderEnd
)
1088 pThis
->addVertexShader(*VertexShaderIt
);
1093 MFUnrecShaderProgramPtr::const_iterator TessControlShaderIt
=
1094 source
->_mfTessControlShader
.begin();
1095 MFUnrecShaderProgramPtr::const_iterator TessControlShaderEnd
=
1096 source
->_mfTessControlShader
.end ();
1098 while(TessControlShaderIt
!= TessControlShaderEnd
)
1100 pThis
->addTessControlShader(*TessControlShaderIt
);
1102 ++TessControlShaderIt
;
1105 MFUnrecShaderProgramPtr::const_iterator TessEvaluationShaderIt
=
1106 source
->_mfTessEvaluationShader
.begin();
1107 MFUnrecShaderProgramPtr::const_iterator TessEvaluationShaderEnd
=
1108 source
->_mfTessEvaluationShader
.end ();
1110 while(TessEvaluationShaderIt
!= TessEvaluationShaderEnd
)
1112 pThis
->addTessEvaluationShader(*TessEvaluationShaderIt
);
1114 ++TessEvaluationShaderIt
;
1117 MFUnrecShaderProgramPtr::const_iterator GeometryShaderIt
=
1118 source
->_mfGeometryShader
.begin();
1119 MFUnrecShaderProgramPtr::const_iterator GeometryShaderEnd
=
1120 source
->_mfGeometryShader
.end ();
1122 while(GeometryShaderIt
!= GeometryShaderEnd
)
1124 pThis
->addGeometryShader(*GeometryShaderIt
);
1129 MFUnrecShaderProgramPtr::const_iterator FragmentShaderIt
=
1130 source
->_mfFragmentShader
.begin();
1131 MFUnrecShaderProgramPtr::const_iterator FragmentShaderEnd
=
1132 source
->_mfFragmentShader
.end ();
1134 while(FragmentShaderIt
!= FragmentShaderEnd
)
1136 pThis
->addFragmentShader(*FragmentShaderIt
);
1143 GetFieldHandlePtr
ShaderProgramChunkBase::getHandleVertexShader (void) const
1145 MFUnrecShaderProgramPtr::GetHandlePtr
returnValue(
1146 new MFUnrecShaderProgramPtr::GetHandle(
1148 this->getType().getFieldDesc(VertexShaderFieldId
),
1149 const_cast<ShaderProgramChunkBase
*>(this)));
1154 EditFieldHandlePtr
ShaderProgramChunkBase::editHandleVertexShader (void)
1156 MFUnrecShaderProgramPtr::EditHandlePtr
returnValue(
1157 new MFUnrecShaderProgramPtr::EditHandle(
1159 this->getType().getFieldDesc(VertexShaderFieldId
),
1162 returnValue
->setAddMethod(
1163 boost::bind(&ShaderProgramChunk::addVertexShader
,
1164 static_cast<ShaderProgramChunk
*>(this), _1
));
1165 returnValue
->setRemoveMethod(
1166 boost::bind(&ShaderProgramChunk::subVertexShader
,
1167 static_cast<ShaderProgramChunk
*>(this), _1
));
1168 returnValue
->setRemoveObjMethod(
1169 boost::bind(&ShaderProgramChunk::removeObjFromVertexShader
,
1170 static_cast<ShaderProgramChunk
*>(this), _1
));
1171 returnValue
->setClearMethod(
1172 boost::bind(&ShaderProgramChunk::clearVertexShaders
,
1173 static_cast<ShaderProgramChunk
*>(this)));
1175 editMField(VertexShaderFieldMask
, _mfVertexShader
);
1180 GetFieldHandlePtr
ShaderProgramChunkBase::getHandleTessControlShader (void) const
1182 MFUnrecShaderProgramPtr::GetHandlePtr
returnValue(
1183 new MFUnrecShaderProgramPtr::GetHandle(
1184 &_mfTessControlShader
,
1185 this->getType().getFieldDesc(TessControlShaderFieldId
),
1186 const_cast<ShaderProgramChunkBase
*>(this)));
1191 EditFieldHandlePtr
ShaderProgramChunkBase::editHandleTessControlShader(void)
1193 MFUnrecShaderProgramPtr::EditHandlePtr
returnValue(
1194 new MFUnrecShaderProgramPtr::EditHandle(
1195 &_mfTessControlShader
,
1196 this->getType().getFieldDesc(TessControlShaderFieldId
),
1199 returnValue
->setAddMethod(
1200 boost::bind(&ShaderProgramChunk::addTessControlShader
,
1201 static_cast<ShaderProgramChunk
*>(this), _1
));
1202 returnValue
->setRemoveMethod(
1203 boost::bind(&ShaderProgramChunk::subTessControlShader
,
1204 static_cast<ShaderProgramChunk
*>(this), _1
));
1205 returnValue
->setRemoveObjMethod(
1206 boost::bind(&ShaderProgramChunk::removeObjFromTessControlShader
,
1207 static_cast<ShaderProgramChunk
*>(this), _1
));
1208 returnValue
->setClearMethod(
1209 boost::bind(&ShaderProgramChunk::clearTessControlShaders
,
1210 static_cast<ShaderProgramChunk
*>(this)));
1212 editMField(TessControlShaderFieldMask
, _mfTessControlShader
);
1217 GetFieldHandlePtr
ShaderProgramChunkBase::getHandleTessEvaluationShader (void) const
1219 MFUnrecShaderProgramPtr::GetHandlePtr
returnValue(
1220 new MFUnrecShaderProgramPtr::GetHandle(
1221 &_mfTessEvaluationShader
,
1222 this->getType().getFieldDesc(TessEvaluationShaderFieldId
),
1223 const_cast<ShaderProgramChunkBase
*>(this)));
1228 EditFieldHandlePtr
ShaderProgramChunkBase::editHandleTessEvaluationShader(void)
1230 MFUnrecShaderProgramPtr::EditHandlePtr
returnValue(
1231 new MFUnrecShaderProgramPtr::EditHandle(
1232 &_mfTessEvaluationShader
,
1233 this->getType().getFieldDesc(TessEvaluationShaderFieldId
),
1236 returnValue
->setAddMethod(
1237 boost::bind(&ShaderProgramChunk::addTessEvaluationShader
,
1238 static_cast<ShaderProgramChunk
*>(this), _1
));
1239 returnValue
->setRemoveMethod(
1240 boost::bind(&ShaderProgramChunk::subTessEvaluationShader
,
1241 static_cast<ShaderProgramChunk
*>(this), _1
));
1242 returnValue
->setRemoveObjMethod(
1243 boost::bind(&ShaderProgramChunk::removeObjFromTessEvaluationShader
,
1244 static_cast<ShaderProgramChunk
*>(this), _1
));
1245 returnValue
->setClearMethod(
1246 boost::bind(&ShaderProgramChunk::clearTessEvaluationShaders
,
1247 static_cast<ShaderProgramChunk
*>(this)));
1249 editMField(TessEvaluationShaderFieldMask
, _mfTessEvaluationShader
);
1254 GetFieldHandlePtr
ShaderProgramChunkBase::getHandleGeometryShader (void) const
1256 MFUnrecShaderProgramPtr::GetHandlePtr
returnValue(
1257 new MFUnrecShaderProgramPtr::GetHandle(
1259 this->getType().getFieldDesc(GeometryShaderFieldId
),
1260 const_cast<ShaderProgramChunkBase
*>(this)));
1265 EditFieldHandlePtr
ShaderProgramChunkBase::editHandleGeometryShader (void)
1267 MFUnrecShaderProgramPtr::EditHandlePtr
returnValue(
1268 new MFUnrecShaderProgramPtr::EditHandle(
1270 this->getType().getFieldDesc(GeometryShaderFieldId
),
1273 returnValue
->setAddMethod(
1274 boost::bind(&ShaderProgramChunk::addGeometryShader
,
1275 static_cast<ShaderProgramChunk
*>(this), _1
));
1276 returnValue
->setRemoveMethod(
1277 boost::bind(&ShaderProgramChunk::subGeometryShader
,
1278 static_cast<ShaderProgramChunk
*>(this), _1
));
1279 returnValue
->setRemoveObjMethod(
1280 boost::bind(&ShaderProgramChunk::removeObjFromGeometryShader
,
1281 static_cast<ShaderProgramChunk
*>(this), _1
));
1282 returnValue
->setClearMethod(
1283 boost::bind(&ShaderProgramChunk::clearGeometryShaders
,
1284 static_cast<ShaderProgramChunk
*>(this)));
1286 editMField(GeometryShaderFieldMask
, _mfGeometryShader
);
1291 GetFieldHandlePtr
ShaderProgramChunkBase::getHandleFragmentShader (void) const
1293 MFUnrecShaderProgramPtr::GetHandlePtr
returnValue(
1294 new MFUnrecShaderProgramPtr::GetHandle(
1296 this->getType().getFieldDesc(FragmentShaderFieldId
),
1297 const_cast<ShaderProgramChunkBase
*>(this)));
1302 EditFieldHandlePtr
ShaderProgramChunkBase::editHandleFragmentShader (void)
1304 MFUnrecShaderProgramPtr::EditHandlePtr
returnValue(
1305 new MFUnrecShaderProgramPtr::EditHandle(
1307 this->getType().getFieldDesc(FragmentShaderFieldId
),
1310 returnValue
->setAddMethod(
1311 boost::bind(&ShaderProgramChunk::addFragmentShader
,
1312 static_cast<ShaderProgramChunk
*>(this), _1
));
1313 returnValue
->setRemoveMethod(
1314 boost::bind(&ShaderProgramChunk::subFragmentShader
,
1315 static_cast<ShaderProgramChunk
*>(this), _1
));
1316 returnValue
->setRemoveObjMethod(
1317 boost::bind(&ShaderProgramChunk::removeObjFromFragmentShader
,
1318 static_cast<ShaderProgramChunk
*>(this), _1
));
1319 returnValue
->setClearMethod(
1320 boost::bind(&ShaderProgramChunk::clearFragmentShaders
,
1321 static_cast<ShaderProgramChunk
*>(this)));
1323 editMField(FragmentShaderFieldMask
, _mfFragmentShader
);
1328 GetFieldHandlePtr
ShaderProgramChunkBase::getHandleGeometryVerticesOut (void) const
1330 SFUInt32::GetHandlePtr
returnValue(
1331 new SFUInt32::GetHandle(
1332 &_sfGeometryVerticesOut
,
1333 this->getType().getFieldDesc(GeometryVerticesOutFieldId
),
1334 const_cast<ShaderProgramChunkBase
*>(this)));
1339 EditFieldHandlePtr
ShaderProgramChunkBase::editHandleGeometryVerticesOut(void)
1341 SFUInt32::EditHandlePtr
returnValue(
1342 new SFUInt32::EditHandle(
1343 &_sfGeometryVerticesOut
,
1344 this->getType().getFieldDesc(GeometryVerticesOutFieldId
),
1348 editSField(GeometryVerticesOutFieldMask
);
1353 GetFieldHandlePtr
ShaderProgramChunkBase::getHandleGeometryInputType (void) const
1355 SFGLenum::GetHandlePtr
returnValue(
1356 new SFGLenum::GetHandle(
1357 &_sfGeometryInputType
,
1358 this->getType().getFieldDesc(GeometryInputTypeFieldId
),
1359 const_cast<ShaderProgramChunkBase
*>(this)));
1364 EditFieldHandlePtr
ShaderProgramChunkBase::editHandleGeometryInputType(void)
1366 SFGLenum::EditHandlePtr
returnValue(
1367 new SFGLenum::EditHandle(
1368 &_sfGeometryInputType
,
1369 this->getType().getFieldDesc(GeometryInputTypeFieldId
),
1373 editSField(GeometryInputTypeFieldMask
);
1378 GetFieldHandlePtr
ShaderProgramChunkBase::getHandleGeometryOutputType (void) const
1380 SFGLenum::GetHandlePtr
returnValue(
1381 new SFGLenum::GetHandle(
1382 &_sfGeometryOutputType
,
1383 this->getType().getFieldDesc(GeometryOutputTypeFieldId
),
1384 const_cast<ShaderProgramChunkBase
*>(this)));
1389 EditFieldHandlePtr
ShaderProgramChunkBase::editHandleGeometryOutputType(void)
1391 SFGLenum::EditHandlePtr
returnValue(
1392 new SFGLenum::EditHandle(
1393 &_sfGeometryOutputType
,
1394 this->getType().getFieldDesc(GeometryOutputTypeFieldId
),
1398 editSField(GeometryOutputTypeFieldMask
);
1404 #ifdef OSG_MT_CPTR_ASPECT
1405 void ShaderProgramChunkBase::execSyncV( FieldContainer
&oFrom
,
1406 ConstFieldMaskArg whichField
,
1407 AspectOffsetStore
&oOffsets
,
1408 ConstFieldMaskArg syncMode
,
1409 const UInt32 uiSyncInfo
)
1411 ShaderProgramChunk
*pThis
= static_cast<ShaderProgramChunk
*>(this);
1413 pThis
->execSync(static_cast<ShaderProgramChunk
*>(&oFrom
),
1422 #ifdef OSG_MT_CPTR_ASPECT
1423 FieldContainer
*ShaderProgramChunkBase::createAspectCopy(
1424 const FieldContainer
*pRefAspect
) const
1426 ShaderProgramChunk
*returnValue
;
1428 newAspectCopy(returnValue
,
1429 dynamic_cast<const ShaderProgramChunk
*>(pRefAspect
),
1430 dynamic_cast<const ShaderProgramChunk
*>(this));
1436 void ShaderProgramChunkBase::resolveLinks(void)
1438 Inherited::resolveLinks();
1440 static_cast<ShaderProgramChunk
*>(this)->clearVertexShaders();
1442 static_cast<ShaderProgramChunk
*>(this)->clearTessControlShaders();
1444 static_cast<ShaderProgramChunk
*>(this)->clearTessEvaluationShaders();
1446 static_cast<ShaderProgramChunk
*>(this)->clearGeometryShaders();
1448 static_cast<ShaderProgramChunk
*>(this)->clearFragmentShaders();