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 TextureBuffer!
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 "OSGTextureBufferBase.h"
68 #include "OSGTextureBuffer.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::TextureBuffer
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 * TextureBufferBase::_sfTexture
89 The texture object to target.
92 /*! \var GLenum TextureBufferBase::_sfTexTarget
93 If specified, this is the target value for FramebufferTextureXDEXT.
94 If GL_NONE, automatically determined.
97 /*! \var UInt32 TextureBufferBase::_sfLevel
98 The mipmap level in the texture to target.
101 /*! \var UInt32 TextureBufferBase::_sfLayer
102 The layer specifies the layer of a 2-dimensional image within a 3-dimensional texture.
106 /***************************************************************************\
107 * FieldType/FieldTrait Instantiation *
108 \***************************************************************************/
110 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
111 PointerType FieldTraits
<TextureBuffer
*, nsOSG
>::_type(
113 "FrameBufferAttachmentPtr",
114 TextureBuffer::getClassType(),
118 OSG_FIELDTRAITS_GETTYPE_NS(TextureBuffer
*, nsOSG
)
120 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
124 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
128 /***************************************************************************\
129 * Field Description *
130 \***************************************************************************/
132 void TextureBufferBase::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
>(&TextureBuffer::editHandleTexture
),
145 static_cast<FieldGetMethodSig
>(&TextureBuffer::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
>(&TextureBuffer::editHandleTexTarget
),
158 static_cast<FieldGetMethodSig
>(&TextureBuffer::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
>(&TextureBuffer::editHandleLevel
),
170 static_cast<FieldGetMethodSig
>(&TextureBuffer::getHandleLevel
));
172 oType
.addInitialDesc(pDesc
);
174 pDesc
= new SFUInt32::Description(
175 SFUInt32::getClassType(),
177 "The layer specifies the layer of a 2-dimensional image within a 3-dimensional texture.\n",
178 LayerFieldId
, LayerFieldMask
,
180 (Field::SFDefaultFlags
| Field::FStdAccess
),
181 static_cast<FieldEditMethodSig
>(&TextureBuffer::editHandleLayer
),
182 static_cast<FieldGetMethodSig
>(&TextureBuffer::getHandleLayer
));
184 oType
.addInitialDesc(pDesc
);
188 TextureBufferBase::TypeObject
TextureBufferBase::_type(
189 TextureBufferBase::getClassname(),
190 Inherited::getClassname(),
193 reinterpret_cast<PrototypeCreateF
>(&TextureBufferBase::createEmptyLocal
),
194 reinterpret_cast<InitContainerF
>(&TextureBuffer::initMethod
),
195 reinterpret_cast<ExitContainerF
>(&TextureBuffer::exitMethod
),
196 reinterpret_cast<InitalInsertDescFunc
>(
197 reinterpret_cast<void *>(&TextureBuffer::classDescInserter
)),
200 "<?xml version=\"1.0\"?>\n"
203 " name=\"TextureBuffer\"\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"
249 " cardinality=\"single\"\n"
250 " visibility=\"external\"\n"
251 " access=\"public\"\n"
252 " defaultValue=\"0\"\n"
254 " The layer specifies the layer of a 2-dimensional image within a 3-dimensional texture.\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
&TextureBufferBase::getType(void)
269 const FieldContainerType
&TextureBufferBase::getType(void) const
274 UInt32
TextureBufferBase::getContainerSize(void) const
276 return sizeof(TextureBuffer
);
279 /*------------------------- decorator get ------------------------------*/
282 //! Get the TextureBuffer::_sfTexture field.
283 const SFUnrecTextureObjChunkPtr
*TextureBufferBase::getSFTexture(void) const
288 SFUnrecTextureObjChunkPtr
*TextureBufferBase::editSFTexture (void)
290 editSField(TextureFieldMask
);
295 //! Get the value of the TextureBuffer::_sfTexture field.
296 TextureObjChunk
* TextureBufferBase::getTexture(void) const
298 return _sfTexture
.getValue();
301 //! Set the value of the TextureBuffer::_sfTexture field.
302 void TextureBufferBase::setTexture(TextureObjChunk
* const value
)
304 editSField(TextureFieldMask
);
306 _sfTexture
.setValue(value
);
310 SFGLenum
*TextureBufferBase::editSFTexTarget(void)
312 editSField(TexTargetFieldMask
);
314 return &_sfTexTarget
;
317 const SFGLenum
*TextureBufferBase::getSFTexTarget(void) const
319 return &_sfTexTarget
;
323 SFUInt32
*TextureBufferBase::editSFLevel(void)
325 editSField(LevelFieldMask
);
330 const SFUInt32
*TextureBufferBase::getSFLevel(void) const
336 SFUInt32
*TextureBufferBase::editSFLayer(void)
338 editSField(LayerFieldMask
);
343 const SFUInt32
*TextureBufferBase::getSFLayer(void) const
353 /*------------------------------ access -----------------------------------*/
355 SizeT
TextureBufferBase::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
!= (LayerFieldMask
& whichField
))
373 returnValue
+= _sfLayer
.getBinSize();
379 void TextureBufferBase::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
!= (LayerFieldMask
& whichField
))
398 _sfLayer
.copyToBin(pMem
);
402 void TextureBufferBase::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
!= (LayerFieldMask
& whichField
))
424 editSField(LayerFieldMask
);
425 _sfLayer
.copyFromBin(pMem
);
429 //! create a new instance of the class
430 TextureBufferTransitPtr
TextureBufferBase::createLocal(BitVector bFlags
)
432 TextureBufferTransitPtr fc
;
434 if(getClassType().getPrototype() != NULL
)
436 FieldContainerTransitPtr tmpPtr
=
437 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
439 fc
= dynamic_pointer_cast
<TextureBuffer
>(tmpPtr
);
445 //! create a new instance of the class, copy the container flags
446 TextureBufferTransitPtr
TextureBufferBase::createDependent(BitVector bFlags
)
448 TextureBufferTransitPtr fc
;
450 if(getClassType().getPrototype() != NULL
)
452 FieldContainerTransitPtr tmpPtr
=
453 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
455 fc
= dynamic_pointer_cast
<TextureBuffer
>(tmpPtr
);
461 //! create a new instance of the class
462 TextureBufferTransitPtr
TextureBufferBase::create(void)
464 TextureBufferTransitPtr fc
;
466 if(getClassType().getPrototype() != NULL
)
468 FieldContainerTransitPtr tmpPtr
=
469 getClassType().getPrototype()-> shallowCopy();
471 fc
= dynamic_pointer_cast
<TextureBuffer
>(tmpPtr
);
477 TextureBuffer
*TextureBufferBase::createEmptyLocal(BitVector bFlags
)
479 TextureBuffer
*returnValue
;
481 newPtr
<TextureBuffer
>(returnValue
, bFlags
);
483 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
488 //! create an empty new instance of the class, do not copy the prototype
489 TextureBuffer
*TextureBufferBase::createEmpty(void)
491 TextureBuffer
*returnValue
;
493 newPtr
<TextureBuffer
>(returnValue
, Thread::getCurrentLocalFlags());
495 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
496 ~Thread::getCurrentLocalFlags();
502 FieldContainerTransitPtr
TextureBufferBase::shallowCopyLocal(
503 BitVector bFlags
) const
505 TextureBuffer
*tmpPtr
;
507 newPtr(tmpPtr
, dynamic_cast<const TextureBuffer
*>(this), bFlags
);
509 FieldContainerTransitPtr
returnValue(tmpPtr
);
511 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
516 FieldContainerTransitPtr
TextureBufferBase::shallowCopyDependent(
517 BitVector bFlags
) const
519 TextureBuffer
*tmpPtr
;
521 newPtr(tmpPtr
, dynamic_cast<const TextureBuffer
*>(this), ~bFlags
);
523 FieldContainerTransitPtr
returnValue(tmpPtr
);
525 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
530 FieldContainerTransitPtr
TextureBufferBase::shallowCopy(void) const
532 TextureBuffer
*tmpPtr
;
535 dynamic_cast<const TextureBuffer
*>(this),
536 Thread::getCurrentLocalFlags());
538 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
540 FieldContainerTransitPtr
returnValue(tmpPtr
);
548 /*------------------------- constructors ----------------------------------*/
550 TextureBufferBase::TextureBufferBase(void) :
553 _sfTexTarget (GLenum(GL_NONE
)),
554 _sfLevel (UInt32(0)),
559 TextureBufferBase::TextureBufferBase(const TextureBufferBase
&source
) :
562 _sfTexTarget (source
._sfTexTarget
),
563 _sfLevel (source
._sfLevel
),
564 _sfLayer (source
._sfLayer
)
569 /*-------------------------- destructors ----------------------------------*/
571 TextureBufferBase::~TextureBufferBase(void)
575 void TextureBufferBase::onCreate(const TextureBuffer
*source
)
577 Inherited::onCreate(source
);
581 TextureBuffer
*pThis
= static_cast<TextureBuffer
*>(this);
583 pThis
->setTexture(source
->getTexture());
587 GetFieldHandlePtr
TextureBufferBase::getHandleTexture (void) const
589 SFUnrecTextureObjChunkPtr::GetHandlePtr
returnValue(
590 new SFUnrecTextureObjChunkPtr::GetHandle(
592 this->getType().getFieldDesc(TextureFieldId
),
593 const_cast<TextureBufferBase
*>(this)));
598 EditFieldHandlePtr
TextureBufferBase::editHandleTexture (void)
600 SFUnrecTextureObjChunkPtr::EditHandlePtr
returnValue(
601 new SFUnrecTextureObjChunkPtr::EditHandle(
603 this->getType().getFieldDesc(TextureFieldId
),
606 returnValue
->setSetMethod(
607 boost::bind(&TextureBuffer::setTexture
,
608 static_cast<TextureBuffer
*>(this), _1
));
610 editSField(TextureFieldMask
);
615 GetFieldHandlePtr
TextureBufferBase::getHandleTexTarget (void) const
617 SFGLenum::GetHandlePtr
returnValue(
618 new SFGLenum::GetHandle(
620 this->getType().getFieldDesc(TexTargetFieldId
),
621 const_cast<TextureBufferBase
*>(this)));
626 EditFieldHandlePtr
TextureBufferBase::editHandleTexTarget (void)
628 SFGLenum::EditHandlePtr
returnValue(
629 new SFGLenum::EditHandle(
631 this->getType().getFieldDesc(TexTargetFieldId
),
635 editSField(TexTargetFieldMask
);
640 GetFieldHandlePtr
TextureBufferBase::getHandleLevel (void) const
642 SFUInt32::GetHandlePtr
returnValue(
643 new SFUInt32::GetHandle(
645 this->getType().getFieldDesc(LevelFieldId
),
646 const_cast<TextureBufferBase
*>(this)));
651 EditFieldHandlePtr
TextureBufferBase::editHandleLevel (void)
653 SFUInt32::EditHandlePtr
returnValue(
654 new SFUInt32::EditHandle(
656 this->getType().getFieldDesc(LevelFieldId
),
660 editSField(LevelFieldMask
);
665 GetFieldHandlePtr
TextureBufferBase::getHandleLayer (void) const
667 SFUInt32::GetHandlePtr
returnValue(
668 new SFUInt32::GetHandle(
670 this->getType().getFieldDesc(LayerFieldId
),
671 const_cast<TextureBufferBase
*>(this)));
676 EditFieldHandlePtr
TextureBufferBase::editHandleLayer (void)
678 SFUInt32::EditHandlePtr
returnValue(
679 new SFUInt32::EditHandle(
681 this->getType().getFieldDesc(LayerFieldId
),
685 editSField(LayerFieldMask
);
691 #ifdef OSG_MT_CPTR_ASPECT
692 void TextureBufferBase::execSyncV( FieldContainer
&oFrom
,
693 ConstFieldMaskArg whichField
,
694 AspectOffsetStore
&oOffsets
,
695 ConstFieldMaskArg syncMode
,
696 const UInt32 uiSyncInfo
)
698 TextureBuffer
*pThis
= static_cast<TextureBuffer
*>(this);
700 pThis
->execSync(static_cast<TextureBuffer
*>(&oFrom
),
709 #ifdef OSG_MT_CPTR_ASPECT
710 FieldContainer
*TextureBufferBase::createAspectCopy(
711 const FieldContainer
*pRefAspect
) const
713 TextureBuffer
*returnValue
;
715 newAspectCopy(returnValue
,
716 dynamic_cast<const TextureBuffer
*>(pRefAspect
),
717 dynamic_cast<const TextureBuffer
*>(this));
723 void TextureBufferBase::resolveLinks(void)
725 Inherited::resolveLinks();
727 static_cast<TextureBuffer
*>(this)->setTexture(NULL
);