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 RenderBuffer!
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 "OSGImage.h" // Image Class
67 #include "OSGRenderBufferBase.h"
68 #include "OSGRenderBuffer.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::RenderBuffer
79 Render buffer. Wraps OpenGL render buffer objects. RENDERBUFFER
80 A renderbuffer is a data storage object containing a single image of a renderable internal format.
85 /***************************************************************************\
86 * Field Documentation *
87 \***************************************************************************/
89 /*! \var GLenum RenderBufferBase::_sfGLId
90 The OpenGL texture id for this buffer object.
93 /*! \var GLenum RenderBufferBase::_sfInternalFormat
97 /*! \var Image * RenderBufferBase::_sfImage
98 Image object used if readback is enabled.
101 /*! \var UInt32 RenderBufferBase::_sfColorSamples
105 /*! \var UInt32 RenderBufferBase::_sfCoverageSamples
109 /*! \var bool RenderBufferBase::_sfFixedSampleLocation
114 /***************************************************************************\
115 * FieldType/FieldTrait Instantiation *
116 \***************************************************************************/
118 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
119 PointerType FieldTraits
<RenderBuffer
*, nsOSG
>::_type(
121 "FrameBufferAttachmentPtr",
122 RenderBuffer::getClassType(),
126 OSG_FIELDTRAITS_GETTYPE_NS(RenderBuffer
*, nsOSG
)
128 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
132 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
136 /***************************************************************************\
137 * Field Description *
138 \***************************************************************************/
140 void RenderBufferBase::classDescInserter(TypeObject
&oType
)
142 FieldDescriptionBase
*pDesc
= NULL
;
145 pDesc
= new SFGLenum::Description(
146 SFGLenum::getClassType(),
148 "The OpenGL texture id for this buffer object.\n",
149 GLIdFieldId
, GLIdFieldMask
,
151 (Field::FClusterLocal
),
152 static_cast<FieldEditMethodSig
>(&RenderBuffer::editHandleGLId
),
153 static_cast<FieldGetMethodSig
>(&RenderBuffer::getHandleGLId
));
155 oType
.addInitialDesc(pDesc
);
157 pDesc
= new SFGLenum::Description(
158 SFGLenum::getClassType(),
161 InternalFormatFieldId
, InternalFormatFieldMask
,
163 (Field::SFDefaultFlags
| Field::FStdAccess
),
164 static_cast<FieldEditMethodSig
>(&RenderBuffer::editHandleInternalFormat
),
165 static_cast<FieldGetMethodSig
>(&RenderBuffer::getHandleInternalFormat
));
167 oType
.addInitialDesc(pDesc
);
169 pDesc
= new SFUnrecImagePtr::Description(
170 SFUnrecImagePtr::getClassType(),
172 "Image object used if readback is enabled.\n",
173 ImageFieldId
, ImageFieldMask
,
175 (Field::SFDefaultFlags
| Field::FStdAccess
),
176 static_cast<FieldEditMethodSig
>(&RenderBuffer::editHandleImage
),
177 static_cast<FieldGetMethodSig
>(&RenderBuffer::getHandleImage
));
179 oType
.addInitialDesc(pDesc
);
181 pDesc
= new SFUInt32::Description(
182 SFUInt32::getClassType(),
185 ColorSamplesFieldId
, ColorSamplesFieldMask
,
187 (Field::SFDefaultFlags
| Field::FStdAccess
),
188 static_cast<FieldEditMethodSig
>(&RenderBuffer::editHandleColorSamples
),
189 static_cast<FieldGetMethodSig
>(&RenderBuffer::getHandleColorSamples
));
191 oType
.addInitialDesc(pDesc
);
193 pDesc
= new SFUInt32::Description(
194 SFUInt32::getClassType(),
197 CoverageSamplesFieldId
, CoverageSamplesFieldMask
,
199 (Field::SFDefaultFlags
| Field::FStdAccess
),
200 static_cast<FieldEditMethodSig
>(&RenderBuffer::editHandleCoverageSamples
),
201 static_cast<FieldGetMethodSig
>(&RenderBuffer::getHandleCoverageSamples
));
203 oType
.addInitialDesc(pDesc
);
205 pDesc
= new SFBool::Description(
206 SFBool::getClassType(),
207 "fixedSampleLocation",
209 FixedSampleLocationFieldId
, FixedSampleLocationFieldMask
,
211 (Field::SFDefaultFlags
| Field::FStdAccess
),
212 static_cast<FieldEditMethodSig
>(&RenderBuffer::editHandleFixedSampleLocation
),
213 static_cast<FieldGetMethodSig
>(&RenderBuffer::getHandleFixedSampleLocation
));
215 oType
.addInitialDesc(pDesc
);
219 RenderBufferBase::TypeObject
RenderBufferBase::_type(
220 RenderBufferBase::getClassname(),
221 Inherited::getClassname(),
224 reinterpret_cast<PrototypeCreateF
>(&RenderBufferBase::createEmptyLocal
),
225 reinterpret_cast<InitContainerF
>(&RenderBuffer::initMethod
),
226 reinterpret_cast<ExitContainerF
>(&RenderBuffer::exitMethod
),
227 reinterpret_cast<InitalInsertDescFunc
>(
228 reinterpret_cast<void *>(&RenderBuffer::classDescInserter
)),
231 "<?xml version=\"1.0\"?>\n"
234 " name=\"RenderBuffer\"\n"
235 " parent=\"FrameBufferAttachment\"\n"
236 " library=\"System\"\n"
237 " pointerfieldtypes=\"both\"\n"
238 " structure=\"concrete\"\n"
239 " systemcomponent=\"true\"\n"
240 " parentsystemcomponent=\"true\"\n"
241 " decoratable=\"false\"\n"
242 " docGroupBase=\"GrpSystemWindowFBO\"\n"
244 " Render buffer. Wraps OpenGL render buffer objects. RENDERBUFFER\n"
245 " A renderbuffer is a data storage object containing a single image of a renderable internal format.\n"
247 " \\see TextureBuffer\n"
251 " cardinality=\"single\"\n"
252 " visibility=\"internal\"\n"
253 " access=\"public\"\n"
254 " defaultValue=\"0\"\n"
255 " fieldFlags=\"FClusterLocal\"\n"
257 " The OpenGL texture id for this buffer object.\n"
260 " name=\"internalFormat\"\n"
262 " cardinality=\"single\"\n"
263 " visibility=\"external\"\n"
264 " access=\"public\"\n"
265 " defaultValue=\"GL_NONE\"\n"
270 " type=\"ImagePtr\"\n"
271 " cardinality=\"single\"\n"
272 " visibility=\"external\"\n"
273 " access=\"public\"\n"
275 " Image object used if readback is enabled.\n"
279 " name=\"colorSamples\"\n"
281 " cardinality=\"single\"\n"
282 " visibility=\"external\"\n"
283 " access=\"public\"\n"
284 " defaultValue=\"0\"\n"
289 " name=\"coverageSamples\"\n"
291 " cardinality=\"single\"\n"
292 " visibility=\"external\"\n"
293 " access=\"public\"\n"
294 " defaultValue=\"0\"\n"
299 " name=\"fixedSampleLocation\"\n"
301 " cardinality=\"single\"\n"
302 " visibility=\"external\"\n"
303 " access=\"public\"\n"
304 " defaultValue=\"true\"\n"
308 "</FieldContainer>\n",
309 "Render buffer. Wraps OpenGL render buffer objects. RENDERBUFFER\n"
310 "A renderbuffer is a data storage object containing a single image of a renderable internal format.\n"
312 "\\see TextureBuffer\n"
315 /*------------------------------ get -----------------------------------*/
317 FieldContainerType
&RenderBufferBase::getType(void)
322 const FieldContainerType
&RenderBufferBase::getType(void) const
327 UInt32
RenderBufferBase::getContainerSize(void) const
329 return sizeof(RenderBuffer
);
332 /*------------------------- decorator get ------------------------------*/
335 SFGLenum
*RenderBufferBase::editSFGLId(void)
337 editSField(GLIdFieldMask
);
342 const SFGLenum
*RenderBufferBase::getSFGLId(void) const
348 SFGLenum
*RenderBufferBase::editSFInternalFormat(void)
350 editSField(InternalFormatFieldMask
);
352 return &_sfInternalFormat
;
355 const SFGLenum
*RenderBufferBase::getSFInternalFormat(void) const
357 return &_sfInternalFormat
;
361 //! Get the RenderBuffer::_sfImage field.
362 const SFUnrecImagePtr
*RenderBufferBase::getSFImage(void) const
367 SFUnrecImagePtr
*RenderBufferBase::editSFImage (void)
369 editSField(ImageFieldMask
);
374 //! Get the value of the RenderBuffer::_sfImage field.
375 Image
* RenderBufferBase::getImage(void) const
377 return _sfImage
.getValue();
380 //! Set the value of the RenderBuffer::_sfImage field.
381 void RenderBufferBase::setImage(Image
* const value
)
383 editSField(ImageFieldMask
);
385 _sfImage
.setValue(value
);
389 SFUInt32
*RenderBufferBase::editSFColorSamples(void)
391 editSField(ColorSamplesFieldMask
);
393 return &_sfColorSamples
;
396 const SFUInt32
*RenderBufferBase::getSFColorSamples(void) const
398 return &_sfColorSamples
;
402 SFUInt32
*RenderBufferBase::editSFCoverageSamples(void)
404 editSField(CoverageSamplesFieldMask
);
406 return &_sfCoverageSamples
;
409 const SFUInt32
*RenderBufferBase::getSFCoverageSamples(void) const
411 return &_sfCoverageSamples
;
415 SFBool
*RenderBufferBase::editSFFixedSampleLocation(void)
417 editSField(FixedSampleLocationFieldMask
);
419 return &_sfFixedSampleLocation
;
422 const SFBool
*RenderBufferBase::getSFFixedSampleLocation(void) const
424 return &_sfFixedSampleLocation
;
432 /*------------------------------ access -----------------------------------*/
434 SizeT
RenderBufferBase::getBinSize(ConstFieldMaskArg whichField
)
436 SizeT returnValue
= Inherited::getBinSize(whichField
);
438 if(FieldBits::NoField
!= (GLIdFieldMask
& whichField
))
440 returnValue
+= _sfGLId
.getBinSize();
442 if(FieldBits::NoField
!= (InternalFormatFieldMask
& whichField
))
444 returnValue
+= _sfInternalFormat
.getBinSize();
446 if(FieldBits::NoField
!= (ImageFieldMask
& whichField
))
448 returnValue
+= _sfImage
.getBinSize();
450 if(FieldBits::NoField
!= (ColorSamplesFieldMask
& whichField
))
452 returnValue
+= _sfColorSamples
.getBinSize();
454 if(FieldBits::NoField
!= (CoverageSamplesFieldMask
& whichField
))
456 returnValue
+= _sfCoverageSamples
.getBinSize();
458 if(FieldBits::NoField
!= (FixedSampleLocationFieldMask
& whichField
))
460 returnValue
+= _sfFixedSampleLocation
.getBinSize();
466 void RenderBufferBase::copyToBin(BinaryDataHandler
&pMem
,
467 ConstFieldMaskArg whichField
)
469 Inherited::copyToBin(pMem
, whichField
);
471 if(FieldBits::NoField
!= (GLIdFieldMask
& whichField
))
473 _sfGLId
.copyToBin(pMem
);
475 if(FieldBits::NoField
!= (InternalFormatFieldMask
& whichField
))
477 _sfInternalFormat
.copyToBin(pMem
);
479 if(FieldBits::NoField
!= (ImageFieldMask
& whichField
))
481 _sfImage
.copyToBin(pMem
);
483 if(FieldBits::NoField
!= (ColorSamplesFieldMask
& whichField
))
485 _sfColorSamples
.copyToBin(pMem
);
487 if(FieldBits::NoField
!= (CoverageSamplesFieldMask
& whichField
))
489 _sfCoverageSamples
.copyToBin(pMem
);
491 if(FieldBits::NoField
!= (FixedSampleLocationFieldMask
& whichField
))
493 _sfFixedSampleLocation
.copyToBin(pMem
);
497 void RenderBufferBase::copyFromBin(BinaryDataHandler
&pMem
,
498 ConstFieldMaskArg whichField
)
500 Inherited::copyFromBin(pMem
, whichField
);
502 if(FieldBits::NoField
!= (GLIdFieldMask
& whichField
))
504 editSField(GLIdFieldMask
);
505 _sfGLId
.copyFromBin(pMem
);
507 if(FieldBits::NoField
!= (InternalFormatFieldMask
& whichField
))
509 editSField(InternalFormatFieldMask
);
510 _sfInternalFormat
.copyFromBin(pMem
);
512 if(FieldBits::NoField
!= (ImageFieldMask
& whichField
))
514 editSField(ImageFieldMask
);
515 _sfImage
.copyFromBin(pMem
);
517 if(FieldBits::NoField
!= (ColorSamplesFieldMask
& whichField
))
519 editSField(ColorSamplesFieldMask
);
520 _sfColorSamples
.copyFromBin(pMem
);
522 if(FieldBits::NoField
!= (CoverageSamplesFieldMask
& whichField
))
524 editSField(CoverageSamplesFieldMask
);
525 _sfCoverageSamples
.copyFromBin(pMem
);
527 if(FieldBits::NoField
!= (FixedSampleLocationFieldMask
& whichField
))
529 editSField(FixedSampleLocationFieldMask
);
530 _sfFixedSampleLocation
.copyFromBin(pMem
);
534 //! create a new instance of the class
535 RenderBufferTransitPtr
RenderBufferBase::createLocal(BitVector bFlags
)
537 RenderBufferTransitPtr fc
;
539 if(getClassType().getPrototype() != NULL
)
541 FieldContainerTransitPtr tmpPtr
=
542 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
544 fc
= dynamic_pointer_cast
<RenderBuffer
>(tmpPtr
);
550 //! create a new instance of the class, copy the container flags
551 RenderBufferTransitPtr
RenderBufferBase::createDependent(BitVector bFlags
)
553 RenderBufferTransitPtr fc
;
555 if(getClassType().getPrototype() != NULL
)
557 FieldContainerTransitPtr tmpPtr
=
558 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
560 fc
= dynamic_pointer_cast
<RenderBuffer
>(tmpPtr
);
566 //! create a new instance of the class
567 RenderBufferTransitPtr
RenderBufferBase::create(void)
569 RenderBufferTransitPtr fc
;
571 if(getClassType().getPrototype() != NULL
)
573 FieldContainerTransitPtr tmpPtr
=
574 getClassType().getPrototype()-> shallowCopy();
576 fc
= dynamic_pointer_cast
<RenderBuffer
>(tmpPtr
);
582 RenderBuffer
*RenderBufferBase::createEmptyLocal(BitVector bFlags
)
584 RenderBuffer
*returnValue
;
586 newPtr
<RenderBuffer
>(returnValue
, bFlags
);
588 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
593 //! create an empty new instance of the class, do not copy the prototype
594 RenderBuffer
*RenderBufferBase::createEmpty(void)
596 RenderBuffer
*returnValue
;
598 newPtr
<RenderBuffer
>(returnValue
, Thread::getCurrentLocalFlags());
600 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
601 ~Thread::getCurrentLocalFlags();
607 FieldContainerTransitPtr
RenderBufferBase::shallowCopyLocal(
608 BitVector bFlags
) const
610 RenderBuffer
*tmpPtr
;
612 newPtr(tmpPtr
, dynamic_cast<const RenderBuffer
*>(this), bFlags
);
614 FieldContainerTransitPtr
returnValue(tmpPtr
);
616 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
621 FieldContainerTransitPtr
RenderBufferBase::shallowCopyDependent(
622 BitVector bFlags
) const
624 RenderBuffer
*tmpPtr
;
626 newPtr(tmpPtr
, dynamic_cast<const RenderBuffer
*>(this), ~bFlags
);
628 FieldContainerTransitPtr
returnValue(tmpPtr
);
630 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
635 FieldContainerTransitPtr
RenderBufferBase::shallowCopy(void) const
637 RenderBuffer
*tmpPtr
;
640 dynamic_cast<const RenderBuffer
*>(this),
641 Thread::getCurrentLocalFlags());
643 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
645 FieldContainerTransitPtr
returnValue(tmpPtr
);
653 /*------------------------- constructors ----------------------------------*/
655 RenderBufferBase::RenderBufferBase(void) :
658 _sfInternalFormat (GLenum(GL_NONE
)),
660 _sfColorSamples (UInt32(0)),
661 _sfCoverageSamples (UInt32(0)),
662 _sfFixedSampleLocation (bool(true))
666 RenderBufferBase::RenderBufferBase(const RenderBufferBase
&source
) :
668 _sfGLId (source
._sfGLId
),
669 _sfInternalFormat (source
._sfInternalFormat
),
671 _sfColorSamples (source
._sfColorSamples
),
672 _sfCoverageSamples (source
._sfCoverageSamples
),
673 _sfFixedSampleLocation (source
._sfFixedSampleLocation
)
678 /*-------------------------- destructors ----------------------------------*/
680 RenderBufferBase::~RenderBufferBase(void)
684 void RenderBufferBase::onCreate(const RenderBuffer
*source
)
686 Inherited::onCreate(source
);
690 RenderBuffer
*pThis
= static_cast<RenderBuffer
*>(this);
692 pThis
->setImage(source
->getImage());
696 GetFieldHandlePtr
RenderBufferBase::getHandleGLId (void) const
698 SFGLenum::GetHandlePtr
returnValue(
699 new SFGLenum::GetHandle(
701 this->getType().getFieldDesc(GLIdFieldId
),
702 const_cast<RenderBufferBase
*>(this)));
707 EditFieldHandlePtr
RenderBufferBase::editHandleGLId (void)
709 SFGLenum::EditHandlePtr
returnValue(
710 new SFGLenum::EditHandle(
712 this->getType().getFieldDesc(GLIdFieldId
),
716 editSField(GLIdFieldMask
);
721 GetFieldHandlePtr
RenderBufferBase::getHandleInternalFormat (void) const
723 SFGLenum::GetHandlePtr
returnValue(
724 new SFGLenum::GetHandle(
726 this->getType().getFieldDesc(InternalFormatFieldId
),
727 const_cast<RenderBufferBase
*>(this)));
732 EditFieldHandlePtr
RenderBufferBase::editHandleInternalFormat (void)
734 SFGLenum::EditHandlePtr
returnValue(
735 new SFGLenum::EditHandle(
737 this->getType().getFieldDesc(InternalFormatFieldId
),
741 editSField(InternalFormatFieldMask
);
746 GetFieldHandlePtr
RenderBufferBase::getHandleImage (void) const
748 SFUnrecImagePtr::GetHandlePtr
returnValue(
749 new SFUnrecImagePtr::GetHandle(
751 this->getType().getFieldDesc(ImageFieldId
),
752 const_cast<RenderBufferBase
*>(this)));
757 EditFieldHandlePtr
RenderBufferBase::editHandleImage (void)
759 SFUnrecImagePtr::EditHandlePtr
returnValue(
760 new SFUnrecImagePtr::EditHandle(
762 this->getType().getFieldDesc(ImageFieldId
),
765 returnValue
->setSetMethod(
766 boost::bind(&RenderBuffer::setImage
,
767 static_cast<RenderBuffer
*>(this), _1
));
769 editSField(ImageFieldMask
);
774 GetFieldHandlePtr
RenderBufferBase::getHandleColorSamples (void) const
776 SFUInt32::GetHandlePtr
returnValue(
777 new SFUInt32::GetHandle(
779 this->getType().getFieldDesc(ColorSamplesFieldId
),
780 const_cast<RenderBufferBase
*>(this)));
785 EditFieldHandlePtr
RenderBufferBase::editHandleColorSamples (void)
787 SFUInt32::EditHandlePtr
returnValue(
788 new SFUInt32::EditHandle(
790 this->getType().getFieldDesc(ColorSamplesFieldId
),
794 editSField(ColorSamplesFieldMask
);
799 GetFieldHandlePtr
RenderBufferBase::getHandleCoverageSamples (void) const
801 SFUInt32::GetHandlePtr
returnValue(
802 new SFUInt32::GetHandle(
804 this->getType().getFieldDesc(CoverageSamplesFieldId
),
805 const_cast<RenderBufferBase
*>(this)));
810 EditFieldHandlePtr
RenderBufferBase::editHandleCoverageSamples(void)
812 SFUInt32::EditHandlePtr
returnValue(
813 new SFUInt32::EditHandle(
815 this->getType().getFieldDesc(CoverageSamplesFieldId
),
819 editSField(CoverageSamplesFieldMask
);
824 GetFieldHandlePtr
RenderBufferBase::getHandleFixedSampleLocation (void) const
826 SFBool::GetHandlePtr
returnValue(
827 new SFBool::GetHandle(
828 &_sfFixedSampleLocation
,
829 this->getType().getFieldDesc(FixedSampleLocationFieldId
),
830 const_cast<RenderBufferBase
*>(this)));
835 EditFieldHandlePtr
RenderBufferBase::editHandleFixedSampleLocation(void)
837 SFBool::EditHandlePtr
returnValue(
838 new SFBool::EditHandle(
839 &_sfFixedSampleLocation
,
840 this->getType().getFieldDesc(FixedSampleLocationFieldId
),
844 editSField(FixedSampleLocationFieldMask
);
850 #ifdef OSG_MT_CPTR_ASPECT
851 void RenderBufferBase::execSyncV( FieldContainer
&oFrom
,
852 ConstFieldMaskArg whichField
,
853 AspectOffsetStore
&oOffsets
,
854 ConstFieldMaskArg syncMode
,
855 const UInt32 uiSyncInfo
)
857 RenderBuffer
*pThis
= static_cast<RenderBuffer
*>(this);
859 pThis
->execSync(static_cast<RenderBuffer
*>(&oFrom
),
868 #ifdef OSG_MT_CPTR_ASPECT
869 FieldContainer
*RenderBufferBase::createAspectCopy(
870 const FieldContainer
*pRefAspect
) const
872 RenderBuffer
*returnValue
;
874 newAspectCopy(returnValue
,
875 dynamic_cast<const RenderBuffer
*>(pRefAspect
),
876 dynamic_cast<const RenderBuffer
*>(this));
882 void RenderBufferBase::resolveLinks(void)
884 Inherited::resolveLinks();
886 static_cast<RenderBuffer
*>(this)->setImage(NULL
);