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 UniformBufferObjStd140Chunk!
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"
66 #include "OSGUniformBufferObjStd140ChunkBase.h"
67 #include "OSGUniformBufferObjStd140Chunk.h"
69 #include <boost/bind.hpp>
73 /***************************************************************************\
75 \***************************************************************************/
77 /*! \class OSG::UniformBufferObjStd140Chunk
78 See \ref PageSystemUniformBufferObjChunk for a description.
80 This chunk wraps the OpenGL uniform buffer object extension (ARB_uniform_buffer_object).
81 Basically, it holds a raw memory buffer and a buffer object binding point. The raw memory
82 buffer is expected to be provided by the chunk user in a OpenGL std140 compatible format.
83 Any shader binding an uniform block to the very same binding point is expected to respect
84 the corresponding block layout.
87 /***************************************************************************\
88 * Field Documentation *
89 \***************************************************************************/
91 /*! \var GLenum UniformBufferObjStd140ChunkBase::_sfGLId
92 The OpenGL object id for this uniform buffer object.
95 /*! \var GLenum UniformBufferObjStd140ChunkBase::_sfUsage
96 Specifies the expected usage pattern of the data store. The symbolic constant must be
97 GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY,
98 GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY,
99 GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY.
102 /*! \var UInt8 UniformBufferObjStd140ChunkBase::_mfBuffer
103 The uniform buffer storage. The layout of this memory block is governed by the
104 shader uniform block layout according to OpenGL std140 specification.
108 /***************************************************************************\
109 * FieldType/FieldTrait Instantiation *
110 \***************************************************************************/
112 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
113 PointerType FieldTraits
<UniformBufferObjStd140Chunk
*, nsOSG
>::_type(
114 "UniformBufferObjStd140ChunkPtr",
115 "UniformBufferObjBaseChunkPtr",
116 UniformBufferObjStd140Chunk::getClassType(),
120 OSG_FIELDTRAITS_GETTYPE_NS(UniformBufferObjStd140Chunk
*, nsOSG
)
122 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
123 UniformBufferObjStd140Chunk
*,
126 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
127 UniformBufferObjStd140Chunk
*,
130 /***************************************************************************\
131 * Field Description *
132 \***************************************************************************/
134 void UniformBufferObjStd140ChunkBase::classDescInserter(TypeObject
&oType
)
136 FieldDescriptionBase
*pDesc
= NULL
;
139 pDesc
= new SFGLenum::Description(
140 SFGLenum::getClassType(),
142 "The OpenGL object id for this uniform buffer object.\n",
143 GLIdFieldId
, GLIdFieldMask
,
145 (Field::FClusterLocal
),
146 static_cast<FieldEditMethodSig
>(&UniformBufferObjStd140Chunk::editHandleGLId
),
147 static_cast<FieldGetMethodSig
>(&UniformBufferObjStd140Chunk::getHandleGLId
));
149 oType
.addInitialDesc(pDesc
);
151 pDesc
= new SFGLenum::Description(
152 SFGLenum::getClassType(),
154 "Specifies the expected usage pattern of the data store. The symbolic constant must be \n"
155 "GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY, \n"
156 "GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY, \n"
157 "GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY.\n",
158 UsageFieldId
, UsageFieldMask
,
160 (Field::SFDefaultFlags
| Field::FStdAccess
),
161 static_cast<FieldEditMethodSig
>(&UniformBufferObjStd140Chunk::editHandleUsage
),
162 static_cast<FieldGetMethodSig
>(&UniformBufferObjStd140Chunk::getHandleUsage
));
164 oType
.addInitialDesc(pDesc
);
166 pDesc
= new MFUInt8::Description(
167 MFUInt8::getClassType(),
169 "The uniform buffer storage. The layout of this memory block is governed by the\n"
170 "shader uniform block layout according to OpenGL std140 specification.\n",
171 BufferFieldId
, BufferFieldMask
,
173 (Field::MFDefaultFlags
| Field::FStdAccess
),
174 static_cast<FieldEditMethodSig
>(&UniformBufferObjStd140Chunk::editHandleBuffer
),
175 static_cast<FieldGetMethodSig
>(&UniformBufferObjStd140Chunk::getHandleBuffer
));
177 oType
.addInitialDesc(pDesc
);
181 UniformBufferObjStd140ChunkBase::TypeObject
UniformBufferObjStd140ChunkBase::_type(
182 UniformBufferObjStd140ChunkBase::getClassname(),
183 Inherited::getClassname(),
186 reinterpret_cast<PrototypeCreateF
>(&UniformBufferObjStd140ChunkBase::createEmptyLocal
),
187 reinterpret_cast<InitContainerF
>(&UniformBufferObjStd140Chunk::initMethod
),
188 reinterpret_cast<ExitContainerF
>(&UniformBufferObjStd140Chunk::exitMethod
),
189 reinterpret_cast<InitalInsertDescFunc
>(
190 reinterpret_cast<void *>(&UniformBufferObjStd140Chunk::classDescInserter
)),
193 "<?xml version=\"1.0\"?>\n"
196 " name=\"UniformBufferObjStd140Chunk\"\n"
197 " parent=\"UniformBufferObjBaseChunk\"\n"
198 " library=\"System\"\n"
199 " pointerfieldtypes=\"both\"\n"
200 " structure=\"concrete\"\n"
201 " systemcomponent=\"true\"\n"
202 " parentsystemcomponent=\"true\"\n"
203 " decoratable=\"false\"\n"
204 " useLocalIncludes=\"false\"\n"
205 " docGroupBase=\"GrpSystemState\"\n"
207 " See \\ref PageSystemUniformBufferObjChunk for a description.\n"
209 " This chunk wraps the OpenGL uniform buffer object extension (ARB_uniform_buffer_object). \n"
210 " Basically, it holds a raw memory buffer and a buffer object binding point. The raw memory \n"
211 " buffer is expected to be provided by the chunk user in a OpenGL std140 compatible format. \n"
212 " Any shader binding an uniform block to the very same binding point is expected to respect \n"
213 " the corresponding block layout.\n"
218 " cardinality=\"single\"\n"
219 " visibility=\"internal\"\n"
220 " access=\"public\"\n"
221 " defaultValue=\"0\"\n"
222 " fieldFlags=\"FClusterLocal\"\n"
224 " The OpenGL object id for this uniform buffer object.\n"
229 " cardinality=\"single\"\n"
230 " visibility=\"external\"\n"
231 " access=\"public\"\n"
232 " defaultValue=\"GL_STATIC_DRAW\"\n"
233 " potential_values=\"GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY, GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY, GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, GL_DYNAMIC_COPY\"\n"
235 " Specifies the expected usage pattern of the data store. The symbolic constant must be \n"
236 " GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY, \n"
237 " GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY, \n"
238 " GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY.\n"
243 " cardinality=\"multi\"\n"
244 " visibility=\"external\"\n"
245 " access=\"public\"\n"
247 "\tThe uniform buffer storage. The layout of this memory block is governed by the\n"
248 " shader uniform block layout according to OpenGL std140 specification.\n"
250 "</FieldContainer>\n",
251 "See \\ref PageSystemUniformBufferObjChunk for a description.\n"
253 "This chunk wraps the OpenGL uniform buffer object extension (ARB_uniform_buffer_object). \n"
254 "Basically, it holds a raw memory buffer and a buffer object binding point. The raw memory \n"
255 "buffer is expected to be provided by the chunk user in a OpenGL std140 compatible format. \n"
256 "Any shader binding an uniform block to the very same binding point is expected to respect \n"
257 "the corresponding block layout.\n"
260 /*------------------------------ get -----------------------------------*/
262 FieldContainerType
&UniformBufferObjStd140ChunkBase::getType(void)
267 const FieldContainerType
&UniformBufferObjStd140ChunkBase::getType(void) const
272 UInt32
UniformBufferObjStd140ChunkBase::getContainerSize(void) const
274 return sizeof(UniformBufferObjStd140Chunk
);
277 /*------------------------- decorator get ------------------------------*/
280 SFGLenum
*UniformBufferObjStd140ChunkBase::editSFGLId(void)
282 editSField(GLIdFieldMask
);
287 const SFGLenum
*UniformBufferObjStd140ChunkBase::getSFGLId(void) const
293 SFGLenum
*UniformBufferObjStd140ChunkBase::editSFUsage(void)
295 editSField(UsageFieldMask
);
300 const SFGLenum
*UniformBufferObjStd140ChunkBase::getSFUsage(void) const
306 MFUInt8
*UniformBufferObjStd140ChunkBase::editMFBuffer(void)
308 editMField(BufferFieldMask
, _mfBuffer
);
313 const MFUInt8
*UniformBufferObjStd140ChunkBase::getMFBuffer(void) const
323 /*------------------------------ access -----------------------------------*/
325 SizeT
UniformBufferObjStd140ChunkBase::getBinSize(ConstFieldMaskArg whichField
)
327 SizeT returnValue
= Inherited::getBinSize(whichField
);
329 if(FieldBits::NoField
!= (GLIdFieldMask
& whichField
))
331 returnValue
+= _sfGLId
.getBinSize();
333 if(FieldBits::NoField
!= (UsageFieldMask
& whichField
))
335 returnValue
+= _sfUsage
.getBinSize();
337 if(FieldBits::NoField
!= (BufferFieldMask
& whichField
))
339 returnValue
+= _mfBuffer
.getBinSize();
345 void UniformBufferObjStd140ChunkBase::copyToBin(BinaryDataHandler
&pMem
,
346 ConstFieldMaskArg whichField
)
348 Inherited::copyToBin(pMem
, whichField
);
350 if(FieldBits::NoField
!= (GLIdFieldMask
& whichField
))
352 _sfGLId
.copyToBin(pMem
);
354 if(FieldBits::NoField
!= (UsageFieldMask
& whichField
))
356 _sfUsage
.copyToBin(pMem
);
358 if(FieldBits::NoField
!= (BufferFieldMask
& whichField
))
360 _mfBuffer
.copyToBin(pMem
);
364 void UniformBufferObjStd140ChunkBase::copyFromBin(BinaryDataHandler
&pMem
,
365 ConstFieldMaskArg whichField
)
367 Inherited::copyFromBin(pMem
, whichField
);
369 if(FieldBits::NoField
!= (GLIdFieldMask
& whichField
))
371 editSField(GLIdFieldMask
);
372 _sfGLId
.copyFromBin(pMem
);
374 if(FieldBits::NoField
!= (UsageFieldMask
& whichField
))
376 editSField(UsageFieldMask
);
377 _sfUsage
.copyFromBin(pMem
);
379 if(FieldBits::NoField
!= (BufferFieldMask
& whichField
))
381 editMField(BufferFieldMask
, _mfBuffer
);
382 _mfBuffer
.copyFromBin(pMem
);
386 //! create a new instance of the class
387 UniformBufferObjStd140ChunkTransitPtr
UniformBufferObjStd140ChunkBase::createLocal(BitVector bFlags
)
389 UniformBufferObjStd140ChunkTransitPtr fc
;
391 if(getClassType().getPrototype() != NULL
)
393 FieldContainerTransitPtr tmpPtr
=
394 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
396 fc
= dynamic_pointer_cast
<UniformBufferObjStd140Chunk
>(tmpPtr
);
402 //! create a new instance of the class, copy the container flags
403 UniformBufferObjStd140ChunkTransitPtr
UniformBufferObjStd140ChunkBase::createDependent(BitVector bFlags
)
405 UniformBufferObjStd140ChunkTransitPtr fc
;
407 if(getClassType().getPrototype() != NULL
)
409 FieldContainerTransitPtr tmpPtr
=
410 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
412 fc
= dynamic_pointer_cast
<UniformBufferObjStd140Chunk
>(tmpPtr
);
418 //! create a new instance of the class
419 UniformBufferObjStd140ChunkTransitPtr
UniformBufferObjStd140ChunkBase::create(void)
421 UniformBufferObjStd140ChunkTransitPtr fc
;
423 if(getClassType().getPrototype() != NULL
)
425 FieldContainerTransitPtr tmpPtr
=
426 getClassType().getPrototype()-> shallowCopy();
428 fc
= dynamic_pointer_cast
<UniformBufferObjStd140Chunk
>(tmpPtr
);
434 UniformBufferObjStd140Chunk
*UniformBufferObjStd140ChunkBase::createEmptyLocal(BitVector bFlags
)
436 UniformBufferObjStd140Chunk
*returnValue
;
438 newPtr
<UniformBufferObjStd140Chunk
>(returnValue
, bFlags
);
440 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
445 //! create an empty new instance of the class, do not copy the prototype
446 UniformBufferObjStd140Chunk
*UniformBufferObjStd140ChunkBase::createEmpty(void)
448 UniformBufferObjStd140Chunk
*returnValue
;
450 newPtr
<UniformBufferObjStd140Chunk
>(returnValue
, Thread::getCurrentLocalFlags());
452 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
453 ~Thread::getCurrentLocalFlags();
459 FieldContainerTransitPtr
UniformBufferObjStd140ChunkBase::shallowCopyLocal(
460 BitVector bFlags
) const
462 UniformBufferObjStd140Chunk
*tmpPtr
;
464 newPtr(tmpPtr
, dynamic_cast<const UniformBufferObjStd140Chunk
*>(this), bFlags
);
466 FieldContainerTransitPtr
returnValue(tmpPtr
);
468 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
473 FieldContainerTransitPtr
UniformBufferObjStd140ChunkBase::shallowCopyDependent(
474 BitVector bFlags
) const
476 UniformBufferObjStd140Chunk
*tmpPtr
;
478 newPtr(tmpPtr
, dynamic_cast<const UniformBufferObjStd140Chunk
*>(this), ~bFlags
);
480 FieldContainerTransitPtr
returnValue(tmpPtr
);
482 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
487 FieldContainerTransitPtr
UniformBufferObjStd140ChunkBase::shallowCopy(void) const
489 UniformBufferObjStd140Chunk
*tmpPtr
;
492 dynamic_cast<const UniformBufferObjStd140Chunk
*>(this),
493 Thread::getCurrentLocalFlags());
495 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
497 FieldContainerTransitPtr
returnValue(tmpPtr
);
505 /*------------------------- constructors ----------------------------------*/
507 UniformBufferObjStd140ChunkBase::UniformBufferObjStd140ChunkBase(void) :
510 _sfUsage (GLenum(GL_STATIC_DRAW
)),
515 UniformBufferObjStd140ChunkBase::UniformBufferObjStd140ChunkBase(const UniformBufferObjStd140ChunkBase
&source
) :
517 _sfGLId (source
._sfGLId
),
518 _sfUsage (source
._sfUsage
),
519 _mfBuffer (source
._mfBuffer
)
524 /*-------------------------- destructors ----------------------------------*/
526 UniformBufferObjStd140ChunkBase::~UniformBufferObjStd140ChunkBase(void)
531 GetFieldHandlePtr
UniformBufferObjStd140ChunkBase::getHandleGLId (void) const
533 SFGLenum::GetHandlePtr
returnValue(
534 new SFGLenum::GetHandle(
536 this->getType().getFieldDesc(GLIdFieldId
),
537 const_cast<UniformBufferObjStd140ChunkBase
*>(this)));
542 EditFieldHandlePtr
UniformBufferObjStd140ChunkBase::editHandleGLId (void)
544 SFGLenum::EditHandlePtr
returnValue(
545 new SFGLenum::EditHandle(
547 this->getType().getFieldDesc(GLIdFieldId
),
551 editSField(GLIdFieldMask
);
556 GetFieldHandlePtr
UniformBufferObjStd140ChunkBase::getHandleUsage (void) const
558 SFGLenum::GetHandlePtr
returnValue(
559 new SFGLenum::GetHandle(
561 this->getType().getFieldDesc(UsageFieldId
),
562 const_cast<UniformBufferObjStd140ChunkBase
*>(this)));
567 EditFieldHandlePtr
UniformBufferObjStd140ChunkBase::editHandleUsage (void)
569 SFGLenum::EditHandlePtr
returnValue(
570 new SFGLenum::EditHandle(
572 this->getType().getFieldDesc(UsageFieldId
),
576 editSField(UsageFieldMask
);
581 GetFieldHandlePtr
UniformBufferObjStd140ChunkBase::getHandleBuffer (void) const
583 MFUInt8::GetHandlePtr
returnValue(
584 new MFUInt8::GetHandle(
586 this->getType().getFieldDesc(BufferFieldId
),
587 const_cast<UniformBufferObjStd140ChunkBase
*>(this)));
592 EditFieldHandlePtr
UniformBufferObjStd140ChunkBase::editHandleBuffer (void)
594 MFUInt8::EditHandlePtr
returnValue(
595 new MFUInt8::EditHandle(
597 this->getType().getFieldDesc(BufferFieldId
),
601 editMField(BufferFieldMask
, _mfBuffer
);
607 #ifdef OSG_MT_CPTR_ASPECT
608 void UniformBufferObjStd140ChunkBase::execSyncV( FieldContainer
&oFrom
,
609 ConstFieldMaskArg whichField
,
610 AspectOffsetStore
&oOffsets
,
611 ConstFieldMaskArg syncMode
,
612 const UInt32 uiSyncInfo
)
614 UniformBufferObjStd140Chunk
*pThis
= static_cast<UniformBufferObjStd140Chunk
*>(this);
616 pThis
->execSync(static_cast<UniformBufferObjStd140Chunk
*>(&oFrom
),
625 #ifdef OSG_MT_CPTR_ASPECT
626 FieldContainer
*UniformBufferObjStd140ChunkBase::createAspectCopy(
627 const FieldContainer
*pRefAspect
) const
629 UniformBufferObjStd140Chunk
*returnValue
;
631 newAspectCopy(returnValue
,
632 dynamic_cast<const UniformBufferObjStd140Chunk
*>(pRefAspect
),
633 dynamic_cast<const UniformBufferObjStd140Chunk
*>(this));
639 void UniformBufferObjStd140ChunkBase::resolveLinks(void)
641 Inherited::resolveLinks();
643 #ifdef OSG_MT_CPTR_ASPECT
644 AspectOffsetStore oOffsets
;
646 _pAspectStore
->fillOffsetArray(oOffsets
, this);
649 #ifdef OSG_MT_CPTR_ASPECT
650 _mfBuffer
.terminateShare(Thread::getCurrentAspect(),