changed: gcc8 base update
[opensg.git] / Source / System / Window / Background / OSGTextureGrabBackgroundBase.cpp
blob5f1a2cb82ee6e123141e3e3315bed2a063632ad5
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 TextureGrabBackground!
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"
65 #include "OSGTextureObjChunk.h" // Texture Class
67 #include "OSGTextureGrabBackgroundBase.h"
68 #include "OSGTextureGrabBackground.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::TextureGrabBackground
79 A background that grabs what's underneath it into a texture before it clears
80 the viewport to a constant color.
82 The color of the background is given by the _sfColor field, the texture to
83 grab into by the _sfTexture field.
86 /***************************************************************************\
87 * Field Documentation *
88 \***************************************************************************/
90 /*! \var TextureObjChunk * TextureGrabBackgroundBase::_sfTexture
91 The texture to grab into.
94 /*! \var bool TextureGrabBackgroundBase::_sfAutoResize
95 Automatically resize the texture when the viewport size changes.
98 /*! \var GLenum TextureGrabBackgroundBase::_sfBindTarget
99 Enum to use for glBindTexture, if GL_NONE chosen from texture dimensionality.
102 /*! \var GLenum TextureGrabBackgroundBase::_sfCopyTarget
103 Enum to use for glCopyTexture, if GL_NONE chosen from texture dimensionality.
104 Mainly useful to grab into the different parts of a CubeTexture.
108 /***************************************************************************\
109 * FieldType/FieldTrait Instantiation *
110 \***************************************************************************/
112 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
113 PointerType FieldTraits<TextureGrabBackground *, nsOSG>::_type(
114 "TextureGrabBackgroundPtr",
115 "SolidBackgroundPtr",
116 TextureGrabBackground::getClassType(),
117 nsOSG);
118 #endif
120 OSG_FIELDTRAITS_GETTYPE_NS(TextureGrabBackground *, nsOSG)
122 /***************************************************************************\
123 * Field Description *
124 \***************************************************************************/
126 void TextureGrabBackgroundBase::classDescInserter(TypeObject &oType)
128 FieldDescriptionBase *pDesc = NULL;
131 pDesc = new SFUnrecTextureObjChunkPtr::Description(
132 SFUnrecTextureObjChunkPtr::getClassType(),
133 "texture",
134 "The texture to grab into.\n",
135 TextureFieldId, TextureFieldMask,
136 false,
137 (Field::SFDefaultFlags | Field::FStdAccess),
138 static_cast<FieldEditMethodSig>(&TextureGrabBackground::editHandleTexture),
139 static_cast<FieldGetMethodSig >(&TextureGrabBackground::getHandleTexture));
141 oType.addInitialDesc(pDesc);
143 pDesc = new SFBool::Description(
144 SFBool::getClassType(),
145 "autoResize",
146 "Automatically resize the texture when the viewport size changes.\n",
147 AutoResizeFieldId, AutoResizeFieldMask,
148 false,
149 (Field::SFDefaultFlags | Field::FStdAccess),
150 static_cast<FieldEditMethodSig>(&TextureGrabBackground::editHandleAutoResize),
151 static_cast<FieldGetMethodSig >(&TextureGrabBackground::getHandleAutoResize));
153 oType.addInitialDesc(pDesc);
155 pDesc = new SFGLenum::Description(
156 SFGLenum::getClassType(),
157 "bindTarget",
158 "Enum to use for glBindTexture, if GL_NONE chosen from texture dimensionality.\n",
159 BindTargetFieldId, BindTargetFieldMask,
160 false,
161 (Field::SFDefaultFlags | Field::FStdAccess),
162 static_cast<FieldEditMethodSig>(&TextureGrabBackground::editHandleBindTarget),
163 static_cast<FieldGetMethodSig >(&TextureGrabBackground::getHandleBindTarget));
165 oType.addInitialDesc(pDesc);
167 pDesc = new SFGLenum::Description(
168 SFGLenum::getClassType(),
169 "copyTarget",
170 "Enum to use for glCopyTexture, if GL_NONE chosen from texture dimensionality.\n"
171 "Mainly useful to grab into the different parts of a CubeTexture.\n",
172 CopyTargetFieldId, CopyTargetFieldMask,
173 false,
174 (Field::SFDefaultFlags | Field::FStdAccess),
175 static_cast<FieldEditMethodSig>(&TextureGrabBackground::editHandleCopyTarget),
176 static_cast<FieldGetMethodSig >(&TextureGrabBackground::getHandleCopyTarget));
178 oType.addInitialDesc(pDesc);
182 TextureGrabBackgroundBase::TypeObject TextureGrabBackgroundBase::_type(
183 TextureGrabBackgroundBase::getClassname(),
184 Inherited::getClassname(),
185 "NULL",
186 nsOSG, //Namespace
187 reinterpret_cast<PrototypeCreateF>(&TextureGrabBackgroundBase::createEmptyLocal),
188 reinterpret_cast<InitContainerF>(&TextureGrabBackground::initMethod),
189 reinterpret_cast<ExitContainerF>(&TextureGrabBackground::exitMethod),
190 reinterpret_cast<InitalInsertDescFunc>(
191 reinterpret_cast<void *>(&TextureGrabBackground::classDescInserter)),
192 false,
194 "<?xml version=\"1.0\"?>\n"
195 "\n"
196 "<FieldContainer\n"
197 " name=\"TextureGrabBackground\"\n"
198 " parent=\"SolidBackground\"\n"
199 " library=\"Window\"\n"
200 " pointerfieldtypes=\"none\"\n"
201 " structure=\"concrete\"\n"
202 " systemcomponent=\"true\"\n"
203 " parentsystemcomponent=\"true\"\n"
204 " decoratable=\"false\"\n"
205 " docGroupBase=\"GrpWindowBackground\"\n"
206 " >\n"
207 " A background that grabs what's underneath it into a texture before it clears \n"
208 " the viewport to a constant color.\n"
209 "\n"
210 " The color of the background is given by the _sfColor field, the texture to\n"
211 " grab into by the _sfTexture field.\n"
212 " <Field\n"
213 "\t name=\"texture\"\n"
214 "\t type=\"TextureObjChunkPtr\"\n"
215 "\t cardinality=\"single\"\n"
216 "\t visibility=\"external\"\n"
217 "\t access=\"public\"\n"
218 "\t >\n"
219 "\tThe texture to grab into.\n"
220 " </Field>\n"
221 " <Field\n"
222 "\t name=\"autoResize\"\n"
223 "\t type=\"bool\"\n"
224 "\t cardinality=\"single\"\n"
225 "\t visibility=\"external\"\n"
226 "\t defaultValue=\"true\"\n"
227 "\t access=\"public\"\n"
228 "\t >\n"
229 " Automatically resize the texture when the viewport size changes.\n"
230 " </Field>\n"
231 " <Field\n"
232 "\t name=\"bindTarget\"\n"
233 "\t type=\"GLenum\"\n"
234 "\t cardinality=\"single\"\n"
235 "\t visibility=\"external\"\n"
236 "\t defaultValue=\"GL_NONE\"\n"
237 "\t access=\"public\"\n"
238 "\t >\n"
239 " Enum to use for glBindTexture, if GL_NONE chosen from texture dimensionality.\n"
240 " </Field>\n"
241 " <Field\n"
242 "\t name=\"copyTarget\"\n"
243 "\t type=\"GLenum\"\n"
244 "\t cardinality=\"single\"\n"
245 "\t visibility=\"external\"\n"
246 "\t defaultValue=\"GL_NONE\"\n"
247 "\t access=\"public\"\n"
248 "\t >\n"
249 " Enum to use for glCopyTexture, if GL_NONE chosen from texture dimensionality.\n"
250 " Mainly useful to grab into the different parts of a CubeTexture.\n"
251 " </Field>\n"
252 "</FieldContainer>\n",
253 "A background that grabs what's underneath it into a texture before it clears \n"
254 "the viewport to a constant color.\n"
255 "\n"
256 "The color of the background is given by the _sfColor field, the texture to\n"
257 "grab into by the _sfTexture field.\n"
260 /*------------------------------ get -----------------------------------*/
262 FieldContainerType &TextureGrabBackgroundBase::getType(void)
264 return _type;
267 const FieldContainerType &TextureGrabBackgroundBase::getType(void) const
269 return _type;
272 UInt32 TextureGrabBackgroundBase::getContainerSize(void) const
274 return sizeof(TextureGrabBackground);
277 /*------------------------- decorator get ------------------------------*/
280 //! Get the TextureGrabBackground::_sfTexture field.
281 const SFUnrecTextureObjChunkPtr *TextureGrabBackgroundBase::getSFTexture(void) const
283 return &_sfTexture;
286 SFUnrecTextureObjChunkPtr *TextureGrabBackgroundBase::editSFTexture (void)
288 editSField(TextureFieldMask);
290 return &_sfTexture;
293 //! Get the value of the TextureGrabBackground::_sfTexture field.
294 TextureObjChunk * TextureGrabBackgroundBase::getTexture(void) const
296 return _sfTexture.getValue();
299 //! Set the value of the TextureGrabBackground::_sfTexture field.
300 void TextureGrabBackgroundBase::setTexture(TextureObjChunk * const value)
302 editSField(TextureFieldMask);
304 _sfTexture.setValue(value);
308 SFBool *TextureGrabBackgroundBase::editSFAutoResize(void)
310 editSField(AutoResizeFieldMask);
312 return &_sfAutoResize;
315 const SFBool *TextureGrabBackgroundBase::getSFAutoResize(void) const
317 return &_sfAutoResize;
321 SFGLenum *TextureGrabBackgroundBase::editSFBindTarget(void)
323 editSField(BindTargetFieldMask);
325 return &_sfBindTarget;
328 const SFGLenum *TextureGrabBackgroundBase::getSFBindTarget(void) const
330 return &_sfBindTarget;
334 SFGLenum *TextureGrabBackgroundBase::editSFCopyTarget(void)
336 editSField(CopyTargetFieldMask);
338 return &_sfCopyTarget;
341 const SFGLenum *TextureGrabBackgroundBase::getSFCopyTarget(void) const
343 return &_sfCopyTarget;
351 /*------------------------------ access -----------------------------------*/
353 SizeT TextureGrabBackgroundBase::getBinSize(ConstFieldMaskArg whichField)
355 SizeT returnValue = Inherited::getBinSize(whichField);
357 if(FieldBits::NoField != (TextureFieldMask & whichField))
359 returnValue += _sfTexture.getBinSize();
361 if(FieldBits::NoField != (AutoResizeFieldMask & whichField))
363 returnValue += _sfAutoResize.getBinSize();
365 if(FieldBits::NoField != (BindTargetFieldMask & whichField))
367 returnValue += _sfBindTarget.getBinSize();
369 if(FieldBits::NoField != (CopyTargetFieldMask & whichField))
371 returnValue += _sfCopyTarget.getBinSize();
374 return returnValue;
377 void TextureGrabBackgroundBase::copyToBin(BinaryDataHandler &pMem,
378 ConstFieldMaskArg whichField)
380 Inherited::copyToBin(pMem, whichField);
382 if(FieldBits::NoField != (TextureFieldMask & whichField))
384 _sfTexture.copyToBin(pMem);
386 if(FieldBits::NoField != (AutoResizeFieldMask & whichField))
388 _sfAutoResize.copyToBin(pMem);
390 if(FieldBits::NoField != (BindTargetFieldMask & whichField))
392 _sfBindTarget.copyToBin(pMem);
394 if(FieldBits::NoField != (CopyTargetFieldMask & whichField))
396 _sfCopyTarget.copyToBin(pMem);
400 void TextureGrabBackgroundBase::copyFromBin(BinaryDataHandler &pMem,
401 ConstFieldMaskArg whichField)
403 Inherited::copyFromBin(pMem, whichField);
405 if(FieldBits::NoField != (TextureFieldMask & whichField))
407 editSField(TextureFieldMask);
408 _sfTexture.copyFromBin(pMem);
410 if(FieldBits::NoField != (AutoResizeFieldMask & whichField))
412 editSField(AutoResizeFieldMask);
413 _sfAutoResize.copyFromBin(pMem);
415 if(FieldBits::NoField != (BindTargetFieldMask & whichField))
417 editSField(BindTargetFieldMask);
418 _sfBindTarget.copyFromBin(pMem);
420 if(FieldBits::NoField != (CopyTargetFieldMask & whichField))
422 editSField(CopyTargetFieldMask);
423 _sfCopyTarget.copyFromBin(pMem);
427 //! create a new instance of the class
428 TextureGrabBackgroundTransitPtr TextureGrabBackgroundBase::createLocal(BitVector bFlags)
430 TextureGrabBackgroundTransitPtr fc;
432 if(getClassType().getPrototype() != NULL)
434 FieldContainerTransitPtr tmpPtr =
435 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
437 fc = dynamic_pointer_cast<TextureGrabBackground>(tmpPtr);
440 return fc;
443 //! create a new instance of the class, copy the container flags
444 TextureGrabBackgroundTransitPtr TextureGrabBackgroundBase::createDependent(BitVector bFlags)
446 TextureGrabBackgroundTransitPtr fc;
448 if(getClassType().getPrototype() != NULL)
450 FieldContainerTransitPtr tmpPtr =
451 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
453 fc = dynamic_pointer_cast<TextureGrabBackground>(tmpPtr);
456 return fc;
459 //! create a new instance of the class
460 TextureGrabBackgroundTransitPtr TextureGrabBackgroundBase::create(void)
462 TextureGrabBackgroundTransitPtr fc;
464 if(getClassType().getPrototype() != NULL)
466 FieldContainerTransitPtr tmpPtr =
467 getClassType().getPrototype()-> shallowCopy();
469 fc = dynamic_pointer_cast<TextureGrabBackground>(tmpPtr);
472 return fc;
475 TextureGrabBackground *TextureGrabBackgroundBase::createEmptyLocal(BitVector bFlags)
477 TextureGrabBackground *returnValue;
479 newPtr<TextureGrabBackground>(returnValue, bFlags);
481 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
483 return returnValue;
486 //! create an empty new instance of the class, do not copy the prototype
487 TextureGrabBackground *TextureGrabBackgroundBase::createEmpty(void)
489 TextureGrabBackground *returnValue;
491 newPtr<TextureGrabBackground>(returnValue, Thread::getCurrentLocalFlags());
493 returnValue->_pFieldFlags->_bNamespaceMask &=
494 ~Thread::getCurrentLocalFlags();
496 return returnValue;
500 FieldContainerTransitPtr TextureGrabBackgroundBase::shallowCopyLocal(
501 BitVector bFlags) const
503 TextureGrabBackground *tmpPtr;
505 newPtr(tmpPtr, dynamic_cast<const TextureGrabBackground *>(this), bFlags);
507 FieldContainerTransitPtr returnValue(tmpPtr);
509 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
511 return returnValue;
514 FieldContainerTransitPtr TextureGrabBackgroundBase::shallowCopyDependent(
515 BitVector bFlags) const
517 TextureGrabBackground *tmpPtr;
519 newPtr(tmpPtr, dynamic_cast<const TextureGrabBackground *>(this), ~bFlags);
521 FieldContainerTransitPtr returnValue(tmpPtr);
523 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
525 return returnValue;
528 FieldContainerTransitPtr TextureGrabBackgroundBase::shallowCopy(void) const
530 TextureGrabBackground *tmpPtr;
532 newPtr(tmpPtr,
533 dynamic_cast<const TextureGrabBackground *>(this),
534 Thread::getCurrentLocalFlags());
536 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
538 FieldContainerTransitPtr returnValue(tmpPtr);
540 return returnValue;
546 /*------------------------- constructors ----------------------------------*/
548 TextureGrabBackgroundBase::TextureGrabBackgroundBase(void) :
549 Inherited(),
550 _sfTexture (NULL),
551 _sfAutoResize (bool(true)),
552 _sfBindTarget (GLenum(GL_NONE)),
553 _sfCopyTarget (GLenum(GL_NONE))
557 TextureGrabBackgroundBase::TextureGrabBackgroundBase(const TextureGrabBackgroundBase &source) :
558 Inherited(source),
559 _sfTexture (NULL),
560 _sfAutoResize (source._sfAutoResize ),
561 _sfBindTarget (source._sfBindTarget ),
562 _sfCopyTarget (source._sfCopyTarget )
567 /*-------------------------- destructors ----------------------------------*/
569 TextureGrabBackgroundBase::~TextureGrabBackgroundBase(void)
573 void TextureGrabBackgroundBase::onCreate(const TextureGrabBackground *source)
575 Inherited::onCreate(source);
577 if(source != NULL)
579 TextureGrabBackground *pThis = static_cast<TextureGrabBackground *>(this);
581 pThis->setTexture(source->getTexture());
585 GetFieldHandlePtr TextureGrabBackgroundBase::getHandleTexture (void) const
587 SFUnrecTextureObjChunkPtr::GetHandlePtr returnValue(
588 new SFUnrecTextureObjChunkPtr::GetHandle(
589 &_sfTexture,
590 this->getType().getFieldDesc(TextureFieldId),
591 const_cast<TextureGrabBackgroundBase *>(this)));
593 return returnValue;
596 EditFieldHandlePtr TextureGrabBackgroundBase::editHandleTexture (void)
598 SFUnrecTextureObjChunkPtr::EditHandlePtr returnValue(
599 new SFUnrecTextureObjChunkPtr::EditHandle(
600 &_sfTexture,
601 this->getType().getFieldDesc(TextureFieldId),
602 this));
604 returnValue->setSetMethod(
605 boost::bind(&TextureGrabBackground::setTexture,
606 static_cast<TextureGrabBackground *>(this), _1));
608 editSField(TextureFieldMask);
610 return returnValue;
613 GetFieldHandlePtr TextureGrabBackgroundBase::getHandleAutoResize (void) const
615 SFBool::GetHandlePtr returnValue(
616 new SFBool::GetHandle(
617 &_sfAutoResize,
618 this->getType().getFieldDesc(AutoResizeFieldId),
619 const_cast<TextureGrabBackgroundBase *>(this)));
621 return returnValue;
624 EditFieldHandlePtr TextureGrabBackgroundBase::editHandleAutoResize (void)
626 SFBool::EditHandlePtr returnValue(
627 new SFBool::EditHandle(
628 &_sfAutoResize,
629 this->getType().getFieldDesc(AutoResizeFieldId),
630 this));
633 editSField(AutoResizeFieldMask);
635 return returnValue;
638 GetFieldHandlePtr TextureGrabBackgroundBase::getHandleBindTarget (void) const
640 SFGLenum::GetHandlePtr returnValue(
641 new SFGLenum::GetHandle(
642 &_sfBindTarget,
643 this->getType().getFieldDesc(BindTargetFieldId),
644 const_cast<TextureGrabBackgroundBase *>(this)));
646 return returnValue;
649 EditFieldHandlePtr TextureGrabBackgroundBase::editHandleBindTarget (void)
651 SFGLenum::EditHandlePtr returnValue(
652 new SFGLenum::EditHandle(
653 &_sfBindTarget,
654 this->getType().getFieldDesc(BindTargetFieldId),
655 this));
658 editSField(BindTargetFieldMask);
660 return returnValue;
663 GetFieldHandlePtr TextureGrabBackgroundBase::getHandleCopyTarget (void) const
665 SFGLenum::GetHandlePtr returnValue(
666 new SFGLenum::GetHandle(
667 &_sfCopyTarget,
668 this->getType().getFieldDesc(CopyTargetFieldId),
669 const_cast<TextureGrabBackgroundBase *>(this)));
671 return returnValue;
674 EditFieldHandlePtr TextureGrabBackgroundBase::editHandleCopyTarget (void)
676 SFGLenum::EditHandlePtr returnValue(
677 new SFGLenum::EditHandle(
678 &_sfCopyTarget,
679 this->getType().getFieldDesc(CopyTargetFieldId),
680 this));
683 editSField(CopyTargetFieldMask);
685 return returnValue;
689 #ifdef OSG_MT_CPTR_ASPECT
690 void TextureGrabBackgroundBase::execSyncV( FieldContainer &oFrom,
691 ConstFieldMaskArg whichField,
692 AspectOffsetStore &oOffsets,
693 ConstFieldMaskArg syncMode,
694 const UInt32 uiSyncInfo)
696 TextureGrabBackground *pThis = static_cast<TextureGrabBackground *>(this);
698 pThis->execSync(static_cast<TextureGrabBackground *>(&oFrom),
699 whichField,
700 oOffsets,
701 syncMode,
702 uiSyncInfo);
704 #endif
707 #ifdef OSG_MT_CPTR_ASPECT
708 FieldContainer *TextureGrabBackgroundBase::createAspectCopy(
709 const FieldContainer *pRefAspect) const
711 TextureGrabBackground *returnValue;
713 newAspectCopy(returnValue,
714 dynamic_cast<const TextureGrabBackground *>(pRefAspect),
715 dynamic_cast<const TextureGrabBackground *>(this));
717 return returnValue;
719 #endif
721 void TextureGrabBackgroundBase::resolveLinks(void)
723 Inherited::resolveLinks();
725 static_cast<TextureGrabBackground *>(this)->setTexture(NULL);
731 OSG_END_NAMESPACE