fixed: compile issue
[opensg.git] / Source / System / Window / FrameBufferObjects / OSGLayeredTextureBufferBase.cpp
blob0c209836d22f1bdcc5209970884b416d9950d5b5
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 LayeredTextureBuffer!
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 "OSGTextureObjChunk.h" // Texture Class
67 #include "OSGLayeredTextureBufferBase.h"
68 #include "OSGLayeredTextureBuffer.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
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
102 UNUSED.
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(),
115 nsOSG);
116 #endif
118 OSG_FIELDTRAITS_GETTYPE_NS(LayeredTextureBuffer *, nsOSG)
120 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
121 LayeredTextureBuffer *,
122 nsOSG)
124 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
125 LayeredTextureBuffer *,
126 nsOSG)
128 /***************************************************************************\
129 * Field Description *
130 \***************************************************************************/
132 void LayeredTextureBufferBase::classDescInserter(TypeObject &oType)
134 FieldDescriptionBase *pDesc = NULL;
137 pDesc = new SFUnrecTextureObjChunkPtr::Description(
138 SFUnrecTextureObjChunkPtr::getClassType(),
139 "texture",
140 "The texture object to target.\n",
141 TextureFieldId, TextureFieldMask,
142 false,
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(),
151 "texTarget",
152 "If specified, this is the target value for FramebufferTextureXDEXT.\n"
153 "If GL_NONE, automatically determined.\n",
154 TexTargetFieldId, TexTargetFieldMask,
155 false,
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(),
164 "level",
165 "The mipmap level in the texture to target.\n",
166 LevelFieldId, LevelFieldMask,
167 false,
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(),
176 "zoffset",
177 "UNUSED.\n",
178 ZoffsetFieldId, ZoffsetFieldMask,
179 false,
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",
192 nsOSG, //Namespace
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)),
198 false,
200 "<?xml version=\"1.0\"?>\n"
201 "\n"
202 "<FieldContainer\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"
212 " >\n"
213 " Texture buffer. Wraps support to binding a framebuffer attachment to an OpenSG texture object.\n"
214 " \n"
215 " See FramebufferTexture1/2/3DEXT.\n"
216 " <Field\n"
217 " name=\"texture\"\n"
218 " type=\"TextureObjChunkPtr\"\n"
219 " cardinality=\"single\"\n"
220 " visibility=\"external\"\n"
221 " access=\"public\"\n"
222 " >\n"
223 " The texture object to target.\n"
224 " </Field>\n"
225 " <Field\n"
226 " name=\"texTarget\"\n"
227 " type=\"GLenum\"\n"
228 " cardinality=\"single\"\n"
229 " visibility=\"external\"\n"
230 " access=\"public\"\n"
231 " defaultValue=\"GL_NONE\"\n"
232 " >\n"
233 " If specified, this is the target value for FramebufferTextureXDEXT.\n"
234 " If GL_NONE, automatically determined.\n"
235 " </Field>\n"
236 " <Field\n"
237 " name=\"level\"\n"
238 " type=\"UInt32\"\n"
239 " cardinality=\"single\"\n"
240 " visibility=\"external\"\n"
241 " access=\"public\"\n"
242 " defaultValue=\"0\"\n"
243 " >\n"
244 " The mipmap level in the texture to target.\n"
245 " </Field>\n"
246 " <Field\n"
247 " name=\"zoffset\"\n"
248 " type=\"UInt32\"\n"
249 " cardinality=\"single\"\n"
250 " visibility=\"external\"\n"
251 " access=\"public\"\n"
252 " defaultValue=\"0\"\n"
253 " >\n"
254 " UNUSED.\n"
255 " </Field>\n"
256 "</FieldContainer>\n",
257 "Texture buffer. Wraps support to binding a framebuffer attachment to an OpenSG texture object.\n"
258 "\n"
259 "See FramebufferTexture1/2/3DEXT.\n"
262 /*------------------------------ get -----------------------------------*/
264 FieldContainerType &LayeredTextureBufferBase::getType(void)
266 return _type;
269 const FieldContainerType &LayeredTextureBufferBase::getType(void) const
271 return _type;
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
285 return &_sfTexture;
288 SFUnrecTextureObjChunkPtr *LayeredTextureBufferBase::editSFTexture (void)
290 editSField(TextureFieldMask);
292 return &_sfTexture;
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);
327 return &_sfLevel;
330 const SFUInt32 *LayeredTextureBufferBase::getSFLevel(void) const
332 return &_sfLevel;
336 SFUInt32 *LayeredTextureBufferBase::editSFZoffset(void)
338 editSField(ZoffsetFieldMask);
340 return &_sfZoffset;
343 const SFUInt32 *LayeredTextureBufferBase::getSFZoffset(void) const
345 return &_sfZoffset;
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();
376 return returnValue;
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);
442 return fc;
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);
458 return fc;
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);
474 return fc;
477 LayeredTextureBuffer *LayeredTextureBufferBase::createEmptyLocal(BitVector bFlags)
479 LayeredTextureBuffer *returnValue;
481 newPtr<LayeredTextureBuffer>(returnValue, bFlags);
483 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
485 return returnValue;
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();
498 return returnValue;
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;
513 return returnValue;
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;
527 return returnValue;
530 FieldContainerTransitPtr LayeredTextureBufferBase::shallowCopy(void) const
532 LayeredTextureBuffer *tmpPtr;
534 newPtr(tmpPtr,
535 dynamic_cast<const LayeredTextureBuffer *>(this),
536 Thread::getCurrentLocalFlags());
538 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
540 FieldContainerTransitPtr returnValue(tmpPtr);
542 return returnValue;
548 /*------------------------- constructors ----------------------------------*/
550 LayeredTextureBufferBase::LayeredTextureBufferBase(void) :
551 Inherited(),
552 _sfTexture (NULL),
553 _sfTexTarget (GLenum(GL_NONE)),
554 _sfLevel (UInt32(0)),
555 _sfZoffset (UInt32(0))
559 LayeredTextureBufferBase::LayeredTextureBufferBase(const LayeredTextureBufferBase &source) :
560 Inherited(source),
561 _sfTexture (NULL),
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);
579 if(source != NULL)
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(
591 &_sfTexture,
592 this->getType().getFieldDesc(TextureFieldId),
593 const_cast<LayeredTextureBufferBase *>(this)));
595 return returnValue;
598 EditFieldHandlePtr LayeredTextureBufferBase::editHandleTexture (void)
600 SFUnrecTextureObjChunkPtr::EditHandlePtr returnValue(
601 new SFUnrecTextureObjChunkPtr::EditHandle(
602 &_sfTexture,
603 this->getType().getFieldDesc(TextureFieldId),
604 this));
606 returnValue->setSetMethod(
607 boost::bind(&LayeredTextureBuffer::setTexture,
608 static_cast<LayeredTextureBuffer *>(this), _1));
610 editSField(TextureFieldMask);
612 return returnValue;
615 GetFieldHandlePtr LayeredTextureBufferBase::getHandleTexTarget (void) const
617 SFGLenum::GetHandlePtr returnValue(
618 new SFGLenum::GetHandle(
619 &_sfTexTarget,
620 this->getType().getFieldDesc(TexTargetFieldId),
621 const_cast<LayeredTextureBufferBase *>(this)));
623 return returnValue;
626 EditFieldHandlePtr LayeredTextureBufferBase::editHandleTexTarget (void)
628 SFGLenum::EditHandlePtr returnValue(
629 new SFGLenum::EditHandle(
630 &_sfTexTarget,
631 this->getType().getFieldDesc(TexTargetFieldId),
632 this));
635 editSField(TexTargetFieldMask);
637 return returnValue;
640 GetFieldHandlePtr LayeredTextureBufferBase::getHandleLevel (void) const
642 SFUInt32::GetHandlePtr returnValue(
643 new SFUInt32::GetHandle(
644 &_sfLevel,
645 this->getType().getFieldDesc(LevelFieldId),
646 const_cast<LayeredTextureBufferBase *>(this)));
648 return returnValue;
651 EditFieldHandlePtr LayeredTextureBufferBase::editHandleLevel (void)
653 SFUInt32::EditHandlePtr returnValue(
654 new SFUInt32::EditHandle(
655 &_sfLevel,
656 this->getType().getFieldDesc(LevelFieldId),
657 this));
660 editSField(LevelFieldMask);
662 return returnValue;
665 GetFieldHandlePtr LayeredTextureBufferBase::getHandleZoffset (void) const
667 SFUInt32::GetHandlePtr returnValue(
668 new SFUInt32::GetHandle(
669 &_sfZoffset,
670 this->getType().getFieldDesc(ZoffsetFieldId),
671 const_cast<LayeredTextureBufferBase *>(this)));
673 return returnValue;
676 EditFieldHandlePtr LayeredTextureBufferBase::editHandleZoffset (void)
678 SFUInt32::EditHandlePtr returnValue(
679 new SFUInt32::EditHandle(
680 &_sfZoffset,
681 this->getType().getFieldDesc(ZoffsetFieldId),
682 this));
685 editSField(ZoffsetFieldMask);
687 return returnValue;
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),
701 whichField,
702 oOffsets,
703 syncMode,
704 uiSyncInfo);
706 #endif
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));
719 return returnValue;
721 #endif
723 void LayeredTextureBufferBase::resolveLinks(void)
725 Inherited::resolveLinks();
727 static_cast<LayeredTextureBuffer *>(this)->setTexture(NULL);
733 OSG_END_NAMESPACE