changed: gcc8 base update
[opensg.git] / Source / System / State / Auxiliary / OSGTextureImageChunkBase.cpp
blob2335a5e8fa6e9e2ff2002826e5524b49d42f23ec
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 TextureImageChunk!
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"
64 #include "OSGGL.h" // Access default header
65 #include "OSGGL.h" // Format default header
67 #include "OSGTextureBaseChunk.h" // Texture Class
69 #include "OSGTextureImageChunkBase.h"
70 #include "OSGTextureImageChunk.h"
72 #include <boost/bind.hpp>
74 OSG_BEGIN_NAMESPACE
76 /***************************************************************************\
77 * Description *
78 \***************************************************************************/
80 /*! \class OSG::TextureImageChunk
81 uses glBindTextureImage
84 /***************************************************************************\
85 * Field Documentation *
86 \***************************************************************************/
88 /*! \var TextureBaseChunk * TextureImageChunkBase::_sfTexture
89 Texture chunks to choose from
92 /*! \var Int32 TextureImageChunkBase::_sfLevel
96 /*! \var Int32 TextureImageChunkBase::_sfLayer
100 /*! \var GLenum TextureImageChunkBase::_sfAccess
104 /*! \var GLenum TextureImageChunkBase::_sfFormat
109 /***************************************************************************\
110 * FieldType/FieldTrait Instantiation *
111 \***************************************************************************/
113 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
114 PointerType FieldTraits<TextureImageChunk *, nsOSG>::_type(
115 "TextureImageChunkPtr",
116 "StateChunkPtr",
117 TextureImageChunk::getClassType(),
118 nsOSG);
119 #endif
121 OSG_FIELDTRAITS_GETTYPE_NS(TextureImageChunk *, nsOSG)
123 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
124 TextureImageChunk *,
125 nsOSG)
127 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
128 TextureImageChunk *,
129 nsOSG)
131 /***************************************************************************\
132 * Field Description *
133 \***************************************************************************/
135 void TextureImageChunkBase::classDescInserter(TypeObject &oType)
137 FieldDescriptionBase *pDesc = NULL;
140 pDesc = new SFUnrecTextureBaseChunkPtr::Description(
141 SFUnrecTextureBaseChunkPtr::getClassType(),
142 "texture",
143 "Texture chunks to choose from \n",
144 TextureFieldId, TextureFieldMask,
145 false,
146 (Field::SFDefaultFlags | Field::FStdAccess),
147 static_cast<FieldEditMethodSig>(&TextureImageChunk::editHandleTexture),
148 static_cast<FieldGetMethodSig >(&TextureImageChunk::getHandleTexture));
150 oType.addInitialDesc(pDesc);
152 pDesc = new SFInt32::Description(
153 SFInt32::getClassType(),
154 "level",
156 LevelFieldId, LevelFieldMask,
157 false,
158 (Field::SFDefaultFlags | Field::FStdAccess),
159 static_cast<FieldEditMethodSig>(&TextureImageChunk::editHandleLevel),
160 static_cast<FieldGetMethodSig >(&TextureImageChunk::getHandleLevel));
162 oType.addInitialDesc(pDesc);
164 pDesc = new SFInt32::Description(
165 SFInt32::getClassType(),
166 "layer",
168 LayerFieldId, LayerFieldMask,
169 false,
170 (Field::SFDefaultFlags | Field::FStdAccess),
171 static_cast<FieldEditMethodSig>(&TextureImageChunk::editHandleLayer),
172 static_cast<FieldGetMethodSig >(&TextureImageChunk::getHandleLayer));
174 oType.addInitialDesc(pDesc);
176 pDesc = new SFGLenum::Description(
177 SFGLenum::getClassType(),
178 "access",
180 AccessFieldId, AccessFieldMask,
181 false,
182 (Field::SFDefaultFlags | Field::FStdAccess),
183 static_cast<FieldEditMethodSig>(&TextureImageChunk::editHandleAccess),
184 static_cast<FieldGetMethodSig >(&TextureImageChunk::getHandleAccess));
186 oType.addInitialDesc(pDesc);
188 pDesc = new SFGLenum::Description(
189 SFGLenum::getClassType(),
190 "format",
192 FormatFieldId, FormatFieldMask,
193 false,
194 (Field::SFDefaultFlags | Field::FStdAccess),
195 static_cast<FieldEditMethodSig>(&TextureImageChunk::editHandleFormat),
196 static_cast<FieldGetMethodSig >(&TextureImageChunk::getHandleFormat));
198 oType.addInitialDesc(pDesc);
202 TextureImageChunkBase::TypeObject TextureImageChunkBase::_type(
203 TextureImageChunkBase::getClassname(),
204 Inherited::getClassname(),
205 "NULL",
206 nsOSG, //Namespace
207 reinterpret_cast<PrototypeCreateF>(&TextureImageChunkBase::createEmptyLocal),
208 reinterpret_cast<InitContainerF>(&TextureImageChunk::initMethod),
209 reinterpret_cast<ExitContainerF>(&TextureImageChunk::exitMethod),
210 reinterpret_cast<InitalInsertDescFunc>(
211 reinterpret_cast<void *>(&TextureImageChunk::classDescInserter)),
212 false,
214 "<?xml version=\"1.0\"?>\n"
215 "\n"
216 "<FieldContainer\n"
217 " name=\"TextureImageChunk\"\n"
218 " parent=\"StateChunk\"\n"
219 " library=\"State\"\n"
220 " pointerfieldtypes=\"both\"\n"
221 " structure=\"concrete\"\n"
222 " systemcomponent=\"true\"\n"
223 " parentsystemcomponent=\"true\"\n"
224 " decoratable=\"false\"\n"
225 " docGroupBase=\"GrpStateAuxiliary\"\n"
226 " >\n"
227 "\n"
228 " uses glBindTextureImage\n"
229 "\n"
230 " <Field\n"
231 "\t name=\"texture\"\n"
232 "\t type=\"TextureBaseChunk\"\n"
233 " category=\"pointer\"\n"
234 "\t cardinality=\"single\"\n"
235 "\t visibility=\"external\"\n"
236 "\t access=\"public\"\n"
237 " defaultValue=\"NULL\"\n"
238 "\t >\n"
239 "\tTexture chunks to choose from \n"
240 " </Field>\n"
241 "\n"
242 " <Field\n"
243 " name=\"level\"\n"
244 " type=\"Int32\"\n"
245 " cardinality=\"single\"\n"
246 " visibility=\"external\"\n"
247 " defaultValue=\"0\"\n"
248 " access=\"public\"\n"
249 " >\n"
250 " </Field>\n"
251 "\n"
252 " <Field\n"
253 " name=\"layer\"\n"
254 " type=\"Int32\"\n"
255 " cardinality=\"single\"\n"
256 " visibility=\"external\"\n"
257 " defaultValue=\"-1\"\n"
258 " access=\"public\"\n"
259 " >\n"
260 " </Field>\n"
261 "\n"
262 " <Field\n"
263 " name=\"access\"\n"
264 " type=\"GLenum\"\n"
265 " cardinality=\"single\"\n"
266 " visibility=\"external\"\n"
267 " defaultValue=\"GL_READ_ONLY\"\n"
268 " defaultHeader=\"&quot;OSGGL.h&quot;\"\n"
269 " access=\"public\"\n"
270 " potential_values=\"GL_READ_ONLY, GL_WRITE_ONLY, GL_READ_WRITE\"\n"
271 "\t >\n"
272 " </Field>\n"
273 "\n"
274 " <Field\n"
275 " name=\"format\"\n"
276 " type=\"GLenum\"\n"
277 " cardinality=\"single\"\n"
278 " visibility=\"external\"\n"
279 " defaultValue=\"GL_NONE\"\n"
280 " defaultHeader=\"&quot;OSGGL.h&quot;\"\n"
281 " access=\"public\"\n"
282 "\t >\n"
283 " </Field>\n"
284 "\n"
285 "</FieldContainer>\n",
286 "uses glBindTextureImage\n"
289 /*------------------------------ get -----------------------------------*/
291 FieldContainerType &TextureImageChunkBase::getType(void)
293 return _type;
296 const FieldContainerType &TextureImageChunkBase::getType(void) const
298 return _type;
301 UInt32 TextureImageChunkBase::getContainerSize(void) const
303 return sizeof(TextureImageChunk);
306 /*------------------------- decorator get ------------------------------*/
309 //! Get the TextureImageChunk::_sfTexture field.
310 const SFUnrecTextureBaseChunkPtr *TextureImageChunkBase::getSFTexture(void) const
312 return &_sfTexture;
315 SFUnrecTextureBaseChunkPtr *TextureImageChunkBase::editSFTexture (void)
317 editSField(TextureFieldMask);
319 return &_sfTexture;
322 //! Get the value of the TextureImageChunk::_sfTexture field.
323 TextureBaseChunk * TextureImageChunkBase::getTexture(void) const
325 return _sfTexture.getValue();
328 //! Set the value of the TextureImageChunk::_sfTexture field.
329 void TextureImageChunkBase::setTexture(TextureBaseChunk * const value)
331 editSField(TextureFieldMask);
333 _sfTexture.setValue(value);
337 SFInt32 *TextureImageChunkBase::editSFLevel(void)
339 editSField(LevelFieldMask);
341 return &_sfLevel;
344 const SFInt32 *TextureImageChunkBase::getSFLevel(void) const
346 return &_sfLevel;
350 SFInt32 *TextureImageChunkBase::editSFLayer(void)
352 editSField(LayerFieldMask);
354 return &_sfLayer;
357 const SFInt32 *TextureImageChunkBase::getSFLayer(void) const
359 return &_sfLayer;
363 SFGLenum *TextureImageChunkBase::editSFAccess(void)
365 editSField(AccessFieldMask);
367 return &_sfAccess;
370 const SFGLenum *TextureImageChunkBase::getSFAccess(void) const
372 return &_sfAccess;
376 SFGLenum *TextureImageChunkBase::editSFFormat(void)
378 editSField(FormatFieldMask);
380 return &_sfFormat;
383 const SFGLenum *TextureImageChunkBase::getSFFormat(void) const
385 return &_sfFormat;
393 /*------------------------------ access -----------------------------------*/
395 SizeT TextureImageChunkBase::getBinSize(ConstFieldMaskArg whichField)
397 SizeT returnValue = Inherited::getBinSize(whichField);
399 if(FieldBits::NoField != (TextureFieldMask & whichField))
401 returnValue += _sfTexture.getBinSize();
403 if(FieldBits::NoField != (LevelFieldMask & whichField))
405 returnValue += _sfLevel.getBinSize();
407 if(FieldBits::NoField != (LayerFieldMask & whichField))
409 returnValue += _sfLayer.getBinSize();
411 if(FieldBits::NoField != (AccessFieldMask & whichField))
413 returnValue += _sfAccess.getBinSize();
415 if(FieldBits::NoField != (FormatFieldMask & whichField))
417 returnValue += _sfFormat.getBinSize();
420 return returnValue;
423 void TextureImageChunkBase::copyToBin(BinaryDataHandler &pMem,
424 ConstFieldMaskArg whichField)
426 Inherited::copyToBin(pMem, whichField);
428 if(FieldBits::NoField != (TextureFieldMask & whichField))
430 _sfTexture.copyToBin(pMem);
432 if(FieldBits::NoField != (LevelFieldMask & whichField))
434 _sfLevel.copyToBin(pMem);
436 if(FieldBits::NoField != (LayerFieldMask & whichField))
438 _sfLayer.copyToBin(pMem);
440 if(FieldBits::NoField != (AccessFieldMask & whichField))
442 _sfAccess.copyToBin(pMem);
444 if(FieldBits::NoField != (FormatFieldMask & whichField))
446 _sfFormat.copyToBin(pMem);
450 void TextureImageChunkBase::copyFromBin(BinaryDataHandler &pMem,
451 ConstFieldMaskArg whichField)
453 Inherited::copyFromBin(pMem, whichField);
455 if(FieldBits::NoField != (TextureFieldMask & whichField))
457 editSField(TextureFieldMask);
458 _sfTexture.copyFromBin(pMem);
460 if(FieldBits::NoField != (LevelFieldMask & whichField))
462 editSField(LevelFieldMask);
463 _sfLevel.copyFromBin(pMem);
465 if(FieldBits::NoField != (LayerFieldMask & whichField))
467 editSField(LayerFieldMask);
468 _sfLayer.copyFromBin(pMem);
470 if(FieldBits::NoField != (AccessFieldMask & whichField))
472 editSField(AccessFieldMask);
473 _sfAccess.copyFromBin(pMem);
475 if(FieldBits::NoField != (FormatFieldMask & whichField))
477 editSField(FormatFieldMask);
478 _sfFormat.copyFromBin(pMem);
482 //! create a new instance of the class
483 TextureImageChunkTransitPtr TextureImageChunkBase::createLocal(BitVector bFlags)
485 TextureImageChunkTransitPtr fc;
487 if(getClassType().getPrototype() != NULL)
489 FieldContainerTransitPtr tmpPtr =
490 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
492 fc = dynamic_pointer_cast<TextureImageChunk>(tmpPtr);
495 return fc;
498 //! create a new instance of the class, copy the container flags
499 TextureImageChunkTransitPtr TextureImageChunkBase::createDependent(BitVector bFlags)
501 TextureImageChunkTransitPtr fc;
503 if(getClassType().getPrototype() != NULL)
505 FieldContainerTransitPtr tmpPtr =
506 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
508 fc = dynamic_pointer_cast<TextureImageChunk>(tmpPtr);
511 return fc;
514 //! create a new instance of the class
515 TextureImageChunkTransitPtr TextureImageChunkBase::create(void)
517 TextureImageChunkTransitPtr fc;
519 if(getClassType().getPrototype() != NULL)
521 FieldContainerTransitPtr tmpPtr =
522 getClassType().getPrototype()-> shallowCopy();
524 fc = dynamic_pointer_cast<TextureImageChunk>(tmpPtr);
527 return fc;
530 TextureImageChunk *TextureImageChunkBase::createEmptyLocal(BitVector bFlags)
532 TextureImageChunk *returnValue;
534 newPtr<TextureImageChunk>(returnValue, bFlags);
536 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
538 return returnValue;
541 //! create an empty new instance of the class, do not copy the prototype
542 TextureImageChunk *TextureImageChunkBase::createEmpty(void)
544 TextureImageChunk *returnValue;
546 newPtr<TextureImageChunk>(returnValue, Thread::getCurrentLocalFlags());
548 returnValue->_pFieldFlags->_bNamespaceMask &=
549 ~Thread::getCurrentLocalFlags();
551 return returnValue;
555 FieldContainerTransitPtr TextureImageChunkBase::shallowCopyLocal(
556 BitVector bFlags) const
558 TextureImageChunk *tmpPtr;
560 newPtr(tmpPtr, dynamic_cast<const TextureImageChunk *>(this), bFlags);
562 FieldContainerTransitPtr returnValue(tmpPtr);
564 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
566 return returnValue;
569 FieldContainerTransitPtr TextureImageChunkBase::shallowCopyDependent(
570 BitVector bFlags) const
572 TextureImageChunk *tmpPtr;
574 newPtr(tmpPtr, dynamic_cast<const TextureImageChunk *>(this), ~bFlags);
576 FieldContainerTransitPtr returnValue(tmpPtr);
578 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
580 return returnValue;
583 FieldContainerTransitPtr TextureImageChunkBase::shallowCopy(void) const
585 TextureImageChunk *tmpPtr;
587 newPtr(tmpPtr,
588 dynamic_cast<const TextureImageChunk *>(this),
589 Thread::getCurrentLocalFlags());
591 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
593 FieldContainerTransitPtr returnValue(tmpPtr);
595 return returnValue;
601 /*------------------------- constructors ----------------------------------*/
603 TextureImageChunkBase::TextureImageChunkBase(void) :
604 Inherited(),
605 _sfTexture (NULL),
606 _sfLevel (Int32(0)),
607 _sfLayer (Int32(-1)),
608 _sfAccess (GLenum(GL_READ_ONLY)),
609 _sfFormat (GLenum(GL_NONE))
613 TextureImageChunkBase::TextureImageChunkBase(const TextureImageChunkBase &source) :
614 Inherited(source),
615 _sfTexture (NULL),
616 _sfLevel (source._sfLevel ),
617 _sfLayer (source._sfLayer ),
618 _sfAccess (source._sfAccess ),
619 _sfFormat (source._sfFormat )
624 /*-------------------------- destructors ----------------------------------*/
626 TextureImageChunkBase::~TextureImageChunkBase(void)
630 void TextureImageChunkBase::onCreate(const TextureImageChunk *source)
632 Inherited::onCreate(source);
634 if(source != NULL)
636 TextureImageChunk *pThis = static_cast<TextureImageChunk *>(this);
638 pThis->setTexture(source->getTexture());
642 GetFieldHandlePtr TextureImageChunkBase::getHandleTexture (void) const
644 SFUnrecTextureBaseChunkPtr::GetHandlePtr returnValue(
645 new SFUnrecTextureBaseChunkPtr::GetHandle(
646 &_sfTexture,
647 this->getType().getFieldDesc(TextureFieldId),
648 const_cast<TextureImageChunkBase *>(this)));
650 return returnValue;
653 EditFieldHandlePtr TextureImageChunkBase::editHandleTexture (void)
655 SFUnrecTextureBaseChunkPtr::EditHandlePtr returnValue(
656 new SFUnrecTextureBaseChunkPtr::EditHandle(
657 &_sfTexture,
658 this->getType().getFieldDesc(TextureFieldId),
659 this));
661 returnValue->setSetMethod(
662 boost::bind(&TextureImageChunk::setTexture,
663 static_cast<TextureImageChunk *>(this), _1));
665 editSField(TextureFieldMask);
667 return returnValue;
670 GetFieldHandlePtr TextureImageChunkBase::getHandleLevel (void) const
672 SFInt32::GetHandlePtr returnValue(
673 new SFInt32::GetHandle(
674 &_sfLevel,
675 this->getType().getFieldDesc(LevelFieldId),
676 const_cast<TextureImageChunkBase *>(this)));
678 return returnValue;
681 EditFieldHandlePtr TextureImageChunkBase::editHandleLevel (void)
683 SFInt32::EditHandlePtr returnValue(
684 new SFInt32::EditHandle(
685 &_sfLevel,
686 this->getType().getFieldDesc(LevelFieldId),
687 this));
690 editSField(LevelFieldMask);
692 return returnValue;
695 GetFieldHandlePtr TextureImageChunkBase::getHandleLayer (void) const
697 SFInt32::GetHandlePtr returnValue(
698 new SFInt32::GetHandle(
699 &_sfLayer,
700 this->getType().getFieldDesc(LayerFieldId),
701 const_cast<TextureImageChunkBase *>(this)));
703 return returnValue;
706 EditFieldHandlePtr TextureImageChunkBase::editHandleLayer (void)
708 SFInt32::EditHandlePtr returnValue(
709 new SFInt32::EditHandle(
710 &_sfLayer,
711 this->getType().getFieldDesc(LayerFieldId),
712 this));
715 editSField(LayerFieldMask);
717 return returnValue;
720 GetFieldHandlePtr TextureImageChunkBase::getHandleAccess (void) const
722 SFGLenum::GetHandlePtr returnValue(
723 new SFGLenum::GetHandle(
724 &_sfAccess,
725 this->getType().getFieldDesc(AccessFieldId),
726 const_cast<TextureImageChunkBase *>(this)));
728 return returnValue;
731 EditFieldHandlePtr TextureImageChunkBase::editHandleAccess (void)
733 SFGLenum::EditHandlePtr returnValue(
734 new SFGLenum::EditHandle(
735 &_sfAccess,
736 this->getType().getFieldDesc(AccessFieldId),
737 this));
740 editSField(AccessFieldMask);
742 return returnValue;
745 GetFieldHandlePtr TextureImageChunkBase::getHandleFormat (void) const
747 SFGLenum::GetHandlePtr returnValue(
748 new SFGLenum::GetHandle(
749 &_sfFormat,
750 this->getType().getFieldDesc(FormatFieldId),
751 const_cast<TextureImageChunkBase *>(this)));
753 return returnValue;
756 EditFieldHandlePtr TextureImageChunkBase::editHandleFormat (void)
758 SFGLenum::EditHandlePtr returnValue(
759 new SFGLenum::EditHandle(
760 &_sfFormat,
761 this->getType().getFieldDesc(FormatFieldId),
762 this));
765 editSField(FormatFieldMask);
767 return returnValue;
771 #ifdef OSG_MT_CPTR_ASPECT
772 void TextureImageChunkBase::execSyncV( FieldContainer &oFrom,
773 ConstFieldMaskArg whichField,
774 AspectOffsetStore &oOffsets,
775 ConstFieldMaskArg syncMode,
776 const UInt32 uiSyncInfo)
778 TextureImageChunk *pThis = static_cast<TextureImageChunk *>(this);
780 pThis->execSync(static_cast<TextureImageChunk *>(&oFrom),
781 whichField,
782 oOffsets,
783 syncMode,
784 uiSyncInfo);
786 #endif
789 #ifdef OSG_MT_CPTR_ASPECT
790 FieldContainer *TextureImageChunkBase::createAspectCopy(
791 const FieldContainer *pRefAspect) const
793 TextureImageChunk *returnValue;
795 newAspectCopy(returnValue,
796 dynamic_cast<const TextureImageChunk *>(pRefAspect),
797 dynamic_cast<const TextureImageChunk *>(this));
799 return returnValue;
801 #endif
803 void TextureImageChunkBase::resolveLinks(void)
805 Inherited::resolveLinks();
807 static_cast<TextureImageChunk *>(this)->setTexture(NULL);
813 OSG_END_NAMESPACE