changed: gcc8 base update
[opensg.git] / Source / System / Window / Foreground / OSGFBOGrabForegroundBase.cpp
blob2d9e434fa758515175f518a648fb0af20806afb2
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 FBOGrabForeground!
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 "OSGFrameBufferObject.h" // FrameBufferObject Class
67 #include "OSGFBOGrabForegroundBase.h"
68 #include "OSGFBOGrabForeground.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
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",
103 "ForegroundPtr",
104 FBOGrabForeground::getClassType(),
105 nsOSG);
106 #endif
108 OSG_FIELDTRAITS_GETTYPE_NS(FBOGrabForeground *, nsOSG)
110 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
111 FBOGrabForeground *,
112 nsOSG)
114 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
115 FBOGrabForeground *,
116 nsOSG)
118 /***************************************************************************\
119 * Field Description *
120 \***************************************************************************/
122 void FBOGrabForegroundBase::classDescInserter(TypeObject &oType)
124 FieldDescriptionBase *pDesc = NULL;
127 pDesc = new SFUnrecFrameBufferObjectPtr::Description(
128 SFUnrecFrameBufferObjectPtr::getClassType(),
129 "frameBufferObject",
130 "The FramebufferObject to write to.\n",
131 FrameBufferObjectFieldId, FrameBufferObjectFieldMask,
132 false,
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(),
141 "autoResize",
142 "Automatically resize the fbo when the viewport size changes.\n",
143 AutoResizeFieldId, AutoResizeFieldMask,
144 false,
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(),
156 "NULL",
157 nsOSG, //Namespace
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)),
163 false,
165 "<?xml version=\"1.0\"?>\n"
166 "\n"
167 "<FieldContainer\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"
178 " >\n"
179 " The FBOGrabForeground is used for grabbing a rendered viewport into a FBO.\n"
180 " See \\ref PageSystemWindowForegroundGrab for a description.\n"
181 " <Field\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"
187 "\t >\n"
188 " The FramebufferObject to write to.\n"
189 " </Field>\n"
190 " <Field\n"
191 "\t name=\"autoResize\"\n"
192 "\t type=\"bool\"\n"
193 "\t cardinality=\"single\"\n"
194 "\t visibility=\"external\"\n"
195 "\t defaultValue=\"false\"\n"
196 "\t access=\"public\"\n"
197 "\t >\n"
198 "\tAutomatically resize the fbo when the viewport size changes.\n"
199 " </Field>\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)
209 return _type;
212 const FieldContainerType &FBOGrabForegroundBase::getType(void) const
214 return _type;
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();
285 return returnValue;
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);
333 return fc;
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);
349 return fc;
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);
365 return fc;
368 FBOGrabForeground *FBOGrabForegroundBase::createEmptyLocal(BitVector bFlags)
370 FBOGrabForeground *returnValue;
372 newPtr<FBOGrabForeground>(returnValue, bFlags);
374 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
376 return returnValue;
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();
389 return returnValue;
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;
404 return returnValue;
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;
418 return returnValue;
421 FieldContainerTransitPtr FBOGrabForegroundBase::shallowCopy(void) const
423 FBOGrabForeground *tmpPtr;
425 newPtr(tmpPtr,
426 dynamic_cast<const FBOGrabForeground *>(this),
427 Thread::getCurrentLocalFlags());
429 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
431 FieldContainerTransitPtr returnValue(tmpPtr);
433 return returnValue;
439 /*------------------------- constructors ----------------------------------*/
441 FBOGrabForegroundBase::FBOGrabForegroundBase(void) :
442 Inherited(),
443 _sfFrameBufferObject (NULL),
444 _sfAutoResize (bool(false))
448 FBOGrabForegroundBase::FBOGrabForegroundBase(const FBOGrabForegroundBase &source) :
449 Inherited(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);
466 if(source != NULL)
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)));
482 return returnValue;
485 EditFieldHandlePtr FBOGrabForegroundBase::editHandleFrameBufferObject(void)
487 SFUnrecFrameBufferObjectPtr::EditHandlePtr returnValue(
488 new SFUnrecFrameBufferObjectPtr::EditHandle(
489 &_sfFrameBufferObject,
490 this->getType().getFieldDesc(FrameBufferObjectFieldId),
491 this));
493 returnValue->setSetMethod(
494 boost::bind(&FBOGrabForeground::setFrameBufferObject,
495 static_cast<FBOGrabForeground *>(this), _1));
497 editSField(FrameBufferObjectFieldMask);
499 return returnValue;
502 GetFieldHandlePtr FBOGrabForegroundBase::getHandleAutoResize (void) const
504 SFBool::GetHandlePtr returnValue(
505 new SFBool::GetHandle(
506 &_sfAutoResize,
507 this->getType().getFieldDesc(AutoResizeFieldId),
508 const_cast<FBOGrabForegroundBase *>(this)));
510 return returnValue;
513 EditFieldHandlePtr FBOGrabForegroundBase::editHandleAutoResize (void)
515 SFBool::EditHandlePtr returnValue(
516 new SFBool::EditHandle(
517 &_sfAutoResize,
518 this->getType().getFieldDesc(AutoResizeFieldId),
519 this));
522 editSField(AutoResizeFieldMask);
524 return returnValue;
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),
538 whichField,
539 oOffsets,
540 syncMode,
541 uiSyncInfo);
543 #endif
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));
556 return returnValue;
558 #endif
560 void FBOGrabForegroundBase::resolveLinks(void)
562 Inherited::resolveLinks();
564 static_cast<FBOGrabForeground *>(this)->setFrameBufferObject(NULL);
570 OSG_END_NAMESPACE