changed: gcc8 base update
[opensg.git] / Source / System / Window / FrameBufferObjects / OSGTextureBufferBase.cpp
blob09983e0d5c3b63772cd5626167dfa38adfe5c92a
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 TextureBuffer!
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 "OSGTextureBufferBase.h"
68 #include "OSGTextureBuffer.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
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(
112 "TextureBufferPtr",
113 "FrameBufferAttachmentPtr",
114 TextureBuffer::getClassType(),
115 nsOSG);
116 #endif
118 OSG_FIELDTRAITS_GETTYPE_NS(TextureBuffer *, nsOSG)
120 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
121 TextureBuffer *,
122 nsOSG)
124 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
125 TextureBuffer *,
126 nsOSG)
128 /***************************************************************************\
129 * Field Description *
130 \***************************************************************************/
132 void TextureBufferBase::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>(&TextureBuffer::editHandleTexture),
145 static_cast<FieldGetMethodSig >(&TextureBuffer::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>(&TextureBuffer::editHandleTexTarget),
158 static_cast<FieldGetMethodSig >(&TextureBuffer::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>(&TextureBuffer::editHandleLevel),
170 static_cast<FieldGetMethodSig >(&TextureBuffer::getHandleLevel));
172 oType.addInitialDesc(pDesc);
174 pDesc = new SFUInt32::Description(
175 SFUInt32::getClassType(),
176 "layer",
177 "The layer specifies the layer of a 2-dimensional image within a 3-dimensional texture.\n",
178 LayerFieldId, LayerFieldMask,
179 false,
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(),
191 "TextureBuffer",
192 nsOSG, //Namespace
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)),
198 false,
200 "<?xml version=\"1.0\"?>\n"
201 "\n"
202 "<FieldContainer\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"
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=\"layer\"\n"
248 " type=\"UInt32\"\n"
249 " cardinality=\"single\"\n"
250 " visibility=\"external\"\n"
251 " access=\"public\"\n"
252 " defaultValue=\"0\"\n"
253 " >\n"
254 " The layer specifies the layer of a 2-dimensional image within a 3-dimensional texture.\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 &TextureBufferBase::getType(void)
266 return _type;
269 const FieldContainerType &TextureBufferBase::getType(void) const
271 return _type;
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
285 return &_sfTexture;
288 SFUnrecTextureObjChunkPtr *TextureBufferBase::editSFTexture (void)
290 editSField(TextureFieldMask);
292 return &_sfTexture;
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);
327 return &_sfLevel;
330 const SFUInt32 *TextureBufferBase::getSFLevel(void) const
332 return &_sfLevel;
336 SFUInt32 *TextureBufferBase::editSFLayer(void)
338 editSField(LayerFieldMask);
340 return &_sfLayer;
343 const SFUInt32 *TextureBufferBase::getSFLayer(void) const
345 return &_sfLayer;
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();
376 return returnValue;
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);
442 return fc;
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);
458 return fc;
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);
474 return fc;
477 TextureBuffer *TextureBufferBase::createEmptyLocal(BitVector bFlags)
479 TextureBuffer *returnValue;
481 newPtr<TextureBuffer>(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 TextureBuffer *TextureBufferBase::createEmpty(void)
491 TextureBuffer *returnValue;
493 newPtr<TextureBuffer>(returnValue, Thread::getCurrentLocalFlags());
495 returnValue->_pFieldFlags->_bNamespaceMask &=
496 ~Thread::getCurrentLocalFlags();
498 return returnValue;
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;
513 return returnValue;
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;
527 return returnValue;
530 FieldContainerTransitPtr TextureBufferBase::shallowCopy(void) const
532 TextureBuffer *tmpPtr;
534 newPtr(tmpPtr,
535 dynamic_cast<const TextureBuffer *>(this),
536 Thread::getCurrentLocalFlags());
538 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
540 FieldContainerTransitPtr returnValue(tmpPtr);
542 return returnValue;
548 /*------------------------- constructors ----------------------------------*/
550 TextureBufferBase::TextureBufferBase(void) :
551 Inherited(),
552 _sfTexture (NULL),
553 _sfTexTarget (GLenum(GL_NONE)),
554 _sfLevel (UInt32(0)),
555 _sfLayer (UInt32(0))
559 TextureBufferBase::TextureBufferBase(const TextureBufferBase &source) :
560 Inherited(source),
561 _sfTexture (NULL),
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);
579 if(source != NULL)
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(
591 &_sfTexture,
592 this->getType().getFieldDesc(TextureFieldId),
593 const_cast<TextureBufferBase *>(this)));
595 return returnValue;
598 EditFieldHandlePtr TextureBufferBase::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(&TextureBuffer::setTexture,
608 static_cast<TextureBuffer *>(this), _1));
610 editSField(TextureFieldMask);
612 return returnValue;
615 GetFieldHandlePtr TextureBufferBase::getHandleTexTarget (void) const
617 SFGLenum::GetHandlePtr returnValue(
618 new SFGLenum::GetHandle(
619 &_sfTexTarget,
620 this->getType().getFieldDesc(TexTargetFieldId),
621 const_cast<TextureBufferBase *>(this)));
623 return returnValue;
626 EditFieldHandlePtr TextureBufferBase::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 TextureBufferBase::getHandleLevel (void) const
642 SFUInt32::GetHandlePtr returnValue(
643 new SFUInt32::GetHandle(
644 &_sfLevel,
645 this->getType().getFieldDesc(LevelFieldId),
646 const_cast<TextureBufferBase *>(this)));
648 return returnValue;
651 EditFieldHandlePtr TextureBufferBase::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 TextureBufferBase::getHandleLayer (void) const
667 SFUInt32::GetHandlePtr returnValue(
668 new SFUInt32::GetHandle(
669 &_sfLayer,
670 this->getType().getFieldDesc(LayerFieldId),
671 const_cast<TextureBufferBase *>(this)));
673 return returnValue;
676 EditFieldHandlePtr TextureBufferBase::editHandleLayer (void)
678 SFUInt32::EditHandlePtr returnValue(
679 new SFUInt32::EditHandle(
680 &_sfLayer,
681 this->getType().getFieldDesc(LayerFieldId),
682 this));
685 editSField(LayerFieldMask);
687 return returnValue;
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),
701 whichField,
702 oOffsets,
703 syncMode,
704 uiSyncInfo);
706 #endif
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));
719 return returnValue;
721 #endif
723 void TextureBufferBase::resolveLinks(void)
725 Inherited::resolveLinks();
727 static_cast<TextureBuffer *>(this)->setTexture(NULL);
733 OSG_END_NAMESPACE