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 TextureGrabBackground!
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"
65 #include "OSGTextureObjChunk.h" // Texture Class
67 #include "OSGTextureGrabBackgroundBase.h"
68 #include "OSGTextureGrabBackground.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
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(),
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(),
134 "The texture to grab into.\n",
135 TextureFieldId
, TextureFieldMask
,
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(),
146 "Automatically resize the texture when the viewport size changes.\n",
147 AutoResizeFieldId
, AutoResizeFieldMask
,
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(),
158 "Enum to use for glBindTexture, if GL_NONE chosen from texture dimensionality.\n",
159 BindTargetFieldId
, BindTargetFieldMask
,
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(),
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
,
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(),
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
)),
194 "<?xml version=\"1.0\"?>\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"
207 " A background that grabs what's underneath it into a texture before it clears \n"
208 " the viewport to a constant color.\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"
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"
219 "\tThe texture to grab into.\n"
222 "\t name=\"autoResize\"\n"
224 "\t cardinality=\"single\"\n"
225 "\t visibility=\"external\"\n"
226 "\t defaultValue=\"true\"\n"
227 "\t access=\"public\"\n"
229 " Automatically resize the texture when the viewport size changes.\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"
239 " Enum to use for glBindTexture, if GL_NONE chosen from texture dimensionality.\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"
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"
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"
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)
267 const FieldContainerType
&TextureGrabBackgroundBase::getType(void) const
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
286 SFUnrecTextureObjChunkPtr
*TextureGrabBackgroundBase::editSFTexture (void)
288 editSField(TextureFieldMask
);
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();
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
);
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
);
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
);
475 TextureGrabBackground
*TextureGrabBackgroundBase::createEmptyLocal(BitVector bFlags
)
477 TextureGrabBackground
*returnValue
;
479 newPtr
<TextureGrabBackground
>(returnValue
, bFlags
);
481 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
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();
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
;
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
;
528 FieldContainerTransitPtr
TextureGrabBackgroundBase::shallowCopy(void) const
530 TextureGrabBackground
*tmpPtr
;
533 dynamic_cast<const TextureGrabBackground
*>(this),
534 Thread::getCurrentLocalFlags());
536 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
538 FieldContainerTransitPtr
returnValue(tmpPtr
);
546 /*------------------------- constructors ----------------------------------*/
548 TextureGrabBackgroundBase::TextureGrabBackgroundBase(void) :
551 _sfAutoResize (bool(true)),
552 _sfBindTarget (GLenum(GL_NONE
)),
553 _sfCopyTarget (GLenum(GL_NONE
))
557 TextureGrabBackgroundBase::TextureGrabBackgroundBase(const TextureGrabBackgroundBase
&source
) :
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
);
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(
590 this->getType().getFieldDesc(TextureFieldId
),
591 const_cast<TextureGrabBackgroundBase
*>(this)));
596 EditFieldHandlePtr
TextureGrabBackgroundBase::editHandleTexture (void)
598 SFUnrecTextureObjChunkPtr::EditHandlePtr
returnValue(
599 new SFUnrecTextureObjChunkPtr::EditHandle(
601 this->getType().getFieldDesc(TextureFieldId
),
604 returnValue
->setSetMethod(
605 boost::bind(&TextureGrabBackground::setTexture
,
606 static_cast<TextureGrabBackground
*>(this), _1
));
608 editSField(TextureFieldMask
);
613 GetFieldHandlePtr
TextureGrabBackgroundBase::getHandleAutoResize (void) const
615 SFBool::GetHandlePtr
returnValue(
616 new SFBool::GetHandle(
618 this->getType().getFieldDesc(AutoResizeFieldId
),
619 const_cast<TextureGrabBackgroundBase
*>(this)));
624 EditFieldHandlePtr
TextureGrabBackgroundBase::editHandleAutoResize (void)
626 SFBool::EditHandlePtr
returnValue(
627 new SFBool::EditHandle(
629 this->getType().getFieldDesc(AutoResizeFieldId
),
633 editSField(AutoResizeFieldMask
);
638 GetFieldHandlePtr
TextureGrabBackgroundBase::getHandleBindTarget (void) const
640 SFGLenum::GetHandlePtr
returnValue(
641 new SFGLenum::GetHandle(
643 this->getType().getFieldDesc(BindTargetFieldId
),
644 const_cast<TextureGrabBackgroundBase
*>(this)));
649 EditFieldHandlePtr
TextureGrabBackgroundBase::editHandleBindTarget (void)
651 SFGLenum::EditHandlePtr
returnValue(
652 new SFGLenum::EditHandle(
654 this->getType().getFieldDesc(BindTargetFieldId
),
658 editSField(BindTargetFieldMask
);
663 GetFieldHandlePtr
TextureGrabBackgroundBase::getHandleCopyTarget (void) const
665 SFGLenum::GetHandlePtr
returnValue(
666 new SFGLenum::GetHandle(
668 this->getType().getFieldDesc(CopyTargetFieldId
),
669 const_cast<TextureGrabBackgroundBase
*>(this)));
674 EditFieldHandlePtr
TextureGrabBackgroundBase::editHandleCopyTarget (void)
676 SFGLenum::EditHandlePtr
returnValue(
677 new SFGLenum::EditHandle(
679 this->getType().getFieldDesc(CopyTargetFieldId
),
683 editSField(CopyTargetFieldMask
);
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
),
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));
721 void TextureGrabBackgroundBase::resolveLinks(void)
723 Inherited::resolveLinks();
725 static_cast<TextureGrabBackground
*>(this)->setTexture(NULL
);