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 LayeredTextureBuffer!
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 "OSGLayeredTextureBufferBase.h"
68 #include "OSGLayeredTextureBuffer.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::LayeredTextureBuffer
79 Texture buffer. Wraps support to binding a framebuffer attachment to an OpenSG texture object.
81 See FramebufferTexture1/2/3DEXT.
84 /***************************************************************************\
85 * Field Documentation *
86 \***************************************************************************/
88 /*! \var TextureObjChunk * LayeredTextureBufferBase::_sfTexture
89 The texture object to target.
92 /*! \var GLenum LayeredTextureBufferBase::_sfTexTarget
93 If specified, this is the target value for FramebufferTextureXDEXT.
94 If GL_NONE, automatically determined.
97 /*! \var UInt32 LayeredTextureBufferBase::_sfLevel
98 The mipmap level in the texture to target.
101 /*! \var UInt32 LayeredTextureBufferBase::_sfZoffset
106 /***************************************************************************\
107 * FieldType/FieldTrait Instantiation *
108 \***************************************************************************/
110 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
111 PointerType FieldTraits
<LayeredTextureBuffer
*, nsOSG
>::_type(
112 "LayeredTextureBufferPtr",
113 "FrameBufferAttachmentPtr",
114 LayeredTextureBuffer::getClassType(),
118 OSG_FIELDTRAITS_GETTYPE_NS(LayeredTextureBuffer
*, nsOSG
)
120 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
121 LayeredTextureBuffer
*,
124 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
125 LayeredTextureBuffer
*,
128 /***************************************************************************\
129 * Field Description *
130 \***************************************************************************/
132 void LayeredTextureBufferBase::classDescInserter(TypeObject
&oType
)
134 FieldDescriptionBase
*pDesc
= NULL
;
137 pDesc
= new SFUnrecTextureObjChunkPtr::Description(
138 SFUnrecTextureObjChunkPtr::getClassType(),
140 "The texture object to target.\n",
141 TextureFieldId
, TextureFieldMask
,
143 (Field::SFDefaultFlags
| Field::FStdAccess
),
144 static_cast<FieldEditMethodSig
>(&LayeredTextureBuffer::editHandleTexture
),
145 static_cast<FieldGetMethodSig
>(&LayeredTextureBuffer::getHandleTexture
));
147 oType
.addInitialDesc(pDesc
);
149 pDesc
= new SFGLenum::Description(
150 SFGLenum::getClassType(),
152 "If specified, this is the target value for FramebufferTextureXDEXT.\n"
153 "If GL_NONE, automatically determined.\n",
154 TexTargetFieldId
, TexTargetFieldMask
,
156 (Field::SFDefaultFlags
| Field::FStdAccess
),
157 static_cast<FieldEditMethodSig
>(&LayeredTextureBuffer::editHandleTexTarget
),
158 static_cast<FieldGetMethodSig
>(&LayeredTextureBuffer::getHandleTexTarget
));
160 oType
.addInitialDesc(pDesc
);
162 pDesc
= new SFUInt32::Description(
163 SFUInt32::getClassType(),
165 "The mipmap level in the texture to target.\n",
166 LevelFieldId
, LevelFieldMask
,
168 (Field::SFDefaultFlags
| Field::FStdAccess
),
169 static_cast<FieldEditMethodSig
>(&LayeredTextureBuffer::editHandleLevel
),
170 static_cast<FieldGetMethodSig
>(&LayeredTextureBuffer::getHandleLevel
));
172 oType
.addInitialDesc(pDesc
);
174 pDesc
= new SFUInt32::Description(
175 SFUInt32::getClassType(),
178 ZoffsetFieldId
, ZoffsetFieldMask
,
180 (Field::SFDefaultFlags
| Field::FStdAccess
),
181 static_cast<FieldEditMethodSig
>(&LayeredTextureBuffer::editHandleZoffset
),
182 static_cast<FieldGetMethodSig
>(&LayeredTextureBuffer::getHandleZoffset
));
184 oType
.addInitialDesc(pDesc
);
188 LayeredTextureBufferBase::TypeObject
LayeredTextureBufferBase::_type(
189 LayeredTextureBufferBase::getClassname(),
190 Inherited::getClassname(),
191 "LayeredTextureBuffer",
193 reinterpret_cast<PrototypeCreateF
>(&LayeredTextureBufferBase::createEmptyLocal
),
194 reinterpret_cast<InitContainerF
>(&LayeredTextureBuffer::initMethod
),
195 reinterpret_cast<ExitContainerF
>(&LayeredTextureBuffer::exitMethod
),
196 reinterpret_cast<InitalInsertDescFunc
>(
197 reinterpret_cast<void *>(&LayeredTextureBuffer::classDescInserter
)),
200 "<?xml version=\"1.0\"?>\n"
203 " name=\"LayeredTextureBuffer\"\n"
204 " parent=\"FrameBufferAttachment\"\n"
205 " library=\"System\"\n"
206 " pointerfieldtypes=\"both\"\n"
207 " structure=\"concrete\"\n"
208 " systemcomponent=\"true\"\n"
209 " parentsystemcomponent=\"true\"\n"
210 " decoratable=\"false\"\n"
211 " docGroupBase=\"GrpSystemWindowFBO\"\n"
213 " Texture buffer. Wraps support to binding a framebuffer attachment to an OpenSG texture object.\n"
215 " See FramebufferTexture1/2/3DEXT.\n"
217 " name=\"texture\"\n"
218 " type=\"TextureObjChunkPtr\"\n"
219 " cardinality=\"single\"\n"
220 " visibility=\"external\"\n"
221 " access=\"public\"\n"
223 " The texture object to target.\n"
226 " name=\"texTarget\"\n"
228 " cardinality=\"single\"\n"
229 " visibility=\"external\"\n"
230 " access=\"public\"\n"
231 " defaultValue=\"GL_NONE\"\n"
233 " If specified, this is the target value for FramebufferTextureXDEXT.\n"
234 " If GL_NONE, automatically determined.\n"
239 " cardinality=\"single\"\n"
240 " visibility=\"external\"\n"
241 " access=\"public\"\n"
242 " defaultValue=\"0\"\n"
244 " The mipmap level in the texture to target.\n"
247 " name=\"zoffset\"\n"
249 " cardinality=\"single\"\n"
250 " visibility=\"external\"\n"
251 " access=\"public\"\n"
252 " defaultValue=\"0\"\n"
256 "</FieldContainer>\n",
257 "Texture buffer. Wraps support to binding a framebuffer attachment to an OpenSG texture object.\n"
259 "See FramebufferTexture1/2/3DEXT.\n"
262 /*------------------------------ get -----------------------------------*/
264 FieldContainerType
&LayeredTextureBufferBase::getType(void)
269 const FieldContainerType
&LayeredTextureBufferBase::getType(void) const
274 UInt32
LayeredTextureBufferBase::getContainerSize(void) const
276 return sizeof(LayeredTextureBuffer
);
279 /*------------------------- decorator get ------------------------------*/
282 //! Get the LayeredTextureBuffer::_sfTexture field.
283 const SFUnrecTextureObjChunkPtr
*LayeredTextureBufferBase::getSFTexture(void) const
288 SFUnrecTextureObjChunkPtr
*LayeredTextureBufferBase::editSFTexture (void)
290 editSField(TextureFieldMask
);
295 //! Get the value of the LayeredTextureBuffer::_sfTexture field.
296 TextureObjChunk
* LayeredTextureBufferBase::getTexture(void) const
298 return _sfTexture
.getValue();
301 //! Set the value of the LayeredTextureBuffer::_sfTexture field.
302 void LayeredTextureBufferBase::setTexture(TextureObjChunk
* const value
)
304 editSField(TextureFieldMask
);
306 _sfTexture
.setValue(value
);
310 SFGLenum
*LayeredTextureBufferBase::editSFTexTarget(void)
312 editSField(TexTargetFieldMask
);
314 return &_sfTexTarget
;
317 const SFGLenum
*LayeredTextureBufferBase::getSFTexTarget(void) const
319 return &_sfTexTarget
;
323 SFUInt32
*LayeredTextureBufferBase::editSFLevel(void)
325 editSField(LevelFieldMask
);
330 const SFUInt32
*LayeredTextureBufferBase::getSFLevel(void) const
336 SFUInt32
*LayeredTextureBufferBase::editSFZoffset(void)
338 editSField(ZoffsetFieldMask
);
343 const SFUInt32
*LayeredTextureBufferBase::getSFZoffset(void) const
353 /*------------------------------ access -----------------------------------*/
355 SizeT
LayeredTextureBufferBase::getBinSize(ConstFieldMaskArg whichField
)
357 SizeT returnValue
= Inherited::getBinSize(whichField
);
359 if(FieldBits::NoField
!= (TextureFieldMask
& whichField
))
361 returnValue
+= _sfTexture
.getBinSize();
363 if(FieldBits::NoField
!= (TexTargetFieldMask
& whichField
))
365 returnValue
+= _sfTexTarget
.getBinSize();
367 if(FieldBits::NoField
!= (LevelFieldMask
& whichField
))
369 returnValue
+= _sfLevel
.getBinSize();
371 if(FieldBits::NoField
!= (ZoffsetFieldMask
& whichField
))
373 returnValue
+= _sfZoffset
.getBinSize();
379 void LayeredTextureBufferBase::copyToBin(BinaryDataHandler
&pMem
,
380 ConstFieldMaskArg whichField
)
382 Inherited::copyToBin(pMem
, whichField
);
384 if(FieldBits::NoField
!= (TextureFieldMask
& whichField
))
386 _sfTexture
.copyToBin(pMem
);
388 if(FieldBits::NoField
!= (TexTargetFieldMask
& whichField
))
390 _sfTexTarget
.copyToBin(pMem
);
392 if(FieldBits::NoField
!= (LevelFieldMask
& whichField
))
394 _sfLevel
.copyToBin(pMem
);
396 if(FieldBits::NoField
!= (ZoffsetFieldMask
& whichField
))
398 _sfZoffset
.copyToBin(pMem
);
402 void LayeredTextureBufferBase::copyFromBin(BinaryDataHandler
&pMem
,
403 ConstFieldMaskArg whichField
)
405 Inherited::copyFromBin(pMem
, whichField
);
407 if(FieldBits::NoField
!= (TextureFieldMask
& whichField
))
409 editSField(TextureFieldMask
);
410 _sfTexture
.copyFromBin(pMem
);
412 if(FieldBits::NoField
!= (TexTargetFieldMask
& whichField
))
414 editSField(TexTargetFieldMask
);
415 _sfTexTarget
.copyFromBin(pMem
);
417 if(FieldBits::NoField
!= (LevelFieldMask
& whichField
))
419 editSField(LevelFieldMask
);
420 _sfLevel
.copyFromBin(pMem
);
422 if(FieldBits::NoField
!= (ZoffsetFieldMask
& whichField
))
424 editSField(ZoffsetFieldMask
);
425 _sfZoffset
.copyFromBin(pMem
);
429 //! create a new instance of the class
430 LayeredTextureBufferTransitPtr
LayeredTextureBufferBase::createLocal(BitVector bFlags
)
432 LayeredTextureBufferTransitPtr fc
;
434 if(getClassType().getPrototype() != NULL
)
436 FieldContainerTransitPtr tmpPtr
=
437 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
439 fc
= dynamic_pointer_cast
<LayeredTextureBuffer
>(tmpPtr
);
445 //! create a new instance of the class, copy the container flags
446 LayeredTextureBufferTransitPtr
LayeredTextureBufferBase::createDependent(BitVector bFlags
)
448 LayeredTextureBufferTransitPtr fc
;
450 if(getClassType().getPrototype() != NULL
)
452 FieldContainerTransitPtr tmpPtr
=
453 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
455 fc
= dynamic_pointer_cast
<LayeredTextureBuffer
>(tmpPtr
);
461 //! create a new instance of the class
462 LayeredTextureBufferTransitPtr
LayeredTextureBufferBase::create(void)
464 LayeredTextureBufferTransitPtr fc
;
466 if(getClassType().getPrototype() != NULL
)
468 FieldContainerTransitPtr tmpPtr
=
469 getClassType().getPrototype()-> shallowCopy();
471 fc
= dynamic_pointer_cast
<LayeredTextureBuffer
>(tmpPtr
);
477 LayeredTextureBuffer
*LayeredTextureBufferBase::createEmptyLocal(BitVector bFlags
)
479 LayeredTextureBuffer
*returnValue
;
481 newPtr
<LayeredTextureBuffer
>(returnValue
, bFlags
);
483 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
488 //! create an empty new instance of the class, do not copy the prototype
489 LayeredTextureBuffer
*LayeredTextureBufferBase::createEmpty(void)
491 LayeredTextureBuffer
*returnValue
;
493 newPtr
<LayeredTextureBuffer
>(returnValue
, Thread::getCurrentLocalFlags());
495 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
496 ~Thread::getCurrentLocalFlags();
502 FieldContainerTransitPtr
LayeredTextureBufferBase::shallowCopyLocal(
503 BitVector bFlags
) const
505 LayeredTextureBuffer
*tmpPtr
;
507 newPtr(tmpPtr
, dynamic_cast<const LayeredTextureBuffer
*>(this), bFlags
);
509 FieldContainerTransitPtr
returnValue(tmpPtr
);
511 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
516 FieldContainerTransitPtr
LayeredTextureBufferBase::shallowCopyDependent(
517 BitVector bFlags
) const
519 LayeredTextureBuffer
*tmpPtr
;
521 newPtr(tmpPtr
, dynamic_cast<const LayeredTextureBuffer
*>(this), ~bFlags
);
523 FieldContainerTransitPtr
returnValue(tmpPtr
);
525 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
530 FieldContainerTransitPtr
LayeredTextureBufferBase::shallowCopy(void) const
532 LayeredTextureBuffer
*tmpPtr
;
535 dynamic_cast<const LayeredTextureBuffer
*>(this),
536 Thread::getCurrentLocalFlags());
538 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
540 FieldContainerTransitPtr
returnValue(tmpPtr
);
548 /*------------------------- constructors ----------------------------------*/
550 LayeredTextureBufferBase::LayeredTextureBufferBase(void) :
553 _sfTexTarget (GLenum(GL_NONE
)),
554 _sfLevel (UInt32(0)),
555 _sfZoffset (UInt32(0))
559 LayeredTextureBufferBase::LayeredTextureBufferBase(const LayeredTextureBufferBase
&source
) :
562 _sfTexTarget (source
._sfTexTarget
),
563 _sfLevel (source
._sfLevel
),
564 _sfZoffset (source
._sfZoffset
)
569 /*-------------------------- destructors ----------------------------------*/
571 LayeredTextureBufferBase::~LayeredTextureBufferBase(void)
575 void LayeredTextureBufferBase::onCreate(const LayeredTextureBuffer
*source
)
577 Inherited::onCreate(source
);
581 LayeredTextureBuffer
*pThis
= static_cast<LayeredTextureBuffer
*>(this);
583 pThis
->setTexture(source
->getTexture());
587 GetFieldHandlePtr
LayeredTextureBufferBase::getHandleTexture (void) const
589 SFUnrecTextureObjChunkPtr::GetHandlePtr
returnValue(
590 new SFUnrecTextureObjChunkPtr::GetHandle(
592 this->getType().getFieldDesc(TextureFieldId
),
593 const_cast<LayeredTextureBufferBase
*>(this)));
598 EditFieldHandlePtr
LayeredTextureBufferBase::editHandleTexture (void)
600 SFUnrecTextureObjChunkPtr::EditHandlePtr
returnValue(
601 new SFUnrecTextureObjChunkPtr::EditHandle(
603 this->getType().getFieldDesc(TextureFieldId
),
606 returnValue
->setSetMethod(
607 boost::bind(&LayeredTextureBuffer::setTexture
,
608 static_cast<LayeredTextureBuffer
*>(this), _1
));
610 editSField(TextureFieldMask
);
615 GetFieldHandlePtr
LayeredTextureBufferBase::getHandleTexTarget (void) const
617 SFGLenum::GetHandlePtr
returnValue(
618 new SFGLenum::GetHandle(
620 this->getType().getFieldDesc(TexTargetFieldId
),
621 const_cast<LayeredTextureBufferBase
*>(this)));
626 EditFieldHandlePtr
LayeredTextureBufferBase::editHandleTexTarget (void)
628 SFGLenum::EditHandlePtr
returnValue(
629 new SFGLenum::EditHandle(
631 this->getType().getFieldDesc(TexTargetFieldId
),
635 editSField(TexTargetFieldMask
);
640 GetFieldHandlePtr
LayeredTextureBufferBase::getHandleLevel (void) const
642 SFUInt32::GetHandlePtr
returnValue(
643 new SFUInt32::GetHandle(
645 this->getType().getFieldDesc(LevelFieldId
),
646 const_cast<LayeredTextureBufferBase
*>(this)));
651 EditFieldHandlePtr
LayeredTextureBufferBase::editHandleLevel (void)
653 SFUInt32::EditHandlePtr
returnValue(
654 new SFUInt32::EditHandle(
656 this->getType().getFieldDesc(LevelFieldId
),
660 editSField(LevelFieldMask
);
665 GetFieldHandlePtr
LayeredTextureBufferBase::getHandleZoffset (void) const
667 SFUInt32::GetHandlePtr
returnValue(
668 new SFUInt32::GetHandle(
670 this->getType().getFieldDesc(ZoffsetFieldId
),
671 const_cast<LayeredTextureBufferBase
*>(this)));
676 EditFieldHandlePtr
LayeredTextureBufferBase::editHandleZoffset (void)
678 SFUInt32::EditHandlePtr
returnValue(
679 new SFUInt32::EditHandle(
681 this->getType().getFieldDesc(ZoffsetFieldId
),
685 editSField(ZoffsetFieldMask
);
691 #ifdef OSG_MT_CPTR_ASPECT
692 void LayeredTextureBufferBase::execSyncV( FieldContainer
&oFrom
,
693 ConstFieldMaskArg whichField
,
694 AspectOffsetStore
&oOffsets
,
695 ConstFieldMaskArg syncMode
,
696 const UInt32 uiSyncInfo
)
698 LayeredTextureBuffer
*pThis
= static_cast<LayeredTextureBuffer
*>(this);
700 pThis
->execSync(static_cast<LayeredTextureBuffer
*>(&oFrom
),
709 #ifdef OSG_MT_CPTR_ASPECT
710 FieldContainer
*LayeredTextureBufferBase::createAspectCopy(
711 const FieldContainer
*pRefAspect
) const
713 LayeredTextureBuffer
*returnValue
;
715 newAspectCopy(returnValue
,
716 dynamic_cast<const LayeredTextureBuffer
*>(pRefAspect
),
717 dynamic_cast<const LayeredTextureBuffer
*>(this));
723 void LayeredTextureBufferBase::resolveLinks(void)
725 Inherited::resolveLinks();
727 static_cast<LayeredTextureBuffer
*>(this)->setTexture(NULL
);