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 FBOGrabForeground!
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 "OSGFrameBufferObject.h" // FrameBufferObject Class
67 #include "OSGFBOGrabForegroundBase.h"
68 #include "OSGFBOGrabForeground.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::FBOGrabForeground
79 The FBOGrabForeground is used for grabbing a rendered viewport into a FBO.
80 See \ref PageSystemWindowForegroundGrab for a description.
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var FrameBufferObject * FBOGrabForegroundBase::_sfFrameBufferObject
88 The FramebufferObject to write to.
91 /*! \var bool FBOGrabForegroundBase::_sfAutoResize
92 Automatically resize the fbo when the viewport size changes.
96 /***************************************************************************\
97 * FieldType/FieldTrait Instantiation *
98 \***************************************************************************/
100 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
101 PointerType FieldTraits
<FBOGrabForeground
*, nsOSG
>::_type(
102 "FBOGrabForegroundPtr",
104 FBOGrabForeground::getClassType(),
108 OSG_FIELDTRAITS_GETTYPE_NS(FBOGrabForeground
*, nsOSG
)
110 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
114 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
118 /***************************************************************************\
119 * Field Description *
120 \***************************************************************************/
122 void FBOGrabForegroundBase::classDescInserter(TypeObject
&oType
)
124 FieldDescriptionBase
*pDesc
= NULL
;
127 pDesc
= new SFUnrecFrameBufferObjectPtr::Description(
128 SFUnrecFrameBufferObjectPtr::getClassType(),
130 "The FramebufferObject to write to.\n",
131 FrameBufferObjectFieldId
, FrameBufferObjectFieldMask
,
133 (Field::SFDefaultFlags
| Field::FStdAccess
),
134 static_cast<FieldEditMethodSig
>(&FBOGrabForeground::editHandleFrameBufferObject
),
135 static_cast<FieldGetMethodSig
>(&FBOGrabForeground::getHandleFrameBufferObject
));
137 oType
.addInitialDesc(pDesc
);
139 pDesc
= new SFBool::Description(
140 SFBool::getClassType(),
142 "Automatically resize the fbo when the viewport size changes.\n",
143 AutoResizeFieldId
, AutoResizeFieldMask
,
145 (Field::SFDefaultFlags
| Field::FStdAccess
),
146 static_cast<FieldEditMethodSig
>(&FBOGrabForeground::editHandleAutoResize
),
147 static_cast<FieldGetMethodSig
>(&FBOGrabForeground::getHandleAutoResize
));
149 oType
.addInitialDesc(pDesc
);
153 FBOGrabForegroundBase::TypeObject
FBOGrabForegroundBase::_type(
154 FBOGrabForegroundBase::getClassname(),
155 Inherited::getClassname(),
158 reinterpret_cast<PrototypeCreateF
>(&FBOGrabForegroundBase::createEmptyLocal
),
159 reinterpret_cast<InitContainerF
>(&FBOGrabForeground::initMethod
),
160 reinterpret_cast<ExitContainerF
>(&FBOGrabForeground::exitMethod
),
161 reinterpret_cast<InitalInsertDescFunc
>(
162 reinterpret_cast<void *>(&FBOGrabForeground::classDescInserter
)),
165 "<?xml version=\"1.0\"?>\n"
168 " name=\"FBOGrabForeground\"\n"
169 " parent=\"Foreground\"\n"
170 " library=\"Window\"\n"
171 " pointerfieldtypes=\"both\"\n"
172 " structure=\"concrete\"\n"
173 " systemcomponent=\"true\"\n"
174 " parentsystemcomponent=\"true\"\n"
175 " decoratable=\"false\"\n"
176 " useLocalIncludes=\"false\"\n"
177 " docGroupBase=\"GrpWindowForeground\"\n"
179 " The FBOGrabForeground is used for grabbing a rendered viewport into a FBO.\n"
180 " See \\ref PageSystemWindowForegroundGrab for a description.\n"
182 "\t name=\"frameBufferObject\"\n"
183 "\t type=\"FrameBufferObjectPtr\"\n"
184 "\t cardinality=\"single\"\n"
185 "\t visibility=\"external\"\n"
186 "\t access=\"public\"\n"
188 " The FramebufferObject to write to.\n"
191 "\t name=\"autoResize\"\n"
193 "\t cardinality=\"single\"\n"
194 "\t visibility=\"external\"\n"
195 "\t defaultValue=\"false\"\n"
196 "\t access=\"public\"\n"
198 "\tAutomatically resize the fbo when the viewport size changes.\n"
200 "</FieldContainer>\n",
201 "The FBOGrabForeground is used for grabbing a rendered viewport into a FBO.\n"
202 "See \\ref PageSystemWindowForegroundGrab for a description.\n"
205 /*------------------------------ get -----------------------------------*/
207 FieldContainerType
&FBOGrabForegroundBase::getType(void)
212 const FieldContainerType
&FBOGrabForegroundBase::getType(void) const
217 UInt32
FBOGrabForegroundBase::getContainerSize(void) const
219 return sizeof(FBOGrabForeground
);
222 /*------------------------- decorator get ------------------------------*/
225 //! Get the FBOGrabForeground::_sfFrameBufferObject field.
226 const SFUnrecFrameBufferObjectPtr
*FBOGrabForegroundBase::getSFFrameBufferObject(void) const
228 return &_sfFrameBufferObject
;
231 SFUnrecFrameBufferObjectPtr
*FBOGrabForegroundBase::editSFFrameBufferObject(void)
233 editSField(FrameBufferObjectFieldMask
);
235 return &_sfFrameBufferObject
;
238 //! Get the value of the FBOGrabForeground::_sfFrameBufferObject field.
239 FrameBufferObject
* FBOGrabForegroundBase::getFrameBufferObject(void) const
241 return _sfFrameBufferObject
.getValue();
244 //! Set the value of the FBOGrabForeground::_sfFrameBufferObject field.
245 void FBOGrabForegroundBase::setFrameBufferObject(FrameBufferObject
* const value
)
247 editSField(FrameBufferObjectFieldMask
);
249 _sfFrameBufferObject
.setValue(value
);
253 SFBool
*FBOGrabForegroundBase::editSFAutoResize(void)
255 editSField(AutoResizeFieldMask
);
257 return &_sfAutoResize
;
260 const SFBool
*FBOGrabForegroundBase::getSFAutoResize(void) const
262 return &_sfAutoResize
;
270 /*------------------------------ access -----------------------------------*/
272 SizeT
FBOGrabForegroundBase::getBinSize(ConstFieldMaskArg whichField
)
274 SizeT returnValue
= Inherited::getBinSize(whichField
);
276 if(FieldBits::NoField
!= (FrameBufferObjectFieldMask
& whichField
))
278 returnValue
+= _sfFrameBufferObject
.getBinSize();
280 if(FieldBits::NoField
!= (AutoResizeFieldMask
& whichField
))
282 returnValue
+= _sfAutoResize
.getBinSize();
288 void FBOGrabForegroundBase::copyToBin(BinaryDataHandler
&pMem
,
289 ConstFieldMaskArg whichField
)
291 Inherited::copyToBin(pMem
, whichField
);
293 if(FieldBits::NoField
!= (FrameBufferObjectFieldMask
& whichField
))
295 _sfFrameBufferObject
.copyToBin(pMem
);
297 if(FieldBits::NoField
!= (AutoResizeFieldMask
& whichField
))
299 _sfAutoResize
.copyToBin(pMem
);
303 void FBOGrabForegroundBase::copyFromBin(BinaryDataHandler
&pMem
,
304 ConstFieldMaskArg whichField
)
306 Inherited::copyFromBin(pMem
, whichField
);
308 if(FieldBits::NoField
!= (FrameBufferObjectFieldMask
& whichField
))
310 editSField(FrameBufferObjectFieldMask
);
311 _sfFrameBufferObject
.copyFromBin(pMem
);
313 if(FieldBits::NoField
!= (AutoResizeFieldMask
& whichField
))
315 editSField(AutoResizeFieldMask
);
316 _sfAutoResize
.copyFromBin(pMem
);
320 //! create a new instance of the class
321 FBOGrabForegroundTransitPtr
FBOGrabForegroundBase::createLocal(BitVector bFlags
)
323 FBOGrabForegroundTransitPtr fc
;
325 if(getClassType().getPrototype() != NULL
)
327 FieldContainerTransitPtr tmpPtr
=
328 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
330 fc
= dynamic_pointer_cast
<FBOGrabForeground
>(tmpPtr
);
336 //! create a new instance of the class, copy the container flags
337 FBOGrabForegroundTransitPtr
FBOGrabForegroundBase::createDependent(BitVector bFlags
)
339 FBOGrabForegroundTransitPtr fc
;
341 if(getClassType().getPrototype() != NULL
)
343 FieldContainerTransitPtr tmpPtr
=
344 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
346 fc
= dynamic_pointer_cast
<FBOGrabForeground
>(tmpPtr
);
352 //! create a new instance of the class
353 FBOGrabForegroundTransitPtr
FBOGrabForegroundBase::create(void)
355 FBOGrabForegroundTransitPtr fc
;
357 if(getClassType().getPrototype() != NULL
)
359 FieldContainerTransitPtr tmpPtr
=
360 getClassType().getPrototype()-> shallowCopy();
362 fc
= dynamic_pointer_cast
<FBOGrabForeground
>(tmpPtr
);
368 FBOGrabForeground
*FBOGrabForegroundBase::createEmptyLocal(BitVector bFlags
)
370 FBOGrabForeground
*returnValue
;
372 newPtr
<FBOGrabForeground
>(returnValue
, bFlags
);
374 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
379 //! create an empty new instance of the class, do not copy the prototype
380 FBOGrabForeground
*FBOGrabForegroundBase::createEmpty(void)
382 FBOGrabForeground
*returnValue
;
384 newPtr
<FBOGrabForeground
>(returnValue
, Thread::getCurrentLocalFlags());
386 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
387 ~Thread::getCurrentLocalFlags();
393 FieldContainerTransitPtr
FBOGrabForegroundBase::shallowCopyLocal(
394 BitVector bFlags
) const
396 FBOGrabForeground
*tmpPtr
;
398 newPtr(tmpPtr
, dynamic_cast<const FBOGrabForeground
*>(this), bFlags
);
400 FieldContainerTransitPtr
returnValue(tmpPtr
);
402 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
407 FieldContainerTransitPtr
FBOGrabForegroundBase::shallowCopyDependent(
408 BitVector bFlags
) const
410 FBOGrabForeground
*tmpPtr
;
412 newPtr(tmpPtr
, dynamic_cast<const FBOGrabForeground
*>(this), ~bFlags
);
414 FieldContainerTransitPtr
returnValue(tmpPtr
);
416 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
421 FieldContainerTransitPtr
FBOGrabForegroundBase::shallowCopy(void) const
423 FBOGrabForeground
*tmpPtr
;
426 dynamic_cast<const FBOGrabForeground
*>(this),
427 Thread::getCurrentLocalFlags());
429 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
431 FieldContainerTransitPtr
returnValue(tmpPtr
);
439 /*------------------------- constructors ----------------------------------*/
441 FBOGrabForegroundBase::FBOGrabForegroundBase(void) :
443 _sfFrameBufferObject (NULL
),
444 _sfAutoResize (bool(false))
448 FBOGrabForegroundBase::FBOGrabForegroundBase(const FBOGrabForegroundBase
&source
) :
450 _sfFrameBufferObject (NULL
),
451 _sfAutoResize (source
._sfAutoResize
)
456 /*-------------------------- destructors ----------------------------------*/
458 FBOGrabForegroundBase::~FBOGrabForegroundBase(void)
462 void FBOGrabForegroundBase::onCreate(const FBOGrabForeground
*source
)
464 Inherited::onCreate(source
);
468 FBOGrabForeground
*pThis
= static_cast<FBOGrabForeground
*>(this);
470 pThis
->setFrameBufferObject(source
->getFrameBufferObject());
474 GetFieldHandlePtr
FBOGrabForegroundBase::getHandleFrameBufferObject (void) const
476 SFUnrecFrameBufferObjectPtr::GetHandlePtr
returnValue(
477 new SFUnrecFrameBufferObjectPtr::GetHandle(
478 &_sfFrameBufferObject
,
479 this->getType().getFieldDesc(FrameBufferObjectFieldId
),
480 const_cast<FBOGrabForegroundBase
*>(this)));
485 EditFieldHandlePtr
FBOGrabForegroundBase::editHandleFrameBufferObject(void)
487 SFUnrecFrameBufferObjectPtr::EditHandlePtr
returnValue(
488 new SFUnrecFrameBufferObjectPtr::EditHandle(
489 &_sfFrameBufferObject
,
490 this->getType().getFieldDesc(FrameBufferObjectFieldId
),
493 returnValue
->setSetMethod(
494 boost::bind(&FBOGrabForeground::setFrameBufferObject
,
495 static_cast<FBOGrabForeground
*>(this), _1
));
497 editSField(FrameBufferObjectFieldMask
);
502 GetFieldHandlePtr
FBOGrabForegroundBase::getHandleAutoResize (void) const
504 SFBool::GetHandlePtr
returnValue(
505 new SFBool::GetHandle(
507 this->getType().getFieldDesc(AutoResizeFieldId
),
508 const_cast<FBOGrabForegroundBase
*>(this)));
513 EditFieldHandlePtr
FBOGrabForegroundBase::editHandleAutoResize (void)
515 SFBool::EditHandlePtr
returnValue(
516 new SFBool::EditHandle(
518 this->getType().getFieldDesc(AutoResizeFieldId
),
522 editSField(AutoResizeFieldMask
);
528 #ifdef OSG_MT_CPTR_ASPECT
529 void FBOGrabForegroundBase::execSyncV( FieldContainer
&oFrom
,
530 ConstFieldMaskArg whichField
,
531 AspectOffsetStore
&oOffsets
,
532 ConstFieldMaskArg syncMode
,
533 const UInt32 uiSyncInfo
)
535 FBOGrabForeground
*pThis
= static_cast<FBOGrabForeground
*>(this);
537 pThis
->execSync(static_cast<FBOGrabForeground
*>(&oFrom
),
546 #ifdef OSG_MT_CPTR_ASPECT
547 FieldContainer
*FBOGrabForegroundBase::createAspectCopy(
548 const FieldContainer
*pRefAspect
) const
550 FBOGrabForeground
*returnValue
;
552 newAspectCopy(returnValue
,
553 dynamic_cast<const FBOGrabForeground
*>(pRefAspect
),
554 dynamic_cast<const FBOGrabForeground
*>(this));
560 void FBOGrabForegroundBase::resolveLinks(void)
562 Inherited::resolveLinks();
564 static_cast<FBOGrabForeground
*>(this)->setFrameBufferObject(NULL
);