fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Shader / Base / OSGShaderProgramBase.h
blobe66a83ba9ccd276e0caccb30a4e7391ea4a59f98
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 ShaderProgram
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
54 #ifndef _OSGSHADERPROGRAMBASE_H_
55 #define _OSGSHADERPROGRAMBASE_H_
56 #ifdef __sgi
57 #pragma once
58 #endif
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"
78 OSG_BEGIN_NAMESPACE
81 class ShaderProgram;
83 //! \brief ShaderProgram Base Class.
85 class OSG_SYSTEM_DLLMAPPING ShaderProgramBase : public FieldContainer
87 public:
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 =================================*/
99 public:
101 enum
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 */
160 /*! \{ */
162 static FieldContainerType &getClassType (void);
163 static UInt32 getClassTypeId (void);
164 static UInt16 getClassGroupId(void);
166 /*! \} */
167 /*---------------------------------------------------------------------*/
168 /*! \name FieldContainer Get */
169 /*! \{ */
171 virtual FieldContainerType &getType (void);
172 virtual const FieldContainerType &getType (void) const;
174 virtual UInt32 getContainerSize(void) const;
176 /*! \} */
177 /*---------------------------------------------------------------------*/
178 /*! \name Field Get */
179 /*! \{ */
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;
241 /*! \} */
242 /*---------------------------------------------------------------------*/
243 /*! \name Field Set */
244 /*! \{ */
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);
254 /*! \} */
255 /*---------------------------------------------------------------------*/
256 /*! \name Ptr Field Set */
257 /*! \{ */
259 /*! \} */
260 /*---------------------------------------------------------------------*/
261 /*! \name Ptr MField Set */
262 /*! \{ */
264 /*! \} */
265 /*---------------------------------------------------------------------*/
266 /*! \name Binary Access */
267 /*! \{ */
269 virtual SizeT getBinSize (ConstFieldMaskArg whichField);
270 virtual void copyToBin (BinaryDataHandler &pMem,
271 ConstFieldMaskArg whichField);
272 virtual void copyFromBin(BinaryDataHandler &pMem,
273 ConstFieldMaskArg whichField);
276 /*! \} */
277 /*---------------------------------------------------------------------*/
278 /*! \name Construction */
279 /*! \{ */
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);
292 /*! \} */
293 /*---------------------------------------------------------------------*/
294 /*! \name Copy */
295 /*! \{ */
297 virtual FieldContainerTransitPtr shallowCopy (void) const;
298 virtual FieldContainerTransitPtr shallowCopyLocal(
299 BitVector bFlags = FCLocal::All) const;
300 virtual FieldContainerTransitPtr shallowCopyDependent(
301 BitVector bFlags) const;
303 /*! \} */
304 /*========================= PROTECTED ===============================*/
306 protected:
308 static TypeObject _type;
310 static void classDescInserter(TypeObject &oType);
311 static const Char8 *getClassname (void );
313 /*---------------------------------------------------------------------*/
314 /*! \name Fields */
315 /*! \{ */
317 SFGLenum _sfShaderType;
318 SFString _sfProgram;
319 SFString _sfDefines;
320 SFUInt32 _sfGLId;
321 SFUnrecChildShaderProgramVariablesPtr _sfVariables;
322 MFString _mfFeedbackVaryings;
323 MFShaderParameter _mfParameter;
324 MFShaderAttribute _mfAttributes;
325 SFBool _sfCgFrontEnd;
326 SFBool _sfPointSize;
327 MFParentFieldContainerPtr _mfParents;
328 MFChangedFunctorCallback _mfDestroyedFunctors;
330 /*! \} */
331 /*---------------------------------------------------------------------*/
332 /*! \name Constructors */
333 /*! \{ */
335 ShaderProgramBase(void);
336 ShaderProgramBase(const ShaderProgramBase &source);
338 /*! \} */
339 /*---------------------------------------------------------------------*/
340 /*! \name Destructors */
341 /*! \{ */
343 virtual ~ShaderProgramBase(void);
345 /*! \} */
346 /*---------------------------------------------------------------------*/
347 /*! \name onCreate */
348 /*! \{ */
350 void onCreate(const ShaderProgram *source = NULL);
352 /*! \} */
353 /*---------------------------------------------------------------------*/
354 /*! \name Parent linking */
355 /*! \{ */
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);
363 /*! \} */
364 /*---------------------------------------------------------------------*/
365 /*! \name Child linking */
366 /*! \{ */
368 virtual bool unlinkChild(FieldContainer * const pChild,
369 UInt16 const childFieldId);
371 /*! \} */
372 /*---------------------------------------------------------------------*/
373 /*! \name Generic Field Access */
374 /*! \{ */
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);
401 /*! \} */
402 /*---------------------------------------------------------------------*/
403 /*! \name Sync */
404 /*! \{ */
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);
418 #endif
420 /*! \} */
421 /*---------------------------------------------------------------------*/
422 /*! \name Edit */
423 /*! \{ */
425 /*! \} */
426 /*---------------------------------------------------------------------*/
427 /*! \name Aspect Create */
428 /*! \{ */
430 #ifdef OSG_MT_CPTR_ASPECT
431 virtual FieldContainer *createAspectCopy(
432 const FieldContainer *pRefAspect) const;
433 #endif
435 /*! \} */
436 /*---------------------------------------------------------------------*/
437 /*! \name Edit */
438 /*! \{ */
439 /*! \} */
440 /*---------------------------------------------------------------------*/
441 /*! \name Sync */
442 /*! \{ */
444 virtual void resolveLinks(void);
446 /*! \} */
447 /*========================== PRIVATE ================================*/
449 private:
450 /*---------------------------------------------------------------------*/
452 // prohibit default functions (move to 'public' if you need one)
453 void operator =(const ShaderProgramBase &source);
456 typedef ShaderProgramBase *ShaderProgramBaseP;
458 OSG_END_NAMESPACE
460 #endif /* _OSGSHADERPROGRAMBASE_H_ */