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 TextureGrabForeground!
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 "OSGTextureGrabForegroundBase.h"
68 #include "OSGTextureGrabForeground.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::TextureGrabForeground
79 The GrabForeground is used for grabbing a rendered viewport into a Texture.
80 See \ref PageSystemWindowForegroundGrabTexture for a description.
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var TextureObjChunk * TextureGrabForegroundBase::_sfTexture
88 The texture to grab into.
91 /*! \var bool TextureGrabForegroundBase::_sfAutoResize
92 Automatically resize the texture when the viewport size changes.
95 /*! \var GLenum TextureGrabForegroundBase::_sfBindTarget
96 Enum to use for glBindTexture, if GL_NONE chosen from texture
100 /*! \var GLenum TextureGrabForegroundBase::_sfCopyTarget
101 Enum to use for glCopyTexture, if GL_NONE chosen from texture
103 Mainly useful to grab into the different parts of a CubeTexture.
107 /***************************************************************************\
108 * FieldType/FieldTrait Instantiation *
109 \***************************************************************************/
111 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
112 PointerType FieldTraits
<TextureGrabForeground
*, nsOSG
>::_type(
113 "TextureGrabForegroundPtr",
115 TextureGrabForeground::getClassType(),
119 OSG_FIELDTRAITS_GETTYPE_NS(TextureGrabForeground
*, nsOSG
)
121 /***************************************************************************\
122 * Field Description *
123 \***************************************************************************/
125 void TextureGrabForegroundBase::classDescInserter(TypeObject
&oType
)
127 FieldDescriptionBase
*pDesc
= NULL
;
130 pDesc
= new SFUnrecTextureObjChunkPtr::Description(
131 SFUnrecTextureObjChunkPtr::getClassType(),
133 "The texture to grab into.\n",
134 TextureFieldId
, TextureFieldMask
,
136 (Field::SFDefaultFlags
| Field::FStdAccess
),
137 static_cast<FieldEditMethodSig
>(&TextureGrabForeground::editHandleTexture
),
138 static_cast<FieldGetMethodSig
>(&TextureGrabForeground::getHandleTexture
));
140 oType
.addInitialDesc(pDesc
);
142 pDesc
= new SFBool::Description(
143 SFBool::getClassType(),
145 "Automatically resize the texture when the viewport size changes.\n",
146 AutoResizeFieldId
, AutoResizeFieldMask
,
148 (Field::SFDefaultFlags
| Field::FStdAccess
),
149 static_cast<FieldEditMethodSig
>(&TextureGrabForeground::editHandleAutoResize
),
150 static_cast<FieldGetMethodSig
>(&TextureGrabForeground::getHandleAutoResize
));
152 oType
.addInitialDesc(pDesc
);
154 pDesc
= new SFGLenum::Description(
155 SFGLenum::getClassType(),
157 "Enum to use for glBindTexture, if GL_NONE chosen from texture\n"
158 "dimensionality. \n",
159 BindTargetFieldId
, BindTargetFieldMask
,
161 (Field::SFDefaultFlags
| Field::FStdAccess
),
162 static_cast<FieldEditMethodSig
>(&TextureGrabForeground::editHandleBindTarget
),
163 static_cast<FieldGetMethodSig
>(&TextureGrabForeground::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\n"
172 "Mainly useful to grab into the different parts of a CubeTexture.\n",
173 CopyTargetFieldId
, CopyTargetFieldMask
,
175 (Field::SFDefaultFlags
| Field::FStdAccess
),
176 static_cast<FieldEditMethodSig
>(&TextureGrabForeground::editHandleCopyTarget
),
177 static_cast<FieldGetMethodSig
>(&TextureGrabForeground::getHandleCopyTarget
));
179 oType
.addInitialDesc(pDesc
);
183 TextureGrabForegroundBase::TypeObject
TextureGrabForegroundBase::_type(
184 TextureGrabForegroundBase::getClassname(),
185 Inherited::getClassname(),
188 reinterpret_cast<PrototypeCreateF
>(&TextureGrabForegroundBase::createEmptyLocal
),
189 reinterpret_cast<InitContainerF
>(&TextureGrabForeground::initMethod
),
190 reinterpret_cast<ExitContainerF
>(&TextureGrabForeground::exitMethod
),
191 reinterpret_cast<InitalInsertDescFunc
>(
192 reinterpret_cast<void *>(&TextureGrabForeground::classDescInserter
)),
195 "<?xml version=\"1.0\"?>\n"
198 " name=\"TextureGrabForeground\"\n"
199 " parent=\"Foreground\"\n"
200 " library=\"Window\"\n"
201 " pointerfieldtypes=\"none\"\n"
202 " structure=\"concrete\"\n"
203 " systemcomponent=\"true\"\n"
204 " parentsystemcomponent=\"true\"\n"
205 " decoratable=\"false\"\n"
206 " docGroupBase=\"GrpWindowForeground\"\n"
208 " The GrabForeground is used for grabbing a rendered viewport into a Texture.\n"
209 " See \\ref PageSystemWindowForegroundGrabTexture for a description.\n"
211 "\t name=\"texture\"\n"
212 "\t type=\"TextureObjChunkPtr\"\n"
213 "\t cardinality=\"single\"\n"
214 "\t visibility=\"external\"\n"
215 "\t access=\"public\"\n"
217 "\tThe texture to grab into.\n"
220 "\t name=\"autoResize\"\n"
222 "\t cardinality=\"single\"\n"
223 "\t visibility=\"external\"\n"
224 "\t defaultValue=\"true\"\n"
225 "\t access=\"public\"\n"
227 " Automatically resize the texture when the viewport size changes.\n"
230 "\t name=\"bindTarget\"\n"
231 "\t type=\"GLenum\"\n"
232 "\t cardinality=\"single\"\n"
233 "\t visibility=\"external\"\n"
234 "\t defaultValue=\"GL_NONE\"\n"
235 "\t access=\"public\"\n"
237 " Enum to use for glBindTexture, if GL_NONE chosen from texture\n"
238 "\tdimensionality. \n"
241 "\t name=\"copyTarget\"\n"
242 "\t type=\"GLenum\"\n"
243 "\t cardinality=\"single\"\n"
244 "\t visibility=\"external\"\n"
245 "\t defaultValue=\"GL_NONE\"\n"
246 "\t access=\"public\"\n"
248 " Enum to use for glCopyTexture, if GL_NONE chosen from texture\n"
249 "\tdimensionality. \n"
250 " Mainly useful to grab into the different parts of a CubeTexture.\n"
252 "</FieldContainer>\n",
253 "The GrabForeground is used for grabbing a rendered viewport into a Texture.\n"
254 "See \\ref PageSystemWindowForegroundGrabTexture for a description.\n"
257 /*------------------------------ get -----------------------------------*/
259 FieldContainerType
&TextureGrabForegroundBase::getType(void)
264 const FieldContainerType
&TextureGrabForegroundBase::getType(void) const
269 UInt32
TextureGrabForegroundBase::getContainerSize(void) const
271 return sizeof(TextureGrabForeground
);
274 /*------------------------- decorator get ------------------------------*/
277 //! Get the TextureGrabForeground::_sfTexture field.
278 const SFUnrecTextureObjChunkPtr
*TextureGrabForegroundBase::getSFTexture(void) const
283 SFUnrecTextureObjChunkPtr
*TextureGrabForegroundBase::editSFTexture (void)
285 editSField(TextureFieldMask
);
290 //! Get the value of the TextureGrabForeground::_sfTexture field.
291 TextureObjChunk
* TextureGrabForegroundBase::getTexture(void) const
293 return _sfTexture
.getValue();
296 //! Set the value of the TextureGrabForeground::_sfTexture field.
297 void TextureGrabForegroundBase::setTexture(TextureObjChunk
* const value
)
299 editSField(TextureFieldMask
);
301 _sfTexture
.setValue(value
);
305 SFBool
*TextureGrabForegroundBase::editSFAutoResize(void)
307 editSField(AutoResizeFieldMask
);
309 return &_sfAutoResize
;
312 const SFBool
*TextureGrabForegroundBase::getSFAutoResize(void) const
314 return &_sfAutoResize
;
318 SFGLenum
*TextureGrabForegroundBase::editSFBindTarget(void)
320 editSField(BindTargetFieldMask
);
322 return &_sfBindTarget
;
325 const SFGLenum
*TextureGrabForegroundBase::getSFBindTarget(void) const
327 return &_sfBindTarget
;
331 SFGLenum
*TextureGrabForegroundBase::editSFCopyTarget(void)
333 editSField(CopyTargetFieldMask
);
335 return &_sfCopyTarget
;
338 const SFGLenum
*TextureGrabForegroundBase::getSFCopyTarget(void) const
340 return &_sfCopyTarget
;
348 /*------------------------------ access -----------------------------------*/
350 SizeT
TextureGrabForegroundBase::getBinSize(ConstFieldMaskArg whichField
)
352 SizeT returnValue
= Inherited::getBinSize(whichField
);
354 if(FieldBits::NoField
!= (TextureFieldMask
& whichField
))
356 returnValue
+= _sfTexture
.getBinSize();
358 if(FieldBits::NoField
!= (AutoResizeFieldMask
& whichField
))
360 returnValue
+= _sfAutoResize
.getBinSize();
362 if(FieldBits::NoField
!= (BindTargetFieldMask
& whichField
))
364 returnValue
+= _sfBindTarget
.getBinSize();
366 if(FieldBits::NoField
!= (CopyTargetFieldMask
& whichField
))
368 returnValue
+= _sfCopyTarget
.getBinSize();
374 void TextureGrabForegroundBase::copyToBin(BinaryDataHandler
&pMem
,
375 ConstFieldMaskArg whichField
)
377 Inherited::copyToBin(pMem
, whichField
);
379 if(FieldBits::NoField
!= (TextureFieldMask
& whichField
))
381 _sfTexture
.copyToBin(pMem
);
383 if(FieldBits::NoField
!= (AutoResizeFieldMask
& whichField
))
385 _sfAutoResize
.copyToBin(pMem
);
387 if(FieldBits::NoField
!= (BindTargetFieldMask
& whichField
))
389 _sfBindTarget
.copyToBin(pMem
);
391 if(FieldBits::NoField
!= (CopyTargetFieldMask
& whichField
))
393 _sfCopyTarget
.copyToBin(pMem
);
397 void TextureGrabForegroundBase::copyFromBin(BinaryDataHandler
&pMem
,
398 ConstFieldMaskArg whichField
)
400 Inherited::copyFromBin(pMem
, whichField
);
402 if(FieldBits::NoField
!= (TextureFieldMask
& whichField
))
404 editSField(TextureFieldMask
);
405 _sfTexture
.copyFromBin(pMem
);
407 if(FieldBits::NoField
!= (AutoResizeFieldMask
& whichField
))
409 editSField(AutoResizeFieldMask
);
410 _sfAutoResize
.copyFromBin(pMem
);
412 if(FieldBits::NoField
!= (BindTargetFieldMask
& whichField
))
414 editSField(BindTargetFieldMask
);
415 _sfBindTarget
.copyFromBin(pMem
);
417 if(FieldBits::NoField
!= (CopyTargetFieldMask
& whichField
))
419 editSField(CopyTargetFieldMask
);
420 _sfCopyTarget
.copyFromBin(pMem
);
424 //! create a new instance of the class
425 TextureGrabForegroundTransitPtr
TextureGrabForegroundBase::createLocal(BitVector bFlags
)
427 TextureGrabForegroundTransitPtr fc
;
429 if(getClassType().getPrototype() != NULL
)
431 FieldContainerTransitPtr tmpPtr
=
432 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
434 fc
= dynamic_pointer_cast
<TextureGrabForeground
>(tmpPtr
);
440 //! create a new instance of the class, copy the container flags
441 TextureGrabForegroundTransitPtr
TextureGrabForegroundBase::createDependent(BitVector bFlags
)
443 TextureGrabForegroundTransitPtr fc
;
445 if(getClassType().getPrototype() != NULL
)
447 FieldContainerTransitPtr tmpPtr
=
448 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
450 fc
= dynamic_pointer_cast
<TextureGrabForeground
>(tmpPtr
);
456 //! create a new instance of the class
457 TextureGrabForegroundTransitPtr
TextureGrabForegroundBase::create(void)
459 TextureGrabForegroundTransitPtr fc
;
461 if(getClassType().getPrototype() != NULL
)
463 FieldContainerTransitPtr tmpPtr
=
464 getClassType().getPrototype()-> shallowCopy();
466 fc
= dynamic_pointer_cast
<TextureGrabForeground
>(tmpPtr
);
472 TextureGrabForeground
*TextureGrabForegroundBase::createEmptyLocal(BitVector bFlags
)
474 TextureGrabForeground
*returnValue
;
476 newPtr
<TextureGrabForeground
>(returnValue
, bFlags
);
478 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
483 //! create an empty new instance of the class, do not copy the prototype
484 TextureGrabForeground
*TextureGrabForegroundBase::createEmpty(void)
486 TextureGrabForeground
*returnValue
;
488 newPtr
<TextureGrabForeground
>(returnValue
, Thread::getCurrentLocalFlags());
490 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
491 ~Thread::getCurrentLocalFlags();
497 FieldContainerTransitPtr
TextureGrabForegroundBase::shallowCopyLocal(
498 BitVector bFlags
) const
500 TextureGrabForeground
*tmpPtr
;
502 newPtr(tmpPtr
, dynamic_cast<const TextureGrabForeground
*>(this), bFlags
);
504 FieldContainerTransitPtr
returnValue(tmpPtr
);
506 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
511 FieldContainerTransitPtr
TextureGrabForegroundBase::shallowCopyDependent(
512 BitVector bFlags
) const
514 TextureGrabForeground
*tmpPtr
;
516 newPtr(tmpPtr
, dynamic_cast<const TextureGrabForeground
*>(this), ~bFlags
);
518 FieldContainerTransitPtr
returnValue(tmpPtr
);
520 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
525 FieldContainerTransitPtr
TextureGrabForegroundBase::shallowCopy(void) const
527 TextureGrabForeground
*tmpPtr
;
530 dynamic_cast<const TextureGrabForeground
*>(this),
531 Thread::getCurrentLocalFlags());
533 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
535 FieldContainerTransitPtr
returnValue(tmpPtr
);
543 /*------------------------- constructors ----------------------------------*/
545 TextureGrabForegroundBase::TextureGrabForegroundBase(void) :
548 _sfAutoResize (bool(true)),
549 _sfBindTarget (GLenum(GL_NONE
)),
550 _sfCopyTarget (GLenum(GL_NONE
))
554 TextureGrabForegroundBase::TextureGrabForegroundBase(const TextureGrabForegroundBase
&source
) :
557 _sfAutoResize (source
._sfAutoResize
),
558 _sfBindTarget (source
._sfBindTarget
),
559 _sfCopyTarget (source
._sfCopyTarget
)
564 /*-------------------------- destructors ----------------------------------*/
566 TextureGrabForegroundBase::~TextureGrabForegroundBase(void)
570 void TextureGrabForegroundBase::onCreate(const TextureGrabForeground
*source
)
572 Inherited::onCreate(source
);
576 TextureGrabForeground
*pThis
= static_cast<TextureGrabForeground
*>(this);
578 pThis
->setTexture(source
->getTexture());
582 GetFieldHandlePtr
TextureGrabForegroundBase::getHandleTexture (void) const
584 SFUnrecTextureObjChunkPtr::GetHandlePtr
returnValue(
585 new SFUnrecTextureObjChunkPtr::GetHandle(
587 this->getType().getFieldDesc(TextureFieldId
),
588 const_cast<TextureGrabForegroundBase
*>(this)));
593 EditFieldHandlePtr
TextureGrabForegroundBase::editHandleTexture (void)
595 SFUnrecTextureObjChunkPtr::EditHandlePtr
returnValue(
596 new SFUnrecTextureObjChunkPtr::EditHandle(
598 this->getType().getFieldDesc(TextureFieldId
),
601 returnValue
->setSetMethod(
602 boost::bind(&TextureGrabForeground::setTexture
,
603 static_cast<TextureGrabForeground
*>(this), _1
));
605 editSField(TextureFieldMask
);
610 GetFieldHandlePtr
TextureGrabForegroundBase::getHandleAutoResize (void) const
612 SFBool::GetHandlePtr
returnValue(
613 new SFBool::GetHandle(
615 this->getType().getFieldDesc(AutoResizeFieldId
),
616 const_cast<TextureGrabForegroundBase
*>(this)));
621 EditFieldHandlePtr
TextureGrabForegroundBase::editHandleAutoResize (void)
623 SFBool::EditHandlePtr
returnValue(
624 new SFBool::EditHandle(
626 this->getType().getFieldDesc(AutoResizeFieldId
),
630 editSField(AutoResizeFieldMask
);
635 GetFieldHandlePtr
TextureGrabForegroundBase::getHandleBindTarget (void) const
637 SFGLenum::GetHandlePtr
returnValue(
638 new SFGLenum::GetHandle(
640 this->getType().getFieldDesc(BindTargetFieldId
),
641 const_cast<TextureGrabForegroundBase
*>(this)));
646 EditFieldHandlePtr
TextureGrabForegroundBase::editHandleBindTarget (void)
648 SFGLenum::EditHandlePtr
returnValue(
649 new SFGLenum::EditHandle(
651 this->getType().getFieldDesc(BindTargetFieldId
),
655 editSField(BindTargetFieldMask
);
660 GetFieldHandlePtr
TextureGrabForegroundBase::getHandleCopyTarget (void) const
662 SFGLenum::GetHandlePtr
returnValue(
663 new SFGLenum::GetHandle(
665 this->getType().getFieldDesc(CopyTargetFieldId
),
666 const_cast<TextureGrabForegroundBase
*>(this)));
671 EditFieldHandlePtr
TextureGrabForegroundBase::editHandleCopyTarget (void)
673 SFGLenum::EditHandlePtr
returnValue(
674 new SFGLenum::EditHandle(
676 this->getType().getFieldDesc(CopyTargetFieldId
),
680 editSField(CopyTargetFieldMask
);
686 #ifdef OSG_MT_CPTR_ASPECT
687 void TextureGrabForegroundBase::execSyncV( FieldContainer
&oFrom
,
688 ConstFieldMaskArg whichField
,
689 AspectOffsetStore
&oOffsets
,
690 ConstFieldMaskArg syncMode
,
691 const UInt32 uiSyncInfo
)
693 TextureGrabForeground
*pThis
= static_cast<TextureGrabForeground
*>(this);
695 pThis
->execSync(static_cast<TextureGrabForeground
*>(&oFrom
),
704 #ifdef OSG_MT_CPTR_ASPECT
705 FieldContainer
*TextureGrabForegroundBase::createAspectCopy(
706 const FieldContainer
*pRefAspect
) const
708 TextureGrabForeground
*returnValue
;
710 newAspectCopy(returnValue
,
711 dynamic_cast<const TextureGrabForeground
*>(pRefAspect
),
712 dynamic_cast<const TextureGrabForeground
*>(this));
718 void TextureGrabForegroundBase::resolveLinks(void)
720 Inherited::resolveLinks();
722 static_cast<TextureGrabForeground
*>(this)->setTexture(NULL
);