changed: gcc8 base update
[opensg.git] / Source / System / State / Base / OSGBlendChunkBase.cpp
blob2ca90b4f8bbbced0a2cc1005b93351f8cc1d9da9
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 BlendChunk!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #ifdef WIN32
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
59 #endif
61 #include "OSGConfig.h"
64 #include "OSGGL.h" // SrcFactor default header
65 #include "OSGGL.h" // DestFactor default header
66 #include "OSGGL.h" // Equation default header
67 #include "OSGGL.h" // AlphaFunc default header
70 #include "OSGBlendChunkBase.h"
71 #include "OSGBlendChunk.h"
73 #include <boost/bind.hpp>
75 OSG_BEGIN_NAMESPACE
77 /***************************************************************************\
78 * Description *
79 \***************************************************************************/
81 /*! \class OSG::BlendChunk
82 See \ref PageSystemBlendChunk for a description.
84 The blending chunk handles OpenGL blending, i.e. the definition how incoming pixel
85 are combined with the pixel already in the frame buffer.
87 This chunk wraps glBlendFunc() (OSG::BlendChunk::_sfSrcFactor,
88 OSG::BlendChunk::_sfDestFactor), glBlendEquation() or glBlendEquationEXT()
89 (whichever is supported) (OSG::BlendChunk::_sfEquation), glBlendColor()
90 (OSG::BlendChunk::_sfColor) and glAlphaFunc() (OSG::BlendChunk::_sfAlphaFunc,
91 OSG::BlendChunk::_sfAlphaValue) including glEnable(GL_ALPHA_TEST).
94 /***************************************************************************\
95 * Field Documentation *
96 \***************************************************************************/
98 /*! \var GLenum BlendChunkBase::_sfSrcFactor
99 The incoming pixel is multiplied by the source factor. Legal values are directly taken from the glBlendFunc() manpage.
102 /*! \var GLenum BlendChunkBase::_sfDestFactor
103 The frame buffer pixel is multiplied by the destination factor. Legal values are directly taken from the glBlendFunc() manpage.
106 /*! \var GLenum BlendChunkBase::_sfEquation
107 The equation used to combine the two values. Only available where GL_ARB_imaging is supported. See glBlendEquation() for details.
110 /*! \var Color4f BlendChunkBase::_sfColor
111 This is the constant color used by blend modes *_CONSTANT_*.
114 /*! \var GLenum BlendChunkBase::_sfAlphaFunc
115 The alphaFunc defines how fragments which do not fulfill a certain condition are handled.
116 See glAlphaFunc() for details. GL_NONE is used to disable alpha comparison.
119 /*! \var Real32 BlendChunkBase::_sfAlphaValue
120 The value used in alpha comparison.
123 /*! \var GLenum BlendChunkBase::_sfAlphaSrcFactor
124 The incoming alpha is multiplied by the source factor before being stored
125 in the frame buffer. Only available where GL_EXT_blend_func_separate is supported.
126 The default is GL_NONE, which indicates using the standard BlendFunction.
129 /*! \var GLenum BlendChunkBase::_sfAlphaDestFactor
130 The frame buffer alpha is multiplied by the source factor before being stored
131 in the frame buffer. Only available where GL_EXT_blend_func_separate is supported.
132 The default is GL_NONE, which indicates using the standard BlendFunction.
136 /***************************************************************************\
137 * FieldType/FieldTrait Instantiation *
138 \***************************************************************************/
140 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
141 PointerType FieldTraits<BlendChunk *, nsOSG>::_type(
142 "BlendChunkPtr",
143 "StateChunkPtr",
144 BlendChunk::getClassType(),
145 nsOSG);
146 #endif
148 OSG_FIELDTRAITS_GETTYPE_NS(BlendChunk *, nsOSG)
150 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
151 BlendChunk *,
152 nsOSG)
154 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
155 BlendChunk *,
156 nsOSG)
158 /***************************************************************************\
159 * Field Description *
160 \***************************************************************************/
162 void BlendChunkBase::classDescInserter(TypeObject &oType)
164 FieldDescriptionBase *pDesc = NULL;
167 pDesc = new SFGLenum::Description(
168 SFGLenum::getClassType(),
169 "srcFactor",
170 "The incoming pixel is multiplied by the source factor. Legal values are directly taken from the glBlendFunc() manpage.\n",
171 SrcFactorFieldId, SrcFactorFieldMask,
172 false,
173 (Field::SFDefaultFlags | Field::FStdAccess),
174 static_cast<FieldEditMethodSig>(&BlendChunk::editHandleSrcFactor),
175 static_cast<FieldGetMethodSig >(&BlendChunk::getHandleSrcFactor));
177 oType.addInitialDesc(pDesc);
179 pDesc = new SFGLenum::Description(
180 SFGLenum::getClassType(),
181 "destFactor",
182 "The frame buffer pixel is multiplied by the destination factor. Legal values are directly taken from the glBlendFunc() manpage.\n",
183 DestFactorFieldId, DestFactorFieldMask,
184 false,
185 (Field::SFDefaultFlags | Field::FStdAccess),
186 static_cast<FieldEditMethodSig>(&BlendChunk::editHandleDestFactor),
187 static_cast<FieldGetMethodSig >(&BlendChunk::getHandleDestFactor));
189 oType.addInitialDesc(pDesc);
191 pDesc = new SFGLenum::Description(
192 SFGLenum::getClassType(),
193 "equation",
194 "The equation used to combine the two values. Only available where GL_ARB_imaging is supported. See glBlendEquation() for details.\n",
195 EquationFieldId, EquationFieldMask,
196 false,
197 (Field::SFDefaultFlags | Field::FStdAccess),
198 static_cast<FieldEditMethodSig>(&BlendChunk::editHandleEquation),
199 static_cast<FieldGetMethodSig >(&BlendChunk::getHandleEquation));
201 oType.addInitialDesc(pDesc);
203 pDesc = new SFColor4f::Description(
204 SFColor4f::getClassType(),
205 "color",
206 "This is the constant color used by blend modes *_CONSTANT_*.\n",
207 ColorFieldId, ColorFieldMask,
208 false,
209 (Field::SFDefaultFlags | Field::FStdAccess),
210 static_cast<FieldEditMethodSig>(&BlendChunk::editHandleColor),
211 static_cast<FieldGetMethodSig >(&BlendChunk::getHandleColor));
213 oType.addInitialDesc(pDesc);
215 pDesc = new SFGLenum::Description(
216 SFGLenum::getClassType(),
217 "alphaFunc",
218 "The alphaFunc defines how fragments which do not fulfill a certain condition are handled. \n"
219 "See glAlphaFunc() for details. GL_NONE is used to disable alpha comparison.\n",
220 AlphaFuncFieldId, AlphaFuncFieldMask,
221 false,
222 (Field::SFDefaultFlags | Field::FStdAccess),
223 static_cast<FieldEditMethodSig>(&BlendChunk::editHandleAlphaFunc),
224 static_cast<FieldGetMethodSig >(&BlendChunk::getHandleAlphaFunc));
226 oType.addInitialDesc(pDesc);
228 pDesc = new SFReal32::Description(
229 SFReal32::getClassType(),
230 "alphaValue",
231 "The value used in alpha comparison.\n",
232 AlphaValueFieldId, AlphaValueFieldMask,
233 false,
234 (Field::SFDefaultFlags | Field::FStdAccess),
235 static_cast<FieldEditMethodSig>(&BlendChunk::editHandleAlphaValue),
236 static_cast<FieldGetMethodSig >(&BlendChunk::getHandleAlphaValue));
238 oType.addInitialDesc(pDesc);
240 pDesc = new SFGLenum::Description(
241 SFGLenum::getClassType(),
242 "alphaSrcFactor",
243 "The incoming alpha is multiplied by the source factor before being stored \n"
244 "in the frame buffer. Only available where GL_EXT_blend_func_separate is supported.\n"
245 "The default is GL_NONE, which indicates using the standard BlendFunction.\n",
246 AlphaSrcFactorFieldId, AlphaSrcFactorFieldMask,
247 false,
248 (Field::SFDefaultFlags | Field::FStdAccess),
249 static_cast<FieldEditMethodSig>(&BlendChunk::editHandleAlphaSrcFactor),
250 static_cast<FieldGetMethodSig >(&BlendChunk::getHandleAlphaSrcFactor));
252 oType.addInitialDesc(pDesc);
254 pDesc = new SFGLenum::Description(
255 SFGLenum::getClassType(),
256 "alphaDestFactor",
257 "The frame buffer alpha is multiplied by the source factor before being stored \n"
258 "in the frame buffer. Only available where GL_EXT_blend_func_separate is supported.\n"
259 "The default is GL_NONE, which indicates using the standard BlendFunction.\n",
260 AlphaDestFactorFieldId, AlphaDestFactorFieldMask,
261 false,
262 (Field::SFDefaultFlags | Field::FStdAccess),
263 static_cast<FieldEditMethodSig>(&BlendChunk::editHandleAlphaDestFactor),
264 static_cast<FieldGetMethodSig >(&BlendChunk::getHandleAlphaDestFactor));
266 oType.addInitialDesc(pDesc);
270 BlendChunkBase::TypeObject BlendChunkBase::_type(
271 BlendChunkBase::getClassname(),
272 Inherited::getClassname(),
273 "NULL",
274 nsOSG, //Namespace
275 reinterpret_cast<PrototypeCreateF>(&BlendChunkBase::createEmptyLocal),
276 reinterpret_cast<InitContainerF>(&BlendChunk::initMethod),
277 reinterpret_cast<ExitContainerF>(&BlendChunk::exitMethod),
278 reinterpret_cast<InitalInsertDescFunc>(
279 reinterpret_cast<void *>(&BlendChunk::classDescInserter)),
280 false,
282 "<?xml version=\"1.0\"?>\n"
283 "\n"
284 "<FieldContainer\n"
285 " name=\"BlendChunk\"\n"
286 " parent=\"StateChunk\"\n"
287 " library=\"System\"\n"
288 " pointerfieldtypes=\"both\"\n"
289 " structure=\"concrete\"\n"
290 " systemcomponent=\"true\"\n"
291 " parentsystemcomponent=\"true\"\n"
292 " docGroupBase=\"GrpSystemState\"\n"
293 " >\n"
294 "\n"
295 "See \\ref PageSystemBlendChunk for a description. \n"
296 "\n"
297 "The blending chunk handles OpenGL blending, i.e. the definition how incoming pixel\n"
298 "are combined with the pixel already in the frame buffer.\n"
299 "\n"
300 "This chunk wraps glBlendFunc() (OSG::BlendChunk::_sfSrcFactor,\n"
301 "OSG::BlendChunk::_sfDestFactor), glBlendEquation() or glBlendEquationEXT()\n"
302 "(whichever is supported) (OSG::BlendChunk::_sfEquation), glBlendColor() \n"
303 "(OSG::BlendChunk::_sfColor) and glAlphaFunc() (OSG::BlendChunk::_sfAlphaFunc,\n"
304 "OSG::BlendChunk::_sfAlphaValue) including glEnable(GL_ALPHA_TEST).\n"
305 "\t<Field\n"
306 "\t\tname=\"srcFactor\"\n"
307 "\t\ttype=\"GLenum\"\n"
308 "\t\tcardinality=\"single\"\n"
309 "\t\tvisibility=\"external\"\n"
310 "\t\tdefaultHeader=\"&quot;OSGGL.h&quot;\"\n"
311 "\t\tdefaultValue=\"GL_ONE\"\n"
312 "\t\taccess=\"public\"\n"
313 "\t>\n"
314 "\tThe incoming pixel is multiplied by the source factor. Legal values are directly taken from the glBlendFunc() manpage.\n"
315 "\t</Field>\n"
316 "\t<Field\n"
317 "\t\tname=\"destFactor\"\n"
318 "\t\ttype=\"GLenum\"\n"
319 "\t\tcardinality=\"single\"\n"
320 "\t\tvisibility=\"external\"\n"
321 "\t\tdefaultHeader=\"&quot;OSGGL.h&quot;\"\n"
322 "\t\tdefaultValue=\"GL_ZERO\"\n"
323 "\t\taccess=\"public\"\n"
324 "\t>\n"
325 "\tThe frame buffer pixel is multiplied by the destination factor. Legal values are directly taken from the glBlendFunc() manpage.\n"
326 "\t</Field>\n"
327 "\t<Field\n"
328 "\t\tname=\"equation\"\n"
329 "\t\ttype=\"GLenum\"\n"
330 "\t\tcardinality=\"single\"\n"
331 "\t\tvisibility=\"external\"\n"
332 "\t\tdefaultHeader=\"&quot;OSGGL.h&quot;\"\n"
333 "\t\tdefaultValue=\"GL_NONE\"\n"
334 "\t\taccess=\"public\"\n"
335 "\t>\n"
336 "\tThe equation used to combine the two values. Only available where GL_ARB_imaging is supported. See glBlendEquation() for details.\n"
337 "\t</Field>\n"
338 "\t<Field\n"
339 "\t\tname=\"color\"\n"
340 "\t\ttype=\"Color4f\"\n"
341 "\t\tcardinality=\"single\"\n"
342 "\t\tvisibility=\"external\"\n"
343 "\t\tdefaultValue=\"0,0,0,0\"\n"
344 "\t\taccess=\"public\"\n"
345 "\t>\n"
346 "\tThis is the constant color used by blend modes *_CONSTANT_*.\n"
347 "\t</Field>\n"
348 "\t<Field\n"
349 "\t\tname=\"alphaFunc\"\n"
350 "\t\ttype=\"GLenum\"\n"
351 "\t\tcardinality=\"single\"\n"
352 "\t\tvisibility=\"external\"\n"
353 "\t\tdefaultValue=\"GL_NONE\"\n"
354 "\t\tdefaultHeader=\"&quot;OSGGL.h&quot;\"\n"
355 "\t\taccess=\"public\"\n"
356 "\t>\n"
357 "\tThe alphaFunc defines how fragments which do not fulfill a certain condition are handled. \n"
358 " See glAlphaFunc() for details. GL_NONE is used to disable alpha comparison.\n"
359 "\t</Field>\n"
360 "\t<Field\n"
361 "\t\tname=\"alphaValue\"\n"
362 "\t\ttype=\"Real32\"\n"
363 "\t\tcardinality=\"single\"\n"
364 "\t\tvisibility=\"external\"\n"
365 "\t\tdefaultValue=\"0\"\n"
366 "\t\taccess=\"public\"\n"
367 "\t>\n"
368 " The value used in alpha comparison.\n"
369 "\t</Field>\n"
370 "\t<Field\n"
371 "\t\tname=\"alphaSrcFactor\"\n"
372 "\t\ttype=\"GLenum\"\n"
373 "\t\tcardinality=\"single\"\n"
374 "\t\tvisibility=\"external\"\n"
375 "\t\tdefaultValue=\"OSG_GL_UNUSED\"\n"
376 "\t\taccess=\"public\"\n"
377 "\t>\n"
378 "\tThe incoming alpha is multiplied by the source factor before being stored \n"
379 " in the frame buffer. Only available where GL_EXT_blend_func_separate is supported.\n"
380 " The default is GL_NONE, which indicates using the standard BlendFunction.\n"
381 "\t</Field>\n"
382 "\t<Field\n"
383 "\t\tname=\"alphaDestFactor\"\n"
384 "\t\ttype=\"GLenum\"\n"
385 "\t\tcardinality=\"single\"\n"
386 "\t\tvisibility=\"external\"\n"
387 "\t\tdefaultValue=\"OSG_GL_UNUSED\"\n"
388 "\t\taccess=\"public\"\n"
389 "\t>\n"
390 "\tThe frame buffer alpha is multiplied by the source factor before being stored \n"
391 " in the frame buffer. Only available where GL_EXT_blend_func_separate is supported.\n"
392 " The default is GL_NONE, which indicates using the standard BlendFunction.\n"
393 "\t</Field>\n"
394 "</FieldContainer>\n",
395 "See \\ref PageSystemBlendChunk for a description. \n"
396 "\n"
397 "The blending chunk handles OpenGL blending, i.e. the definition how incoming pixel\n"
398 "are combined with the pixel already in the frame buffer.\n"
399 "\n"
400 "This chunk wraps glBlendFunc() (OSG::BlendChunk::_sfSrcFactor,\n"
401 "OSG::BlendChunk::_sfDestFactor), glBlendEquation() or glBlendEquationEXT()\n"
402 "(whichever is supported) (OSG::BlendChunk::_sfEquation), glBlendColor() \n"
403 "(OSG::BlendChunk::_sfColor) and glAlphaFunc() (OSG::BlendChunk::_sfAlphaFunc,\n"
404 "OSG::BlendChunk::_sfAlphaValue) including glEnable(GL_ALPHA_TEST).\n"
407 /*------------------------------ get -----------------------------------*/
409 FieldContainerType &BlendChunkBase::getType(void)
411 return _type;
414 const FieldContainerType &BlendChunkBase::getType(void) const
416 return _type;
419 UInt32 BlendChunkBase::getContainerSize(void) const
421 return sizeof(BlendChunk);
424 /*------------------------- decorator get ------------------------------*/
427 SFGLenum *BlendChunkBase::editSFSrcFactor(void)
429 editSField(SrcFactorFieldMask);
431 return &_sfSrcFactor;
434 const SFGLenum *BlendChunkBase::getSFSrcFactor(void) const
436 return &_sfSrcFactor;
440 SFGLenum *BlendChunkBase::editSFDestFactor(void)
442 editSField(DestFactorFieldMask);
444 return &_sfDestFactor;
447 const SFGLenum *BlendChunkBase::getSFDestFactor(void) const
449 return &_sfDestFactor;
453 SFGLenum *BlendChunkBase::editSFEquation(void)
455 editSField(EquationFieldMask);
457 return &_sfEquation;
460 const SFGLenum *BlendChunkBase::getSFEquation(void) const
462 return &_sfEquation;
466 SFColor4f *BlendChunkBase::editSFColor(void)
468 editSField(ColorFieldMask);
470 return &_sfColor;
473 const SFColor4f *BlendChunkBase::getSFColor(void) const
475 return &_sfColor;
479 SFGLenum *BlendChunkBase::editSFAlphaFunc(void)
481 editSField(AlphaFuncFieldMask);
483 return &_sfAlphaFunc;
486 const SFGLenum *BlendChunkBase::getSFAlphaFunc(void) const
488 return &_sfAlphaFunc;
492 SFReal32 *BlendChunkBase::editSFAlphaValue(void)
494 editSField(AlphaValueFieldMask);
496 return &_sfAlphaValue;
499 const SFReal32 *BlendChunkBase::getSFAlphaValue(void) const
501 return &_sfAlphaValue;
505 SFGLenum *BlendChunkBase::editSFAlphaSrcFactor(void)
507 editSField(AlphaSrcFactorFieldMask);
509 return &_sfAlphaSrcFactor;
512 const SFGLenum *BlendChunkBase::getSFAlphaSrcFactor(void) const
514 return &_sfAlphaSrcFactor;
518 SFGLenum *BlendChunkBase::editSFAlphaDestFactor(void)
520 editSField(AlphaDestFactorFieldMask);
522 return &_sfAlphaDestFactor;
525 const SFGLenum *BlendChunkBase::getSFAlphaDestFactor(void) const
527 return &_sfAlphaDestFactor;
535 /*------------------------------ access -----------------------------------*/
537 SizeT BlendChunkBase::getBinSize(ConstFieldMaskArg whichField)
539 SizeT returnValue = Inherited::getBinSize(whichField);
541 if(FieldBits::NoField != (SrcFactorFieldMask & whichField))
543 returnValue += _sfSrcFactor.getBinSize();
545 if(FieldBits::NoField != (DestFactorFieldMask & whichField))
547 returnValue += _sfDestFactor.getBinSize();
549 if(FieldBits::NoField != (EquationFieldMask & whichField))
551 returnValue += _sfEquation.getBinSize();
553 if(FieldBits::NoField != (ColorFieldMask & whichField))
555 returnValue += _sfColor.getBinSize();
557 if(FieldBits::NoField != (AlphaFuncFieldMask & whichField))
559 returnValue += _sfAlphaFunc.getBinSize();
561 if(FieldBits::NoField != (AlphaValueFieldMask & whichField))
563 returnValue += _sfAlphaValue.getBinSize();
565 if(FieldBits::NoField != (AlphaSrcFactorFieldMask & whichField))
567 returnValue += _sfAlphaSrcFactor.getBinSize();
569 if(FieldBits::NoField != (AlphaDestFactorFieldMask & whichField))
571 returnValue += _sfAlphaDestFactor.getBinSize();
574 return returnValue;
577 void BlendChunkBase::copyToBin(BinaryDataHandler &pMem,
578 ConstFieldMaskArg whichField)
580 Inherited::copyToBin(pMem, whichField);
582 if(FieldBits::NoField != (SrcFactorFieldMask & whichField))
584 _sfSrcFactor.copyToBin(pMem);
586 if(FieldBits::NoField != (DestFactorFieldMask & whichField))
588 _sfDestFactor.copyToBin(pMem);
590 if(FieldBits::NoField != (EquationFieldMask & whichField))
592 _sfEquation.copyToBin(pMem);
594 if(FieldBits::NoField != (ColorFieldMask & whichField))
596 _sfColor.copyToBin(pMem);
598 if(FieldBits::NoField != (AlphaFuncFieldMask & whichField))
600 _sfAlphaFunc.copyToBin(pMem);
602 if(FieldBits::NoField != (AlphaValueFieldMask & whichField))
604 _sfAlphaValue.copyToBin(pMem);
606 if(FieldBits::NoField != (AlphaSrcFactorFieldMask & whichField))
608 _sfAlphaSrcFactor.copyToBin(pMem);
610 if(FieldBits::NoField != (AlphaDestFactorFieldMask & whichField))
612 _sfAlphaDestFactor.copyToBin(pMem);
616 void BlendChunkBase::copyFromBin(BinaryDataHandler &pMem,
617 ConstFieldMaskArg whichField)
619 Inherited::copyFromBin(pMem, whichField);
621 if(FieldBits::NoField != (SrcFactorFieldMask & whichField))
623 editSField(SrcFactorFieldMask);
624 _sfSrcFactor.copyFromBin(pMem);
626 if(FieldBits::NoField != (DestFactorFieldMask & whichField))
628 editSField(DestFactorFieldMask);
629 _sfDestFactor.copyFromBin(pMem);
631 if(FieldBits::NoField != (EquationFieldMask & whichField))
633 editSField(EquationFieldMask);
634 _sfEquation.copyFromBin(pMem);
636 if(FieldBits::NoField != (ColorFieldMask & whichField))
638 editSField(ColorFieldMask);
639 _sfColor.copyFromBin(pMem);
641 if(FieldBits::NoField != (AlphaFuncFieldMask & whichField))
643 editSField(AlphaFuncFieldMask);
644 _sfAlphaFunc.copyFromBin(pMem);
646 if(FieldBits::NoField != (AlphaValueFieldMask & whichField))
648 editSField(AlphaValueFieldMask);
649 _sfAlphaValue.copyFromBin(pMem);
651 if(FieldBits::NoField != (AlphaSrcFactorFieldMask & whichField))
653 editSField(AlphaSrcFactorFieldMask);
654 _sfAlphaSrcFactor.copyFromBin(pMem);
656 if(FieldBits::NoField != (AlphaDestFactorFieldMask & whichField))
658 editSField(AlphaDestFactorFieldMask);
659 _sfAlphaDestFactor.copyFromBin(pMem);
663 //! create a new instance of the class
664 BlendChunkTransitPtr BlendChunkBase::createLocal(BitVector bFlags)
666 BlendChunkTransitPtr fc;
668 if(getClassType().getPrototype() != NULL)
670 FieldContainerTransitPtr tmpPtr =
671 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
673 fc = dynamic_pointer_cast<BlendChunk>(tmpPtr);
676 return fc;
679 //! create a new instance of the class, copy the container flags
680 BlendChunkTransitPtr BlendChunkBase::createDependent(BitVector bFlags)
682 BlendChunkTransitPtr fc;
684 if(getClassType().getPrototype() != NULL)
686 FieldContainerTransitPtr tmpPtr =
687 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
689 fc = dynamic_pointer_cast<BlendChunk>(tmpPtr);
692 return fc;
695 //! create a new instance of the class
696 BlendChunkTransitPtr BlendChunkBase::create(void)
698 BlendChunkTransitPtr fc;
700 if(getClassType().getPrototype() != NULL)
702 FieldContainerTransitPtr tmpPtr =
703 getClassType().getPrototype()-> shallowCopy();
705 fc = dynamic_pointer_cast<BlendChunk>(tmpPtr);
708 return fc;
711 BlendChunk *BlendChunkBase::createEmptyLocal(BitVector bFlags)
713 BlendChunk *returnValue;
715 newPtr<BlendChunk>(returnValue, bFlags);
717 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
719 return returnValue;
722 //! create an empty new instance of the class, do not copy the prototype
723 BlendChunk *BlendChunkBase::createEmpty(void)
725 BlendChunk *returnValue;
727 newPtr<BlendChunk>(returnValue, Thread::getCurrentLocalFlags());
729 returnValue->_pFieldFlags->_bNamespaceMask &=
730 ~Thread::getCurrentLocalFlags();
732 return returnValue;
736 FieldContainerTransitPtr BlendChunkBase::shallowCopyLocal(
737 BitVector bFlags) const
739 BlendChunk *tmpPtr;
741 newPtr(tmpPtr, dynamic_cast<const BlendChunk *>(this), bFlags);
743 FieldContainerTransitPtr returnValue(tmpPtr);
745 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
747 return returnValue;
750 FieldContainerTransitPtr BlendChunkBase::shallowCopyDependent(
751 BitVector bFlags) const
753 BlendChunk *tmpPtr;
755 newPtr(tmpPtr, dynamic_cast<const BlendChunk *>(this), ~bFlags);
757 FieldContainerTransitPtr returnValue(tmpPtr);
759 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
761 return returnValue;
764 FieldContainerTransitPtr BlendChunkBase::shallowCopy(void) const
766 BlendChunk *tmpPtr;
768 newPtr(tmpPtr,
769 dynamic_cast<const BlendChunk *>(this),
770 Thread::getCurrentLocalFlags());
772 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
774 FieldContainerTransitPtr returnValue(tmpPtr);
776 return returnValue;
782 /*------------------------- constructors ----------------------------------*/
784 BlendChunkBase::BlendChunkBase(void) :
785 Inherited(),
786 _sfSrcFactor (GLenum(GL_ONE)),
787 _sfDestFactor (GLenum(GL_ZERO)),
788 _sfEquation (GLenum(GL_NONE)),
789 _sfColor (Color4f(0,0,0,0)),
790 _sfAlphaFunc (GLenum(GL_NONE)),
791 _sfAlphaValue (Real32(0)),
792 _sfAlphaSrcFactor (GLenum(OSG_GL_UNUSED)),
793 _sfAlphaDestFactor (GLenum(OSG_GL_UNUSED))
797 BlendChunkBase::BlendChunkBase(const BlendChunkBase &source) :
798 Inherited(source),
799 _sfSrcFactor (source._sfSrcFactor ),
800 _sfDestFactor (source._sfDestFactor ),
801 _sfEquation (source._sfEquation ),
802 _sfColor (source._sfColor ),
803 _sfAlphaFunc (source._sfAlphaFunc ),
804 _sfAlphaValue (source._sfAlphaValue ),
805 _sfAlphaSrcFactor (source._sfAlphaSrcFactor ),
806 _sfAlphaDestFactor (source._sfAlphaDestFactor )
811 /*-------------------------- destructors ----------------------------------*/
813 BlendChunkBase::~BlendChunkBase(void)
818 GetFieldHandlePtr BlendChunkBase::getHandleSrcFactor (void) const
820 SFGLenum::GetHandlePtr returnValue(
821 new SFGLenum::GetHandle(
822 &_sfSrcFactor,
823 this->getType().getFieldDesc(SrcFactorFieldId),
824 const_cast<BlendChunkBase *>(this)));
826 return returnValue;
829 EditFieldHandlePtr BlendChunkBase::editHandleSrcFactor (void)
831 SFGLenum::EditHandlePtr returnValue(
832 new SFGLenum::EditHandle(
833 &_sfSrcFactor,
834 this->getType().getFieldDesc(SrcFactorFieldId),
835 this));
838 editSField(SrcFactorFieldMask);
840 return returnValue;
843 GetFieldHandlePtr BlendChunkBase::getHandleDestFactor (void) const
845 SFGLenum::GetHandlePtr returnValue(
846 new SFGLenum::GetHandle(
847 &_sfDestFactor,
848 this->getType().getFieldDesc(DestFactorFieldId),
849 const_cast<BlendChunkBase *>(this)));
851 return returnValue;
854 EditFieldHandlePtr BlendChunkBase::editHandleDestFactor (void)
856 SFGLenum::EditHandlePtr returnValue(
857 new SFGLenum::EditHandle(
858 &_sfDestFactor,
859 this->getType().getFieldDesc(DestFactorFieldId),
860 this));
863 editSField(DestFactorFieldMask);
865 return returnValue;
868 GetFieldHandlePtr BlendChunkBase::getHandleEquation (void) const
870 SFGLenum::GetHandlePtr returnValue(
871 new SFGLenum::GetHandle(
872 &_sfEquation,
873 this->getType().getFieldDesc(EquationFieldId),
874 const_cast<BlendChunkBase *>(this)));
876 return returnValue;
879 EditFieldHandlePtr BlendChunkBase::editHandleEquation (void)
881 SFGLenum::EditHandlePtr returnValue(
882 new SFGLenum::EditHandle(
883 &_sfEquation,
884 this->getType().getFieldDesc(EquationFieldId),
885 this));
888 editSField(EquationFieldMask);
890 return returnValue;
893 GetFieldHandlePtr BlendChunkBase::getHandleColor (void) const
895 SFColor4f::GetHandlePtr returnValue(
896 new SFColor4f::GetHandle(
897 &_sfColor,
898 this->getType().getFieldDesc(ColorFieldId),
899 const_cast<BlendChunkBase *>(this)));
901 return returnValue;
904 EditFieldHandlePtr BlendChunkBase::editHandleColor (void)
906 SFColor4f::EditHandlePtr returnValue(
907 new SFColor4f::EditHandle(
908 &_sfColor,
909 this->getType().getFieldDesc(ColorFieldId),
910 this));
913 editSField(ColorFieldMask);
915 return returnValue;
918 GetFieldHandlePtr BlendChunkBase::getHandleAlphaFunc (void) const
920 SFGLenum::GetHandlePtr returnValue(
921 new SFGLenum::GetHandle(
922 &_sfAlphaFunc,
923 this->getType().getFieldDesc(AlphaFuncFieldId),
924 const_cast<BlendChunkBase *>(this)));
926 return returnValue;
929 EditFieldHandlePtr BlendChunkBase::editHandleAlphaFunc (void)
931 SFGLenum::EditHandlePtr returnValue(
932 new SFGLenum::EditHandle(
933 &_sfAlphaFunc,
934 this->getType().getFieldDesc(AlphaFuncFieldId),
935 this));
938 editSField(AlphaFuncFieldMask);
940 return returnValue;
943 GetFieldHandlePtr BlendChunkBase::getHandleAlphaValue (void) const
945 SFReal32::GetHandlePtr returnValue(
946 new SFReal32::GetHandle(
947 &_sfAlphaValue,
948 this->getType().getFieldDesc(AlphaValueFieldId),
949 const_cast<BlendChunkBase *>(this)));
951 return returnValue;
954 EditFieldHandlePtr BlendChunkBase::editHandleAlphaValue (void)
956 SFReal32::EditHandlePtr returnValue(
957 new SFReal32::EditHandle(
958 &_sfAlphaValue,
959 this->getType().getFieldDesc(AlphaValueFieldId),
960 this));
963 editSField(AlphaValueFieldMask);
965 return returnValue;
968 GetFieldHandlePtr BlendChunkBase::getHandleAlphaSrcFactor (void) const
970 SFGLenum::GetHandlePtr returnValue(
971 new SFGLenum::GetHandle(
972 &_sfAlphaSrcFactor,
973 this->getType().getFieldDesc(AlphaSrcFactorFieldId),
974 const_cast<BlendChunkBase *>(this)));
976 return returnValue;
979 EditFieldHandlePtr BlendChunkBase::editHandleAlphaSrcFactor (void)
981 SFGLenum::EditHandlePtr returnValue(
982 new SFGLenum::EditHandle(
983 &_sfAlphaSrcFactor,
984 this->getType().getFieldDesc(AlphaSrcFactorFieldId),
985 this));
988 editSField(AlphaSrcFactorFieldMask);
990 return returnValue;
993 GetFieldHandlePtr BlendChunkBase::getHandleAlphaDestFactor (void) const
995 SFGLenum::GetHandlePtr returnValue(
996 new SFGLenum::GetHandle(
997 &_sfAlphaDestFactor,
998 this->getType().getFieldDesc(AlphaDestFactorFieldId),
999 const_cast<BlendChunkBase *>(this)));
1001 return returnValue;
1004 EditFieldHandlePtr BlendChunkBase::editHandleAlphaDestFactor(void)
1006 SFGLenum::EditHandlePtr returnValue(
1007 new SFGLenum::EditHandle(
1008 &_sfAlphaDestFactor,
1009 this->getType().getFieldDesc(AlphaDestFactorFieldId),
1010 this));
1013 editSField(AlphaDestFactorFieldMask);
1015 return returnValue;
1019 #ifdef OSG_MT_CPTR_ASPECT
1020 void BlendChunkBase::execSyncV( FieldContainer &oFrom,
1021 ConstFieldMaskArg whichField,
1022 AspectOffsetStore &oOffsets,
1023 ConstFieldMaskArg syncMode,
1024 const UInt32 uiSyncInfo)
1026 BlendChunk *pThis = static_cast<BlendChunk *>(this);
1028 pThis->execSync(static_cast<BlendChunk *>(&oFrom),
1029 whichField,
1030 oOffsets,
1031 syncMode,
1032 uiSyncInfo);
1034 #endif
1037 #ifdef OSG_MT_CPTR_ASPECT
1038 FieldContainer *BlendChunkBase::createAspectCopy(
1039 const FieldContainer *pRefAspect) const
1041 BlendChunk *returnValue;
1043 newAspectCopy(returnValue,
1044 dynamic_cast<const BlendChunk *>(pRefAspect),
1045 dynamic_cast<const BlendChunk *>(this));
1047 return returnValue;
1049 #endif
1051 void BlendChunkBase::resolveLinks(void)
1053 Inherited::resolveLinks();
1059 OSG_END_NAMESPACE