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 \*****************************************************************************/
54 #ifndef _OSGSHADERPROGRAMBASE_H_
55 #define _OSGSHADERPROGRAMBASE_H_
61 #include "OSGConfig.h"
62 #include "OSGSystemDef.h"
64 //#include "OSGBaseTypes.h"
66 #include "OSGFieldContainer.h" // Parent
68 #include "OSGBaseFields.h" // ShaderType type
69 #include "OSGSysFields.h" // GLId type
70 #include "OSGShaderProgramVariablesFields.h" // Variables type
71 #include "OSGShaderParameterFields.h" // Parameter type
72 #include "OSGShaderAttributeFields.h" // Attributes type
73 #include "OSGFieldContainerFields.h" // Parents type
74 #include "OSGChangedFunctorCallbackFields.h" // DestroyedFunctors type
76 #include "OSGShaderProgramFields.h"
83 //! \brief ShaderProgram Base Class.
85 class OSG_SYSTEM_DLLMAPPING ShaderProgramBase
: public FieldContainer
89 typedef FieldContainer Inherited
;
90 typedef FieldContainer ParentContainer
;
92 typedef Inherited::TypeObject TypeObject
;
93 typedef TypeObject::InitPhase InitPhase
;
95 OSG_GEN_INTERNALPTR(ShaderProgram
);
97 /*========================== PUBLIC =================================*/
103 ShaderTypeFieldId
= Inherited::NextFieldId
,
104 ProgramFieldId
= ShaderTypeFieldId
+ 1,
105 DefinesFieldId
= ProgramFieldId
+ 1,
106 GLIdFieldId
= DefinesFieldId
+ 1,
107 VariablesFieldId
= GLIdFieldId
+ 1,
108 FeedbackVaryingsFieldId
= VariablesFieldId
+ 1,
109 ParameterFieldId
= FeedbackVaryingsFieldId
+ 1,
110 AttributesFieldId
= ParameterFieldId
+ 1,
111 CgFrontEndFieldId
= AttributesFieldId
+ 1,
112 PointSizeFieldId
= CgFrontEndFieldId
+ 1,
113 ParentsFieldId
= PointSizeFieldId
+ 1,
114 DestroyedFunctorsFieldId
= ParentsFieldId
+ 1,
115 NextFieldId
= DestroyedFunctorsFieldId
+ 1
118 static const OSG::BitVector ShaderTypeFieldMask
=
119 (TypeTraits
<BitVector
>::One
<< ShaderTypeFieldId
);
120 static const OSG::BitVector ProgramFieldMask
=
121 (TypeTraits
<BitVector
>::One
<< ProgramFieldId
);
122 static const OSG::BitVector DefinesFieldMask
=
123 (TypeTraits
<BitVector
>::One
<< DefinesFieldId
);
124 static const OSG::BitVector GLIdFieldMask
=
125 (TypeTraits
<BitVector
>::One
<< GLIdFieldId
);
126 static const OSG::BitVector VariablesFieldMask
=
127 (TypeTraits
<BitVector
>::One
<< VariablesFieldId
);
128 static const OSG::BitVector FeedbackVaryingsFieldMask
=
129 (TypeTraits
<BitVector
>::One
<< FeedbackVaryingsFieldId
);
130 static const OSG::BitVector ParameterFieldMask
=
131 (TypeTraits
<BitVector
>::One
<< ParameterFieldId
);
132 static const OSG::BitVector AttributesFieldMask
=
133 (TypeTraits
<BitVector
>::One
<< AttributesFieldId
);
134 static const OSG::BitVector CgFrontEndFieldMask
=
135 (TypeTraits
<BitVector
>::One
<< CgFrontEndFieldId
);
136 static const OSG::BitVector PointSizeFieldMask
=
137 (TypeTraits
<BitVector
>::One
<< PointSizeFieldId
);
138 static const OSG::BitVector ParentsFieldMask
=
139 (TypeTraits
<BitVector
>::One
<< ParentsFieldId
);
140 static const OSG::BitVector DestroyedFunctorsFieldMask
=
141 (TypeTraits
<BitVector
>::One
<< DestroyedFunctorsFieldId
);
142 static const OSG::BitVector NextFieldMask
=
143 (TypeTraits
<BitVector
>::One
<< NextFieldId
);
145 typedef SFGLenum SFShaderTypeType
;
146 typedef SFString SFProgramType
;
147 typedef SFString SFDefinesType
;
148 typedef SFUInt32 SFGLIdType
;
149 typedef SFUnrecChildShaderProgramVariablesPtr SFVariablesType
;
150 typedef MFString MFFeedbackVaryingsType
;
151 typedef MFShaderParameter MFParameterType
;
152 typedef MFShaderAttribute MFAttributesType
;
153 typedef SFBool SFCgFrontEndType
;
154 typedef SFBool SFPointSizeType
;
155 typedef MFParentFieldContainerPtr MFParentsType
;
156 typedef MFChangedFunctorCallback MFDestroyedFunctorsType
;
158 /*---------------------------------------------------------------------*/
159 /*! \name Class Get */
162 static FieldContainerType
&getClassType (void);
163 static UInt32
getClassTypeId (void);
164 static UInt16
getClassGroupId(void);
167 /*---------------------------------------------------------------------*/
168 /*! \name FieldContainer Get */
171 virtual FieldContainerType
&getType (void);
172 virtual const FieldContainerType
&getType (void) const;
174 virtual UInt32
getContainerSize(void) const;
177 /*---------------------------------------------------------------------*/
178 /*! \name Field Get */
182 SFGLenum
*editSFShaderType (void);
183 const SFGLenum
*getSFShaderType (void) const;
185 SFString
*editSFProgram (void);
186 const SFString
*getSFProgram (void) const;
188 SFString
*editSFDefines (void);
189 const SFString
*getSFDefines (void) const;
191 SFUInt32
*editSFGLId (void);
192 const SFUInt32
*getSFGLId (void) const;
193 const SFUnrecChildShaderProgramVariablesPtr
*getSFVariables (void) const;
194 SFUnrecChildShaderProgramVariablesPtr
*editSFVariables (void);
196 MFString
*editMFFeedbackVaryings(void);
197 const MFString
*getMFFeedbackVaryings (void) const;
199 MFShaderParameter
*editMFParameter (void);
200 const MFShaderParameter
*getMFParameter (void) const;
202 MFShaderAttribute
*editMFAttributes (void);
203 const MFShaderAttribute
*getMFAttributes (void) const;
205 SFBool
*editSFCgFrontEnd (void);
206 const SFBool
*getSFCgFrontEnd (void) const;
208 SFBool
*editSFPointSize (void);
209 const SFBool
*getSFPointSize (void) const;
212 GLenum
&editShaderType (void);
213 const GLenum
&getShaderType (void) const;
215 std::string
&editProgram (void);
216 const std::string
&getProgram (void) const;
218 std::string
&editDefines (void);
219 const std::string
&getDefines (void) const;
221 UInt32
&editGLId (void);
222 UInt32
getGLId (void) const;
224 ShaderProgramVariables
* getVariables (void) const;
226 MFString ::reference
editFeedbackVaryings(const UInt32 index
);
227 const std::string
&getFeedbackVaryings (const UInt32 index
) const;
229 MFShaderParameter ::reference
editParameter (const UInt32 index
);
230 const ShaderParameter
&getParameter (const UInt32 index
) const;
232 MFShaderAttribute ::reference
editAttributes (const UInt32 index
);
233 const ShaderAttribute
&getAttributes (const UInt32 index
) const;
235 bool &editCgFrontEnd (void);
236 bool getCgFrontEnd (void) const;
238 bool &editPointSize (void);
239 bool getPointSize (void) const;
242 /*---------------------------------------------------------------------*/
243 /*! \name Field Set */
246 void setShaderType (const GLenum
&value
);
247 void setProgram (const std::string
&value
);
248 void setDefines (const std::string
&value
);
249 void setGLId (const UInt32 value
);
250 void setVariables (ShaderProgramVariables
* const value
);
251 void setCgFrontEnd (const bool value
);
252 void setPointSize (const bool value
);
255 /*---------------------------------------------------------------------*/
256 /*! \name Ptr Field Set */
260 /*---------------------------------------------------------------------*/
261 /*! \name Ptr MField Set */
265 /*---------------------------------------------------------------------*/
266 /*! \name Binary Access */
269 virtual SizeT
getBinSize (ConstFieldMaskArg whichField
);
270 virtual void copyToBin (BinaryDataHandler
&pMem
,
271 ConstFieldMaskArg whichField
);
272 virtual void copyFromBin(BinaryDataHandler
&pMem
,
273 ConstFieldMaskArg whichField
);
277 /*---------------------------------------------------------------------*/
278 /*! \name Construction */
281 static ShaderProgramTransitPtr
create (void);
282 static ShaderProgram
*createEmpty (void);
284 static ShaderProgramTransitPtr
createLocal (
285 BitVector bFlags
= FCLocal::All
);
287 static ShaderProgram
*createEmptyLocal(
288 BitVector bFlags
= FCLocal::All
);
290 static ShaderProgramTransitPtr
createDependent (BitVector bFlags
);
293 /*---------------------------------------------------------------------*/
297 virtual FieldContainerTransitPtr
shallowCopy (void) const;
298 virtual FieldContainerTransitPtr
shallowCopyLocal(
299 BitVector bFlags
= FCLocal::All
) const;
300 virtual FieldContainerTransitPtr
shallowCopyDependent(
301 BitVector bFlags
) const;
304 /*========================= PROTECTED ===============================*/
308 static TypeObject _type
;
310 static void classDescInserter(TypeObject
&oType
);
311 static const Char8
*getClassname (void );
313 /*---------------------------------------------------------------------*/
317 SFGLenum _sfShaderType
;
321 SFUnrecChildShaderProgramVariablesPtr _sfVariables
;
322 MFString _mfFeedbackVaryings
;
323 MFShaderParameter _mfParameter
;
324 MFShaderAttribute _mfAttributes
;
325 SFBool _sfCgFrontEnd
;
327 MFParentFieldContainerPtr _mfParents
;
328 MFChangedFunctorCallback _mfDestroyedFunctors
;
331 /*---------------------------------------------------------------------*/
332 /*! \name Constructors */
335 ShaderProgramBase(void);
336 ShaderProgramBase(const ShaderProgramBase
&source
);
339 /*---------------------------------------------------------------------*/
340 /*! \name Destructors */
343 virtual ~ShaderProgramBase(void);
346 /*---------------------------------------------------------------------*/
347 /*! \name onCreate */
350 void onCreate(const ShaderProgram
*source
= NULL
);
353 /*---------------------------------------------------------------------*/
354 /*! \name Parent linking */
357 virtual bool linkParent (FieldContainer
* const pParent
,
358 UInt16
const childFieldId
,
359 UInt16
const parentFieldId
);
360 virtual bool unlinkParent(FieldContainer
* const pParent
,
361 UInt16
const parentFieldId
);
364 /*---------------------------------------------------------------------*/
365 /*! \name Child linking */
368 virtual bool unlinkChild(FieldContainer
* const pChild
,
369 UInt16
const childFieldId
);
372 /*---------------------------------------------------------------------*/
373 /*! \name Generic Field Access */
376 GetFieldHandlePtr
getHandleShaderType (void) const;
377 EditFieldHandlePtr
editHandleShaderType (void);
378 GetFieldHandlePtr
getHandleProgram (void) const;
379 EditFieldHandlePtr
editHandleProgram (void);
380 GetFieldHandlePtr
getHandleDefines (void) const;
381 EditFieldHandlePtr
editHandleDefines (void);
382 GetFieldHandlePtr
getHandleGLId (void) const;
383 EditFieldHandlePtr
editHandleGLId (void);
384 GetFieldHandlePtr
getHandleVariables (void) const;
385 EditFieldHandlePtr
editHandleVariables (void);
386 GetFieldHandlePtr
getHandleFeedbackVaryings (void) const;
387 EditFieldHandlePtr
editHandleFeedbackVaryings(void);
388 GetFieldHandlePtr
getHandleParameter (void) const;
389 EditFieldHandlePtr
editHandleParameter (void);
390 GetFieldHandlePtr
getHandleAttributes (void) const;
391 EditFieldHandlePtr
editHandleAttributes (void);
392 GetFieldHandlePtr
getHandleCgFrontEnd (void) const;
393 EditFieldHandlePtr
editHandleCgFrontEnd (void);
394 GetFieldHandlePtr
getHandlePointSize (void) const;
395 EditFieldHandlePtr
editHandlePointSize (void);
396 GetFieldHandlePtr
getHandleParents (void) const;
397 EditFieldHandlePtr
editHandleParents (void);
398 GetFieldHandlePtr
getHandleDestroyedFunctors (void) const;
399 EditFieldHandlePtr
editHandleDestroyedFunctors(void);
402 /*---------------------------------------------------------------------*/
406 #ifdef OSG_MT_CPTR_ASPECT
407 virtual void execSyncV( FieldContainer
&oFrom
,
408 ConstFieldMaskArg whichField
,
409 AspectOffsetStore
&oOffsets
,
410 ConstFieldMaskArg syncMode
,
411 const UInt32 uiSyncInfo
);
413 void execSync ( ShaderProgramBase
*pFrom
,
414 ConstFieldMaskArg whichField
,
415 AspectOffsetStore
&oOffsets
,
416 ConstFieldMaskArg syncMode
,
417 const UInt32 uiSyncInfo
);
421 /*---------------------------------------------------------------------*/
426 /*---------------------------------------------------------------------*/
427 /*! \name Aspect Create */
430 #ifdef OSG_MT_CPTR_ASPECT
431 virtual FieldContainer
*createAspectCopy(
432 const FieldContainer
*pRefAspect
) const;
436 /*---------------------------------------------------------------------*/
440 /*---------------------------------------------------------------------*/
444 virtual void resolveLinks(void);
447 /*========================== PRIVATE ================================*/
450 /*---------------------------------------------------------------------*/
452 // prohibit default functions (move to 'public' if you need one)
453 void operator =(const ShaderProgramBase
&source
);
456 typedef ShaderProgramBase
*ShaderProgramBaseP
;
460 #endif /* _OSGSHADERPROGRAMBASE_H_ */