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 **
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 "OSGFBOViewportBase.h"
68 #include "OSGFBOViewport.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::FBOViewport
79 \ingroup GrpSystemWindowViewports
81 A viewport using a framebuffer object for output.
84 /***************************************************************************\
85 * Field Documentation *
86 \***************************************************************************/
88 /*! \var FrameBufferObject * FBOViewportBase::_sfFrameBufferObject
89 FramebufferObject to write to.
93 /***************************************************************************\
94 * FieldType/FieldTrait Instantiation *
95 \***************************************************************************/
97 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
98 PointerType FieldTraits
<FBOViewport
*, nsOSG
>::_type(
101 FBOViewport::getClassType(),
105 OSG_FIELDTRAITS_GETTYPE_NS(FBOViewport
*, nsOSG
)
107 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
111 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
115 /***************************************************************************\
116 * Field Description *
117 \***************************************************************************/
119 void FBOViewportBase::classDescInserter(TypeObject
&oType
)
121 FieldDescriptionBase
*pDesc
= NULL
;
124 pDesc
= new SFUnrecFrameBufferObjectPtr::Description(
125 SFUnrecFrameBufferObjectPtr::getClassType(),
127 "FramebufferObject to write to.\n",
128 FrameBufferObjectFieldId
, FrameBufferObjectFieldMask
,
130 (Field::SFDefaultFlags
| Field::FStdAccess
),
131 static_cast<FieldEditMethodSig
>(&FBOViewport::editHandleFrameBufferObject
),
132 static_cast<FieldGetMethodSig
>(&FBOViewport::getHandleFrameBufferObject
));
134 oType
.addInitialDesc(pDesc
);
138 FBOViewportBase::TypeObject
FBOViewportBase::_type(
139 FBOViewportBase::getClassname(),
140 Inherited::getClassname(),
143 reinterpret_cast<PrototypeCreateF
>(&FBOViewportBase::createEmptyLocal
),
144 reinterpret_cast<InitContainerF
>(&FBOViewport::initMethod
),
145 reinterpret_cast<ExitContainerF
>(&FBOViewport::exitMethod
),
146 reinterpret_cast<InitalInsertDescFunc
>(
147 reinterpret_cast<void *>(&FBOViewport::classDescInserter
)),
150 "<?xml version=\"1.0\"?>\n"
153 " name=\"FBOViewport\"\n"
154 " parent=\"Viewport\"\n"
155 " library=\"System\"\n"
156 " pointerfieldtypes=\"both\"\n"
157 " structure=\"concrete\"\n"
158 " systemcomponent=\"true\"\n"
159 " parentsystemcomponent=\"true\"\n"
160 " decoratable=\"false\"\n"
161 " docGroupBase=\"GrpSystemWindowFBO\"\n"
163 "\\ingroup GrpSystemWindowViewports\n"
165 "A viewport using a framebuffer object for output.\n"
167 "\t\tname=\"frameBufferObject\"\n"
168 "\t\ttype=\"FrameBufferObjectPtr\"\n"
169 "\t\tcardinality=\"single\"\n"
170 "\t\tvisibility=\"external\"\n"
171 "\t\taccess=\"public\"\n"
173 " FramebufferObject to write to.\n"
175 "</FieldContainer>\n",
176 "\\ingroup GrpSystemWindowViewports\n"
178 "A viewport using a framebuffer object for output.\n"
181 /*------------------------------ get -----------------------------------*/
183 FieldContainerType
&FBOViewportBase::getType(void)
188 const FieldContainerType
&FBOViewportBase::getType(void) const
193 UInt32
FBOViewportBase::getContainerSize(void) const
195 return sizeof(FBOViewport
);
198 /*------------------------- decorator get ------------------------------*/
201 //! Get the FBOViewport::_sfFrameBufferObject field.
202 const SFUnrecFrameBufferObjectPtr
*FBOViewportBase::getSFFrameBufferObject(void) const
204 return &_sfFrameBufferObject
;
207 SFUnrecFrameBufferObjectPtr
*FBOViewportBase::editSFFrameBufferObject(void)
209 editSField(FrameBufferObjectFieldMask
);
211 return &_sfFrameBufferObject
;
214 //! Get the value of the FBOViewport::_sfFrameBufferObject field.
215 FrameBufferObject
* FBOViewportBase::getFrameBufferObject(void) const
217 return _sfFrameBufferObject
.getValue();
220 //! Set the value of the FBOViewport::_sfFrameBufferObject field.
221 void FBOViewportBase::setFrameBufferObject(FrameBufferObject
* const value
)
223 editSField(FrameBufferObjectFieldMask
);
225 _sfFrameBufferObject
.setValue(value
);
233 /*------------------------------ access -----------------------------------*/
235 SizeT
FBOViewportBase::getBinSize(ConstFieldMaskArg whichField
)
237 SizeT returnValue
= Inherited::getBinSize(whichField
);
239 if(FieldBits::NoField
!= (FrameBufferObjectFieldMask
& whichField
))
241 returnValue
+= _sfFrameBufferObject
.getBinSize();
247 void FBOViewportBase::copyToBin(BinaryDataHandler
&pMem
,
248 ConstFieldMaskArg whichField
)
250 Inherited::copyToBin(pMem
, whichField
);
252 if(FieldBits::NoField
!= (FrameBufferObjectFieldMask
& whichField
))
254 _sfFrameBufferObject
.copyToBin(pMem
);
258 void FBOViewportBase::copyFromBin(BinaryDataHandler
&pMem
,
259 ConstFieldMaskArg whichField
)
261 Inherited::copyFromBin(pMem
, whichField
);
263 if(FieldBits::NoField
!= (FrameBufferObjectFieldMask
& whichField
))
265 editSField(FrameBufferObjectFieldMask
);
266 _sfFrameBufferObject
.copyFromBin(pMem
);
270 //! create a new instance of the class
271 FBOViewportTransitPtr
FBOViewportBase::createLocal(BitVector bFlags
)
273 FBOViewportTransitPtr fc
;
275 if(getClassType().getPrototype() != NULL
)
277 FieldContainerTransitPtr tmpPtr
=
278 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
280 fc
= dynamic_pointer_cast
<FBOViewport
>(tmpPtr
);
286 //! create a new instance of the class, copy the container flags
287 FBOViewportTransitPtr
FBOViewportBase::createDependent(BitVector bFlags
)
289 FBOViewportTransitPtr fc
;
291 if(getClassType().getPrototype() != NULL
)
293 FieldContainerTransitPtr tmpPtr
=
294 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
296 fc
= dynamic_pointer_cast
<FBOViewport
>(tmpPtr
);
302 //! create a new instance of the class
303 FBOViewportTransitPtr
FBOViewportBase::create(void)
305 FBOViewportTransitPtr fc
;
307 if(getClassType().getPrototype() != NULL
)
309 FieldContainerTransitPtr tmpPtr
=
310 getClassType().getPrototype()-> shallowCopy();
312 fc
= dynamic_pointer_cast
<FBOViewport
>(tmpPtr
);
318 FBOViewport
*FBOViewportBase::createEmptyLocal(BitVector bFlags
)
320 FBOViewport
*returnValue
;
322 newPtr
<FBOViewport
>(returnValue
, bFlags
);
324 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
329 //! create an empty new instance of the class, do not copy the prototype
330 FBOViewport
*FBOViewportBase::createEmpty(void)
332 FBOViewport
*returnValue
;
334 newPtr
<FBOViewport
>(returnValue
, Thread::getCurrentLocalFlags());
336 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
337 ~Thread::getCurrentLocalFlags();
343 FieldContainerTransitPtr
FBOViewportBase::shallowCopyLocal(
344 BitVector bFlags
) const
348 newPtr(tmpPtr
, dynamic_cast<const FBOViewport
*>(this), bFlags
);
350 FieldContainerTransitPtr
returnValue(tmpPtr
);
352 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
357 FieldContainerTransitPtr
FBOViewportBase::shallowCopyDependent(
358 BitVector bFlags
) const
362 newPtr(tmpPtr
, dynamic_cast<const FBOViewport
*>(this), ~bFlags
);
364 FieldContainerTransitPtr
returnValue(tmpPtr
);
366 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
371 FieldContainerTransitPtr
FBOViewportBase::shallowCopy(void) const
376 dynamic_cast<const FBOViewport
*>(this),
377 Thread::getCurrentLocalFlags());
379 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
381 FieldContainerTransitPtr
returnValue(tmpPtr
);
389 /*------------------------- constructors ----------------------------------*/
391 FBOViewportBase::FBOViewportBase(void) :
393 _sfFrameBufferObject (NULL
)
397 FBOViewportBase::FBOViewportBase(const FBOViewportBase
&source
) :
399 _sfFrameBufferObject (NULL
)
404 /*-------------------------- destructors ----------------------------------*/
406 FBOViewportBase::~FBOViewportBase(void)
410 void FBOViewportBase::onCreate(const FBOViewport
*source
)
412 Inherited::onCreate(source
);
416 FBOViewport
*pThis
= static_cast<FBOViewport
*>(this);
418 pThis
->setFrameBufferObject(source
->getFrameBufferObject());
422 GetFieldHandlePtr
FBOViewportBase::getHandleFrameBufferObject (void) const
424 SFUnrecFrameBufferObjectPtr::GetHandlePtr
returnValue(
425 new SFUnrecFrameBufferObjectPtr::GetHandle(
426 &_sfFrameBufferObject
,
427 this->getType().getFieldDesc(FrameBufferObjectFieldId
),
428 const_cast<FBOViewportBase
*>(this)));
433 EditFieldHandlePtr
FBOViewportBase::editHandleFrameBufferObject(void)
435 SFUnrecFrameBufferObjectPtr::EditHandlePtr
returnValue(
436 new SFUnrecFrameBufferObjectPtr::EditHandle(
437 &_sfFrameBufferObject
,
438 this->getType().getFieldDesc(FrameBufferObjectFieldId
),
441 returnValue
->setSetMethod(
442 boost::bind(&FBOViewport::setFrameBufferObject
,
443 static_cast<FBOViewport
*>(this), _1
));
445 editSField(FrameBufferObjectFieldMask
);
451 #ifdef OSG_MT_CPTR_ASPECT
452 void FBOViewportBase::execSyncV( FieldContainer
&oFrom
,
453 ConstFieldMaskArg whichField
,
454 AspectOffsetStore
&oOffsets
,
455 ConstFieldMaskArg syncMode
,
456 const UInt32 uiSyncInfo
)
458 FBOViewport
*pThis
= static_cast<FBOViewport
*>(this);
460 pThis
->execSync(static_cast<FBOViewport
*>(&oFrom
),
469 #ifdef OSG_MT_CPTR_ASPECT
470 FieldContainer
*FBOViewportBase::createAspectCopy(
471 const FieldContainer
*pRefAspect
) const
473 FBOViewport
*returnValue
;
475 newAspectCopy(returnValue
,
476 dynamic_cast<const FBOViewport
*>(pRefAspect
),
477 dynamic_cast<const FBOViewport
*>(this));
483 void FBOViewportBase::resolveLinks(void)
485 Inherited::resolveLinks();
487 static_cast<FBOViewport
*>(this)->setFrameBufferObject(NULL
);