fixed: determing internal format if not set for TextureImageChunk
[opensg.git] / Source / System / State / Auxiliary / OSGTextureObjRefChunkBase.cpp
blobf6f3420299abd2295fed474bd90c125a50fe5fe5
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 TextureObjRefChunk!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #include "OSGConfig.h"
59 #include "OSGGL.h" // InternalFormat default header
62 #include "OSGTextureObjRefChunkBase.h"
63 #include "OSGTextureObjRefChunk.h"
65 #include <boost/bind.hpp>
67 #ifdef WIN32 // turn off 'this' : used in base member initializer list warning
68 #pragma warning(disable:4355)
69 #endif
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::TextureObjRefChunk
81 /***************************************************************************\
82 * Field Documentation *
83 \***************************************************************************/
85 /*! \var GLenum TextureObjRefChunkBase::_sfOsgGLId
86 OpenSG-OpenGL id of texture object.
89 /*! \var GLenum TextureObjRefChunkBase::_sfOglGLId
90 Native OpenGL id of texture object.
93 /*! \var GLenum TextureObjRefChunkBase::_sfInternalFormat
94 The internal texture format, needed if the texture is bound to an image
95 unit
99 /***************************************************************************\
100 * FieldType/FieldTrait Instantiation *
101 \***************************************************************************/
103 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
104 PointerType FieldTraits<TextureObjRefChunk *, nsOSG>::_type(
105 "TextureObjRefChunkPtr",
106 "TextureBaseChunkPtr",
107 TextureObjRefChunk::getClassType(),
108 nsOSG);
109 #endif
111 OSG_FIELDTRAITS_GETTYPE_NS(TextureObjRefChunk *, nsOSG)
113 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
114 TextureObjRefChunk *,
115 nsOSG);
117 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
118 TextureObjRefChunk *,
119 nsOSG);
121 /***************************************************************************\
122 * Field Description *
123 \***************************************************************************/
125 void TextureObjRefChunkBase::classDescInserter(TypeObject &oType)
127 FieldDescriptionBase *pDesc = NULL;
130 pDesc = new SFGLenum::Description(
131 SFGLenum::getClassType(),
132 "osgGLId",
133 "OpenSG-OpenGL id of texture object.\n",
134 OsgGLIdFieldId, OsgGLIdFieldMask,
135 false,
136 (Field::FClusterLocal),
137 static_cast<FieldEditMethodSig>(&TextureObjRefChunk::editHandleOsgGLId),
138 static_cast<FieldGetMethodSig >(&TextureObjRefChunk::getHandleOsgGLId));
140 oType.addInitialDesc(pDesc);
142 pDesc = new SFGLenum::Description(
143 SFGLenum::getClassType(),
144 "oglGLId",
145 "Native OpenGL id of texture object.\n",
146 OglGLIdFieldId, OglGLIdFieldMask,
147 false,
148 (Field::FClusterLocal),
149 static_cast<FieldEditMethodSig>(&TextureObjRefChunk::editHandleOglGLId),
150 static_cast<FieldGetMethodSig >(&TextureObjRefChunk::getHandleOglGLId));
152 oType.addInitialDesc(pDesc);
154 pDesc = new SFGLenum::Description(
155 SFGLenum::getClassType(),
156 "internalFormat",
157 "The internal texture format, needed if the texture is bound to an image\n"
158 "unit\n",
159 InternalFormatFieldId, InternalFormatFieldMask,
160 false,
161 (Field::SFDefaultFlags | Field::FStdAccess),
162 static_cast<FieldEditMethodSig>(&TextureObjRefChunk::editHandleInternalFormat),
163 static_cast<FieldGetMethodSig >(&TextureObjRefChunk::getHandleInternalFormat));
165 oType.addInitialDesc(pDesc);
169 TextureObjRefChunkBase::TypeObject TextureObjRefChunkBase::_type(
170 TextureObjRefChunkBase::getClassname(),
171 Inherited::getClassname(),
172 "NULL",
173 nsOSG, //Namespace
174 reinterpret_cast<PrototypeCreateF>(&TextureObjRefChunkBase::createEmptyLocal),
175 TextureObjRefChunk::initMethod,
176 TextureObjRefChunk::exitMethod,
177 reinterpret_cast<InitalInsertDescFunc>(&TextureObjRefChunk::classDescInserter),
178 false,
180 "<?xml version=\"1.0\"?>\n"
181 "\n"
182 "<FieldContainer\n"
183 " name=\"TextureObjRefChunk\"\n"
184 " parent=\"TextureBaseChunk\"\n"
185 " library=\"State\"\n"
186 " pointerfieldtypes=\"both\"\n"
187 " structure=\"concrete\"\n"
188 " systemcomponent=\"true\"\n"
189 " parentsystemcomponent=\"true\"\n"
190 " decoratable=\"false\"\n"
191 " docGroupBase=\"GrpStateAuxiliary\"\n"
192 " >\n"
193 " <Field\n"
194 " name=\"osgGLId\"\n"
195 " type=\"GLenum\"\n"
196 " cardinality=\"single\"\n"
197 " visibility=\"external\"\n"
198 " access=\"public\"\n"
199 " defaultValue=\"0\"\n"
200 " fieldFlags=\"FClusterLocal\"\n"
201 " >\n"
202 " OpenSG-OpenGL id of texture object.\n"
203 " </Field>\n"
204 " <Field\n"
205 " name=\"oglGLId\"\n"
206 " type=\"GLenum\"\n"
207 " cardinality=\"single\"\n"
208 " visibility=\"external\"\n"
209 " access=\"public\"\n"
210 " defaultValue=\"0\"\n"
211 " fieldFlags=\"FClusterLocal\"\n"
212 " >\n"
213 " Native OpenGL id of texture object.\n"
214 " </Field>\n"
215 " <Field\n"
216 " name=\"internalFormat\"\n"
217 " type=\"GLenum\"\n"
218 " cardinality=\"single\"\n"
219 " visibility=\"external\"\n"
220 " defaultValue=\"GL_NONE\"\n"
221 " defaultHeader=\"&quot;OSGGL.h&quot;\"\n"
222 " access=\"public\"\n"
223 " potential_values=\"GL_NONE,GL_ALPHA, GL_DEPTH_COMPONENT, GL_LUMINANCE, GL_LUMINANCE_ALPH, GL_INTENSITY, GL_RGB, GL_RGBA, COMPRESSED_ALPHA, COMPRESSED_LUMINANCE, COMPRESSED_LUMINANCE_ALPHA, COMPRESSED_RGB, COMPRESSED_RGBA\"\n"
224 "\t>\n"
225 "\tThe internal texture format, needed if the texture is bound to an image\n"
226 " unit\n"
227 " </Field>\n"
228 "</FieldContainer>\n",
232 /*------------------------------ get -----------------------------------*/
234 FieldContainerType &TextureObjRefChunkBase::getType(void)
236 return _type;
239 const FieldContainerType &TextureObjRefChunkBase::getType(void) const
241 return _type;
244 UInt32 TextureObjRefChunkBase::getContainerSize(void) const
246 return sizeof(TextureObjRefChunk);
249 /*------------------------- decorator get ------------------------------*/
252 SFGLenum *TextureObjRefChunkBase::editSFOsgGLId(void)
254 editSField(OsgGLIdFieldMask);
256 return &_sfOsgGLId;
259 const SFGLenum *TextureObjRefChunkBase::getSFOsgGLId(void) const
261 return &_sfOsgGLId;
265 SFGLenum *TextureObjRefChunkBase::editSFOglGLId(void)
267 editSField(OglGLIdFieldMask);
269 return &_sfOglGLId;
272 const SFGLenum *TextureObjRefChunkBase::getSFOglGLId(void) const
274 return &_sfOglGLId;
278 SFGLenum *TextureObjRefChunkBase::editSFInternalFormat(void)
280 editSField(InternalFormatFieldMask);
282 return &_sfInternalFormat;
285 const SFGLenum *TextureObjRefChunkBase::getSFInternalFormat(void) const
287 return &_sfInternalFormat;
295 /*------------------------------ access -----------------------------------*/
297 SizeT TextureObjRefChunkBase::getBinSize(ConstFieldMaskArg whichField)
299 SizeT returnValue = Inherited::getBinSize(whichField);
301 if(FieldBits::NoField != (OsgGLIdFieldMask & whichField))
303 returnValue += _sfOsgGLId.getBinSize();
305 if(FieldBits::NoField != (OglGLIdFieldMask & whichField))
307 returnValue += _sfOglGLId.getBinSize();
309 if(FieldBits::NoField != (InternalFormatFieldMask & whichField))
311 returnValue += _sfInternalFormat.getBinSize();
314 return returnValue;
317 void TextureObjRefChunkBase::copyToBin(BinaryDataHandler &pMem,
318 ConstFieldMaskArg whichField)
320 Inherited::copyToBin(pMem, whichField);
322 if(FieldBits::NoField != (OsgGLIdFieldMask & whichField))
324 _sfOsgGLId.copyToBin(pMem);
326 if(FieldBits::NoField != (OglGLIdFieldMask & whichField))
328 _sfOglGLId.copyToBin(pMem);
330 if(FieldBits::NoField != (InternalFormatFieldMask & whichField))
332 _sfInternalFormat.copyToBin(pMem);
336 void TextureObjRefChunkBase::copyFromBin(BinaryDataHandler &pMem,
337 ConstFieldMaskArg whichField)
339 Inherited::copyFromBin(pMem, whichField);
341 if(FieldBits::NoField != (OsgGLIdFieldMask & whichField))
343 editSField(OsgGLIdFieldMask);
344 _sfOsgGLId.copyFromBin(pMem);
346 if(FieldBits::NoField != (OglGLIdFieldMask & whichField))
348 editSField(OglGLIdFieldMask);
349 _sfOglGLId.copyFromBin(pMem);
351 if(FieldBits::NoField != (InternalFormatFieldMask & whichField))
353 editSField(InternalFormatFieldMask);
354 _sfInternalFormat.copyFromBin(pMem);
358 //! create a new instance of the class
359 TextureObjRefChunkTransitPtr TextureObjRefChunkBase::createLocal(BitVector bFlags)
361 TextureObjRefChunkTransitPtr fc;
363 if(getClassType().getPrototype() != NULL)
365 FieldContainerTransitPtr tmpPtr =
366 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
368 fc = dynamic_pointer_cast<TextureObjRefChunk>(tmpPtr);
371 return fc;
374 //! create a new instance of the class, copy the container flags
375 TextureObjRefChunkTransitPtr TextureObjRefChunkBase::createDependent(BitVector bFlags)
377 TextureObjRefChunkTransitPtr fc;
379 if(getClassType().getPrototype() != NULL)
381 FieldContainerTransitPtr tmpPtr =
382 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
384 fc = dynamic_pointer_cast<TextureObjRefChunk>(tmpPtr);
387 return fc;
390 //! create a new instance of the class
391 TextureObjRefChunkTransitPtr TextureObjRefChunkBase::create(void)
393 TextureObjRefChunkTransitPtr fc;
395 if(getClassType().getPrototype() != NULL)
397 FieldContainerTransitPtr tmpPtr =
398 getClassType().getPrototype()-> shallowCopy();
400 fc = dynamic_pointer_cast<TextureObjRefChunk>(tmpPtr);
403 return fc;
406 TextureObjRefChunk *TextureObjRefChunkBase::createEmptyLocal(BitVector bFlags)
408 TextureObjRefChunk *returnValue;
410 newPtr<TextureObjRefChunk>(returnValue, bFlags);
412 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
414 return returnValue;
417 //! create an empty new instance of the class, do not copy the prototype
418 TextureObjRefChunk *TextureObjRefChunkBase::createEmpty(void)
420 TextureObjRefChunk *returnValue;
422 newPtr<TextureObjRefChunk>(returnValue, Thread::getCurrentLocalFlags());
424 returnValue->_pFieldFlags->_bNamespaceMask &=
425 ~Thread::getCurrentLocalFlags();
427 return returnValue;
431 FieldContainerTransitPtr TextureObjRefChunkBase::shallowCopyLocal(
432 BitVector bFlags) const
434 TextureObjRefChunk *tmpPtr;
436 newPtr(tmpPtr, dynamic_cast<const TextureObjRefChunk *>(this), bFlags);
438 FieldContainerTransitPtr returnValue(tmpPtr);
440 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
442 return returnValue;
445 FieldContainerTransitPtr TextureObjRefChunkBase::shallowCopyDependent(
446 BitVector bFlags) const
448 TextureObjRefChunk *tmpPtr;
450 newPtr(tmpPtr, dynamic_cast<const TextureObjRefChunk *>(this), ~bFlags);
452 FieldContainerTransitPtr returnValue(tmpPtr);
454 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
456 return returnValue;
459 FieldContainerTransitPtr TextureObjRefChunkBase::shallowCopy(void) const
461 TextureObjRefChunk *tmpPtr;
463 newPtr(tmpPtr,
464 dynamic_cast<const TextureObjRefChunk *>(this),
465 Thread::getCurrentLocalFlags());
467 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
469 FieldContainerTransitPtr returnValue(tmpPtr);
471 return returnValue;
477 /*------------------------- constructors ----------------------------------*/
479 TextureObjRefChunkBase::TextureObjRefChunkBase(void) :
480 Inherited(),
481 _sfOsgGLId (GLenum(0)),
482 _sfOglGLId (GLenum(0)),
483 _sfInternalFormat (GLenum(GL_NONE))
487 TextureObjRefChunkBase::TextureObjRefChunkBase(const TextureObjRefChunkBase &source) :
488 Inherited(source),
489 _sfOsgGLId (source._sfOsgGLId ),
490 _sfOglGLId (source._sfOglGLId ),
491 _sfInternalFormat (source._sfInternalFormat )
496 /*-------------------------- destructors ----------------------------------*/
498 TextureObjRefChunkBase::~TextureObjRefChunkBase(void)
503 GetFieldHandlePtr TextureObjRefChunkBase::getHandleOsgGLId (void) const
505 SFGLenum::GetHandlePtr returnValue(
506 new SFGLenum::GetHandle(
507 &_sfOsgGLId,
508 this->getType().getFieldDesc(OsgGLIdFieldId),
509 const_cast<TextureObjRefChunkBase *>(this)));
511 return returnValue;
514 EditFieldHandlePtr TextureObjRefChunkBase::editHandleOsgGLId (void)
516 SFGLenum::EditHandlePtr returnValue(
517 new SFGLenum::EditHandle(
518 &_sfOsgGLId,
519 this->getType().getFieldDesc(OsgGLIdFieldId),
520 this));
523 editSField(OsgGLIdFieldMask);
525 return returnValue;
528 GetFieldHandlePtr TextureObjRefChunkBase::getHandleOglGLId (void) const
530 SFGLenum::GetHandlePtr returnValue(
531 new SFGLenum::GetHandle(
532 &_sfOglGLId,
533 this->getType().getFieldDesc(OglGLIdFieldId),
534 const_cast<TextureObjRefChunkBase *>(this)));
536 return returnValue;
539 EditFieldHandlePtr TextureObjRefChunkBase::editHandleOglGLId (void)
541 SFGLenum::EditHandlePtr returnValue(
542 new SFGLenum::EditHandle(
543 &_sfOglGLId,
544 this->getType().getFieldDesc(OglGLIdFieldId),
545 this));
548 editSField(OglGLIdFieldMask);
550 return returnValue;
553 GetFieldHandlePtr TextureObjRefChunkBase::getHandleInternalFormat (void) const
555 SFGLenum::GetHandlePtr returnValue(
556 new SFGLenum::GetHandle(
557 &_sfInternalFormat,
558 this->getType().getFieldDesc(InternalFormatFieldId),
559 const_cast<TextureObjRefChunkBase *>(this)));
561 return returnValue;
564 EditFieldHandlePtr TextureObjRefChunkBase::editHandleInternalFormat (void)
566 SFGLenum::EditHandlePtr returnValue(
567 new SFGLenum::EditHandle(
568 &_sfInternalFormat,
569 this->getType().getFieldDesc(InternalFormatFieldId),
570 this));
573 editSField(InternalFormatFieldMask);
575 return returnValue;
579 #ifdef OSG_MT_CPTR_ASPECT
580 void TextureObjRefChunkBase::execSyncV( FieldContainer &oFrom,
581 ConstFieldMaskArg whichField,
582 AspectOffsetStore &oOffsets,
583 ConstFieldMaskArg syncMode,
584 const UInt32 uiSyncInfo)
586 TextureObjRefChunk *pThis = static_cast<TextureObjRefChunk *>(this);
588 pThis->execSync(static_cast<TextureObjRefChunk *>(&oFrom),
589 whichField,
590 oOffsets,
591 syncMode,
592 uiSyncInfo);
594 #endif
597 #ifdef OSG_MT_CPTR_ASPECT
598 FieldContainer *TextureObjRefChunkBase::createAspectCopy(
599 const FieldContainer *pRefAspect) const
601 TextureObjRefChunk *returnValue;
603 newAspectCopy(returnValue,
604 dynamic_cast<const TextureObjRefChunk *>(pRefAspect),
605 dynamic_cast<const TextureObjRefChunk *>(this));
607 return returnValue;
609 #endif
611 void TextureObjRefChunkBase::resolveLinks(void)
613 Inherited::resolveLinks();
619 OSG_END_NAMESPACE