changed: gcc8 base update
[opensg.git] / Source / System / State / Base / OSGShaderStorageBufferObjRefChunkBase.cpp
blobcfbac0e31a73fd711cb713b3ab84cdb5b6eaf8e5
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 ShaderStorageBufferObjRefChunk!
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"
66 #include "OSGShaderStorageBufferObjRefChunkBase.h"
67 #include "OSGShaderStorageBufferObjRefChunk.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::ShaderStorageBufferObjRefChunk
78 See \ref PageSystemShaderStorageBufferObjRefChunk for a description.
80 This chunk wraps the OpenGL shader storage buffer object extension (ARB_shader_storage_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 either an OpenGL std140 or std430 compatible format.
83 Any shader, binding a shader storage block to the very same binding point, is expected to respect
84 the corresponding block layout.
86 This one differs from the ShaderStorageBufferObjStdLayoutChunk in that it does not manage the buffer by
87 itself , but just takes the GLid of that buffer. The idea is that the buffer of a GeoVectorPropertyBuffer can be
88 used if its layout is compatible to std140 or std430 format.
91 /***************************************************************************\
92 * Field Documentation *
93 \***************************************************************************/
95 /*! \var GLenum ShaderStorageBufferObjRefChunkBase::_sfOglGLId
96 The external OpenGL object id for this shader storage buffer object. This id is used as the GL object id iff the osgGLId is set to 0.
99 /*! \var GLenum ShaderStorageBufferObjRefChunkBase::_sfOsgGLId
100 The OpenSG GL object id for this shader storage buffer object. If this id is set the GL object id is determined by OpenSG. If this id equals 0, the oglGLId is used directly as the GL object id.
104 /***************************************************************************\
105 * FieldType/FieldTrait Instantiation *
106 \***************************************************************************/
108 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
109 PointerType FieldTraits<ShaderStorageBufferObjRefChunk *, nsOSG>::_type(
110 "ShaderStorageBufferObjRefChunkPtr",
111 "ShaderStorageBufferObjBaseChunkPtr",
112 ShaderStorageBufferObjRefChunk::getClassType(),
113 nsOSG);
114 #endif
116 OSG_FIELDTRAITS_GETTYPE_NS(ShaderStorageBufferObjRefChunk *, nsOSG)
118 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
119 ShaderStorageBufferObjRefChunk *,
120 nsOSG)
122 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
123 ShaderStorageBufferObjRefChunk *,
124 nsOSG)
126 /***************************************************************************\
127 * Field Description *
128 \***************************************************************************/
130 void ShaderStorageBufferObjRefChunkBase::classDescInserter(TypeObject &oType)
132 FieldDescriptionBase *pDesc = NULL;
135 pDesc = new SFGLenum::Description(
136 SFGLenum::getClassType(),
137 "oglGLId",
138 "The external OpenGL object id for this shader storage buffer object. This id is used as the GL object id iff the osgGLId is set to 0.\n",
139 OglGLIdFieldId, OglGLIdFieldMask,
140 true,
141 (Field::FClusterLocal),
142 static_cast<FieldEditMethodSig>(&ShaderStorageBufferObjRefChunk::editHandleOglGLId),
143 static_cast<FieldGetMethodSig >(&ShaderStorageBufferObjRefChunk::getHandleOglGLId));
145 oType.addInitialDesc(pDesc);
147 pDesc = new SFGLenum::Description(
148 SFGLenum::getClassType(),
149 "osgGLId",
150 "The OpenSG GL object id for this shader storage buffer object. If this id is set the GL object id is determined by OpenSG. If this id equals 0, the oglGLId is used directly as the GL object id.\n",
151 OsgGLIdFieldId, OsgGLIdFieldMask,
152 true,
153 (Field::FClusterLocal),
154 static_cast<FieldEditMethodSig>(&ShaderStorageBufferObjRefChunk::editHandleOsgGLId),
155 static_cast<FieldGetMethodSig >(&ShaderStorageBufferObjRefChunk::getHandleOsgGLId));
157 oType.addInitialDesc(pDesc);
161 ShaderStorageBufferObjRefChunkBase::TypeObject ShaderStorageBufferObjRefChunkBase::_type(
162 ShaderStorageBufferObjRefChunkBase::getClassname(),
163 Inherited::getClassname(),
164 "NULL",
165 nsOSG, //Namespace
166 reinterpret_cast<PrototypeCreateF>(&ShaderStorageBufferObjRefChunkBase::createEmptyLocal),
167 reinterpret_cast<InitContainerF>(&ShaderStorageBufferObjRefChunk::initMethod),
168 reinterpret_cast<ExitContainerF>(&ShaderStorageBufferObjRefChunk::exitMethod),
169 reinterpret_cast<InitalInsertDescFunc>(
170 reinterpret_cast<void *>(&ShaderStorageBufferObjRefChunk::classDescInserter)),
171 false,
173 "<?xml version=\"1.0\"?>\n"
174 "\n"
175 "<FieldContainer\n"
176 " name=\"ShaderStorageBufferObjRefChunk\"\n"
177 " parent=\"ShaderStorageBufferObjBaseChunk\"\n"
178 " library=\"System\"\n"
179 " pointerfieldtypes=\"both\"\n"
180 " structure=\"concrete\"\n"
181 " systemcomponent=\"true\"\n"
182 " parentsystemcomponent=\"true\"\n"
183 " decoratable=\"false\"\n"
184 " useLocalIncludes=\"false\"\n"
185 " docGroupBase=\"GrpSystemState\"\n"
186 " >\n"
187 " See \\ref PageSystemShaderStorageBufferObjRefChunk for a description.\n"
188 "\n"
189 " This chunk wraps the OpenGL shader storage buffer object extension (ARB_shader_storage_buffer_object). \n"
190 " Basically, it holds a raw memory buffer and a buffer object binding point. The raw memory \n"
191 " buffer is expected to be provided by the chunk user in either an OpenGL std140 or std430 compatible format. \n"
192 " Any shader, binding a shader storage block to the very same binding point, is expected to respect \n"
193 " the corresponding block layout.\n"
194 "\n"
195 " This one differs from the ShaderStorageBufferObjStdLayoutChunk in that it does not manage the buffer by\n"
196 " itself , but just takes the GLid of that buffer. The idea is that the buffer of a GeoVectorPropertyBuffer can be \n"
197 " used if its layout is compatible to std140 or std430 format.\n"
198 "\n"
199 " <Field\n"
200 " name=\"oglGLId\"\n"
201 " type=\"GLenum\"\n"
202 " cardinality=\"single\"\n"
203 " visibility=\"internal\"\n"
204 " access=\"public\"\n"
205 " defaultValue=\"0\"\n"
206 " fieldFlags=\"FClusterLocal\"\n"
207 " >\n"
208 " The external OpenGL object id for this shader storage buffer object. This id is used as the GL object id iff the osgGLId is set to 0.\n"
209 " </Field>\n"
210 "\n"
211 " <Field\n"
212 " name=\"osgGLId\"\n"
213 " type=\"GLenum\"\n"
214 " cardinality=\"single\"\n"
215 " visibility=\"internal\"\n"
216 " access=\"public\"\n"
217 " defaultValue=\"0\"\n"
218 " fieldFlags=\"FClusterLocal\"\n"
219 " >\n"
220 " The OpenSG GL object id for this shader storage buffer object. If this id is set the GL object id is determined by OpenSG. If this id equals 0, the oglGLId is used directly as the GL object id.\n"
221 " </Field>\n"
222 "</FieldContainer>\n",
223 "See \\ref PageSystemShaderStorageBufferObjRefChunk for a description.\n"
224 "\n"
225 "This chunk wraps the OpenGL shader storage buffer object extension (ARB_shader_storage_buffer_object). \n"
226 "Basically, it holds a raw memory buffer and a buffer object binding point. The raw memory \n"
227 "buffer is expected to be provided by the chunk user in either an OpenGL std140 or std430 compatible format. \n"
228 "Any shader, binding a shader storage block to the very same binding point, is expected to respect \n"
229 "the corresponding block layout.\n"
230 "\n"
231 "This one differs from the ShaderStorageBufferObjStdLayoutChunk in that it does not manage the buffer by\n"
232 "itself , but just takes the GLid of that buffer. The idea is that the buffer of a GeoVectorPropertyBuffer can be \n"
233 "used if its layout is compatible to std140 or std430 format.\n"
236 /*------------------------------ get -----------------------------------*/
238 FieldContainerType &ShaderStorageBufferObjRefChunkBase::getType(void)
240 return _type;
243 const FieldContainerType &ShaderStorageBufferObjRefChunkBase::getType(void) const
245 return _type;
248 UInt32 ShaderStorageBufferObjRefChunkBase::getContainerSize(void) const
250 return sizeof(ShaderStorageBufferObjRefChunk);
253 /*------------------------- decorator get ------------------------------*/
256 SFGLenum *ShaderStorageBufferObjRefChunkBase::editSFOglGLId(void)
258 editSField(OglGLIdFieldMask);
260 return &_sfOglGLId;
263 const SFGLenum *ShaderStorageBufferObjRefChunkBase::getSFOglGLId(void) const
265 return &_sfOglGLId;
269 SFGLenum *ShaderStorageBufferObjRefChunkBase::editSFOsgGLId(void)
271 editSField(OsgGLIdFieldMask);
273 return &_sfOsgGLId;
276 const SFGLenum *ShaderStorageBufferObjRefChunkBase::getSFOsgGLId(void) const
278 return &_sfOsgGLId;
286 /*------------------------------ access -----------------------------------*/
288 SizeT ShaderStorageBufferObjRefChunkBase::getBinSize(ConstFieldMaskArg whichField)
290 SizeT returnValue = Inherited::getBinSize(whichField);
292 if(FieldBits::NoField != (OglGLIdFieldMask & whichField))
294 returnValue += _sfOglGLId.getBinSize();
296 if(FieldBits::NoField != (OsgGLIdFieldMask & whichField))
298 returnValue += _sfOsgGLId.getBinSize();
301 return returnValue;
304 void ShaderStorageBufferObjRefChunkBase::copyToBin(BinaryDataHandler &pMem,
305 ConstFieldMaskArg whichField)
307 Inherited::copyToBin(pMem, whichField);
309 if(FieldBits::NoField != (OglGLIdFieldMask & whichField))
311 _sfOglGLId.copyToBin(pMem);
313 if(FieldBits::NoField != (OsgGLIdFieldMask & whichField))
315 _sfOsgGLId.copyToBin(pMem);
319 void ShaderStorageBufferObjRefChunkBase::copyFromBin(BinaryDataHandler &pMem,
320 ConstFieldMaskArg whichField)
322 Inherited::copyFromBin(pMem, whichField);
324 if(FieldBits::NoField != (OglGLIdFieldMask & whichField))
326 editSField(OglGLIdFieldMask);
327 _sfOglGLId.copyFromBin(pMem);
329 if(FieldBits::NoField != (OsgGLIdFieldMask & whichField))
331 editSField(OsgGLIdFieldMask);
332 _sfOsgGLId.copyFromBin(pMem);
336 //! create a new instance of the class
337 ShaderStorageBufferObjRefChunkTransitPtr ShaderStorageBufferObjRefChunkBase::createLocal(BitVector bFlags)
339 ShaderStorageBufferObjRefChunkTransitPtr fc;
341 if(getClassType().getPrototype() != NULL)
343 FieldContainerTransitPtr tmpPtr =
344 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
346 fc = dynamic_pointer_cast<ShaderStorageBufferObjRefChunk>(tmpPtr);
349 return fc;
352 //! create a new instance of the class, copy the container flags
353 ShaderStorageBufferObjRefChunkTransitPtr ShaderStorageBufferObjRefChunkBase::createDependent(BitVector bFlags)
355 ShaderStorageBufferObjRefChunkTransitPtr fc;
357 if(getClassType().getPrototype() != NULL)
359 FieldContainerTransitPtr tmpPtr =
360 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
362 fc = dynamic_pointer_cast<ShaderStorageBufferObjRefChunk>(tmpPtr);
365 return fc;
368 //! create a new instance of the class
369 ShaderStorageBufferObjRefChunkTransitPtr ShaderStorageBufferObjRefChunkBase::create(void)
371 ShaderStorageBufferObjRefChunkTransitPtr fc;
373 if(getClassType().getPrototype() != NULL)
375 FieldContainerTransitPtr tmpPtr =
376 getClassType().getPrototype()-> shallowCopy();
378 fc = dynamic_pointer_cast<ShaderStorageBufferObjRefChunk>(tmpPtr);
381 return fc;
384 ShaderStorageBufferObjRefChunk *ShaderStorageBufferObjRefChunkBase::createEmptyLocal(BitVector bFlags)
386 ShaderStorageBufferObjRefChunk *returnValue;
388 newPtr<ShaderStorageBufferObjRefChunk>(returnValue, bFlags);
390 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
392 return returnValue;
395 //! create an empty new instance of the class, do not copy the prototype
396 ShaderStorageBufferObjRefChunk *ShaderStorageBufferObjRefChunkBase::createEmpty(void)
398 ShaderStorageBufferObjRefChunk *returnValue;
400 newPtr<ShaderStorageBufferObjRefChunk>(returnValue, Thread::getCurrentLocalFlags());
402 returnValue->_pFieldFlags->_bNamespaceMask &=
403 ~Thread::getCurrentLocalFlags();
405 return returnValue;
409 FieldContainerTransitPtr ShaderStorageBufferObjRefChunkBase::shallowCopyLocal(
410 BitVector bFlags) const
412 ShaderStorageBufferObjRefChunk *tmpPtr;
414 newPtr(tmpPtr, dynamic_cast<const ShaderStorageBufferObjRefChunk *>(this), bFlags);
416 FieldContainerTransitPtr returnValue(tmpPtr);
418 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
420 return returnValue;
423 FieldContainerTransitPtr ShaderStorageBufferObjRefChunkBase::shallowCopyDependent(
424 BitVector bFlags) const
426 ShaderStorageBufferObjRefChunk *tmpPtr;
428 newPtr(tmpPtr, dynamic_cast<const ShaderStorageBufferObjRefChunk *>(this), ~bFlags);
430 FieldContainerTransitPtr returnValue(tmpPtr);
432 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
434 return returnValue;
437 FieldContainerTransitPtr ShaderStorageBufferObjRefChunkBase::shallowCopy(void) const
439 ShaderStorageBufferObjRefChunk *tmpPtr;
441 newPtr(tmpPtr,
442 dynamic_cast<const ShaderStorageBufferObjRefChunk *>(this),
443 Thread::getCurrentLocalFlags());
445 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
447 FieldContainerTransitPtr returnValue(tmpPtr);
449 return returnValue;
455 /*------------------------- constructors ----------------------------------*/
457 ShaderStorageBufferObjRefChunkBase::ShaderStorageBufferObjRefChunkBase(void) :
458 Inherited(),
459 _sfOglGLId (GLenum(0)),
460 _sfOsgGLId (GLenum(0))
464 ShaderStorageBufferObjRefChunkBase::ShaderStorageBufferObjRefChunkBase(const ShaderStorageBufferObjRefChunkBase &source) :
465 Inherited(source),
466 _sfOglGLId (source._sfOglGLId ),
467 _sfOsgGLId (source._sfOsgGLId )
472 /*-------------------------- destructors ----------------------------------*/
474 ShaderStorageBufferObjRefChunkBase::~ShaderStorageBufferObjRefChunkBase(void)
479 GetFieldHandlePtr ShaderStorageBufferObjRefChunkBase::getHandleOglGLId (void) const
481 SFGLenum::GetHandlePtr returnValue(
482 new SFGLenum::GetHandle(
483 &_sfOglGLId,
484 this->getType().getFieldDesc(OglGLIdFieldId),
485 const_cast<ShaderStorageBufferObjRefChunkBase *>(this)));
487 return returnValue;
490 EditFieldHandlePtr ShaderStorageBufferObjRefChunkBase::editHandleOglGLId (void)
492 SFGLenum::EditHandlePtr returnValue(
493 new SFGLenum::EditHandle(
494 &_sfOglGLId,
495 this->getType().getFieldDesc(OglGLIdFieldId),
496 this));
499 editSField(OglGLIdFieldMask);
501 return returnValue;
504 GetFieldHandlePtr ShaderStorageBufferObjRefChunkBase::getHandleOsgGLId (void) const
506 SFGLenum::GetHandlePtr returnValue(
507 new SFGLenum::GetHandle(
508 &_sfOsgGLId,
509 this->getType().getFieldDesc(OsgGLIdFieldId),
510 const_cast<ShaderStorageBufferObjRefChunkBase *>(this)));
512 return returnValue;
515 EditFieldHandlePtr ShaderStorageBufferObjRefChunkBase::editHandleOsgGLId (void)
517 SFGLenum::EditHandlePtr returnValue(
518 new SFGLenum::EditHandle(
519 &_sfOsgGLId,
520 this->getType().getFieldDesc(OsgGLIdFieldId),
521 this));
524 editSField(OsgGLIdFieldMask);
526 return returnValue;
530 #ifdef OSG_MT_CPTR_ASPECT
531 void ShaderStorageBufferObjRefChunkBase::execSyncV( FieldContainer &oFrom,
532 ConstFieldMaskArg whichField,
533 AspectOffsetStore &oOffsets,
534 ConstFieldMaskArg syncMode,
535 const UInt32 uiSyncInfo)
537 ShaderStorageBufferObjRefChunk *pThis = static_cast<ShaderStorageBufferObjRefChunk *>(this);
539 pThis->execSync(static_cast<ShaderStorageBufferObjRefChunk *>(&oFrom),
540 whichField,
541 oOffsets,
542 syncMode,
543 uiSyncInfo);
545 #endif
548 #ifdef OSG_MT_CPTR_ASPECT
549 FieldContainer *ShaderStorageBufferObjRefChunkBase::createAspectCopy(
550 const FieldContainer *pRefAspect) const
552 ShaderStorageBufferObjRefChunk *returnValue;
554 newAspectCopy(returnValue,
555 dynamic_cast<const ShaderStorageBufferObjRefChunk *>(pRefAspect),
556 dynamic_cast<const ShaderStorageBufferObjRefChunk *>(this));
558 return returnValue;
560 #endif
562 void ShaderStorageBufferObjRefChunkBase::resolveLinks(void)
564 Inherited::resolveLinks();
570 OSG_END_NAMESPACE