Hi Carsten and Gerrit,
Ok I will give it a try.
Attached you can find a first version of the changes. I have added a osgGLId field to the ref property classes. I still use the inherited GLId field, but I have added an getOglGLId/setOglGLId API. I have still an issue with the implementation since in the former cpp-files you can find a few statements with getGLId() != 0 and I'm unsure how to handle these correctly. I have replace these calls by (getOsgGLId() != 0 || getOglGLId() != 0). Can I safely use this->getOpenGLId(pEnv) != 0 instead. Especially, in the integral ref property implementation of the changeFrom function, their is a call to a GeoIntegralProperty::getGLId() (line 165) that can not be replaced with my schema since getOsgGLId()/getOglGLId() are unknown here.
Do you have an idea how I should implement this reasonably? Best, JohannesP.S.: I also have the ShaderStorageBufferObjRef finished. This does not have any unclear issues. But since I was recently forced to introduce a common base class for the ShaderStorageBufferObj chunk classes and one for the UniformBufferObj chunk classes, I will send them separately. This ssbo/ubo patch exceeds the 200kB limit of the mailing list and therefore I allow me to send this patch directly to Carsten. Hope that this is fine for you.
diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.cpp d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.cpp --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.cpp 2017-05-11 11:33:54.387564100 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.cpp 2017-05-11 11:11:59.379763500 +0200 @@ -117,22 +117,47 @@ void GeoIntegralBufferRefProperty::dump( SLOG << "Dump GeoIntegralBufferRefProperty NI" << std::endl; } +/*------------------------------ tools --------------------------------------*/ + +void GeoIntegralBufferRefProperty::validate(DrawEnv *pEnv) +{ + if(this->getOsgGLId() != 0) + { + pEnv->getWindow()->validateGLObject(this->getOsgGLId(), + pEnv ); + } +} + +Int32 GeoIntegralBufferRefProperty::getOpenGLId(DrawEnv *pEnv) +{ + if(this->getOsgGLId() != 0) + { + return pEnv->getWindow()->getGLObjectId(this->getOsgGLId()); + } + else + { + return this->getOglGLId(); + } +} + void GeoIntegralBufferRefProperty::activate(DrawEnv *pEnv, UInt32 slot) { - Window *win = pEnv->getWindow(); - - if(!win->hasExtOrVersion(_extVertexBufferObject, 0x0105, 0x0200)) + Window *pWin = pEnv->getWindow(); + + if(!pWin->hasExtOrVersion(_extVertexBufferObject, 0x0105, 0x0200)) return; - if(getGLId() != 0 && getUseVBO()) // Do we have a VBO? + if((getOsgGLId() != 0 || getOglGLId() != 0) && getUseVBO()) // Do we have a VBO? { + validate(pEnv); + GLuint id = this->getOpenGLId(pEnv); + OSGGETGLFUNCBYID_GL3_ES( glBindBuffer, osgGlBindBuffer, _funcBindBuffer, - win); + pWin); - osgGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, - getGLId()); + osgGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, id); } } @@ -145,22 +170,24 @@ void GeoIntegralBufferRefProperty::chang if(old == this) return; - Window *win = pEnv->getWindow(); + Window *pWin = pEnv->getWindow(); GeoIntegralProperty *o = dynamic_cast<GeoIntegralProperty*>(old); - if(!win->hasExtOrVersion(_extVertexBufferObject, 0x0105, 0x0200)) + if(!pWin->hasExtOrVersion(_extVertexBufferObject, 0x0105, 0x0200)) return; OSGGETGLFUNCBYID_GL3_ES( glBindBuffer, osgGlBindBuffer, _funcBindBuffer, - win); + pWin); - if(getGLId() != 0 && getUseVBO()) // Do we have a VBO? + if((getOsgGLId() != 0 || getOglGLId() != 0) && getUseVBO()) // Do we have a VBO? { - osgGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, - getGLId()); + validate(pEnv); + GLuint id = this->getOpenGLId(pEnv); + + osgGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, id); } else if(o != NULL && o->getGLId() != 0 && o->getUseVBO()) { @@ -172,10 +199,13 @@ void *GeoIntegralBufferRefProperty::mapB { void *returnValue = NULL; - if((getUseVBO() == true) && (getGLId() != 0)) + if((getUseVBO() == true) && (getOsgGLId() != 0 || getOglGLId() != 0)) { Window *pWin = pEnv->getWindow(); + validate(pEnv); + GLuint id = this->getOpenGLId(pEnv); + osgSinkUnusedWarning(pWin); OSGGETGLFUNCBYID_GL3_ES( glBindBuffer, @@ -188,8 +218,7 @@ void *GeoIntegralBufferRefProperty::mapB _funcMapBuffer, pWin); - osgGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, - getGLId()); + osgGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, id); returnValue = osgGlMapBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, eAccess); @@ -203,10 +232,13 @@ bool GeoIntegralBufferRefProperty::unmap { bool returnValue = true; - if((getUseVBO() == true) && (getGLId() != 0)) + if((getUseVBO() == true) && (getOsgGLId() != 0 || getOglGLId() != 0)) { Window *pWin = pEnv->getWindow(); + validate(pEnv); + GLuint id = this->getOpenGLId(pEnv); + osgSinkUnusedWarning(pWin); OSGGETGLFUNCBYID_GL3_ES( glBindBuffer, @@ -219,8 +251,7 @@ bool GeoIntegralBufferRefProperty::unmap _funcUnmapBuffer, pWin); - osgGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, - getGLId()); + osgGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, id); returnValue = osgGlUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB) != 0; diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.fcd d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.fcd --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.fcd 2017-05-11 11:33:54.388564100 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.fcd 2017-05-11 10:47:15.291179500 +0200 @@ -12,4 +12,20 @@ childFields="both" docGroupBase="GrpDrawablesGeometry" > + + <Field + name="osgGLId" + type="UInt32" + cardinality="single" + visibility="internal" + access="public" + defaultValue="0" + fieldFlags="FClusterLocal" + > + The OpenSG GL object id for this geo property buffer object. If osgGLId is set, the GL object id + is determined by OpenSG. If osgGLId equals 0, the GLId is used directly as the GL object id. + An API getOglGLId()/setOglGLId() is provided to get/set the inherited GLId. This brings the + interface more in line to the TextureObjRefChunk and the ShaderStorageBufferRefObjChunk + classes. + </Field> </FieldContainer> diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.h d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.h --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.h 2017-05-11 11:33:54.388564100 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.h 2017-05-11 10:52:51.819676500 +0200 @@ -78,7 +78,10 @@ class OSG_DRAWABLE_DLLMAPPING GeoIntegra /*! \name State Commands */ /*! \{ */ - void setGLId(UInt32 uiGLId); + void setGLId (UInt32 uiGLId); + + UInt32 getOglGLId (void) const; + void setOglGLId (UInt32 uiGLId); /*! \} */ /*---------------------------------------------------------------------*/ @@ -101,6 +104,14 @@ class OSG_DRAWABLE_DLLMAPPING GeoIntegra /*! \} */ /*---------------------------------------------------------------------*/ + /*! \name OpenGL handling */ + /*! \{ */ + + virtual void validate (DrawEnv *pEnv); + virtual Int32 getOpenGLId (DrawEnv *pEnv); + + /*! \} */ + /*---------------------------------------------------------------------*/ /*! \name Output */ /*! \{ */ diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.inl d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.inl --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.inl 2017-05-11 11:33:54.389564200 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefProperty.inl 2017-05-11 11:00:17.927742900 +0200 @@ -46,4 +46,16 @@ void GeoIntegralBufferRefProperty::setGL Inherited::setGLId(uiGLId); } +inline +UInt32 GeoIntegralBufferRefProperty::getOglGLId(void) const +{ + return Inherited::getGLId(); +} + +inline +void GeoIntegralBufferRefProperty::setOglGLId(UInt32 uiGLId) +{ + Inherited::setGLId(uiGLId); +} + OSG_END_NAMESPACE diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefPropertyBase.cpp d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefPropertyBase.cpp --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefPropertyBase.cpp 2017-05-11 11:33:54.389564200 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefPropertyBase.cpp 2017-05-11 10:51:06.666413500 +0200 @@ -82,6 +82,14 @@ OSG_BEGIN_NAMESPACE * Field Documentation * \***************************************************************************/ +/*! \var UInt32 GeoIntegralBufferRefPropertyBase::_sfOsgGLId + The OpenSG GL object id for this geo property buffer object. If osgGLId is set, the GL object id + is determined by OpenSG. If osgGLId equals 0, the GLId is used directly as the GL object id. + An API getOglGLId()/setOglGLId() is provided to get/set the inherited GLId. This brings the + interface more in line to the TextureObjRefChunk and the ShaderStorageBufferRefObjChunk + classes. +*/ + /***************************************************************************\ * FieldType/FieldTrait Instantiation * @@ -129,6 +137,24 @@ OSG_EXPORT_PTR_MFIELD(ChildPointerMField void GeoIntegralBufferRefPropertyBase::classDescInserter(TypeObject &oType) { + FieldDescriptionBase *pDesc = NULL; + + + pDesc = new SFUInt32::Description( + SFUInt32::getClassType(), + "osgGLId", + "The OpenSG GL object id for this geo property buffer object. If osgGLId is set, the GL object id\n" + "is determined by OpenSG. If osgGLId equals 0, the GLId is used directly as the GL object id.\n" + "An API getOglGLId()/setOglGLId() is provided to get/set the inherited GLId. This brings the\n" + "interface more in line to the TextureObjRefChunk and the ShaderStorageBufferRefObjChunk\n" + "classes.\n", + OsgGLIdFieldId, OsgGLIdFieldMask, + true, + (Field::FClusterLocal), + static_cast<FieldEditMethodSig>(&GeoIntegralBufferRefProperty::editHandleOsgGLId), + static_cast<FieldGetMethodSig >(&GeoIntegralBufferRefProperty::getHandleOsgGLId)); + + oType.addInitialDesc(pDesc); } @@ -143,20 +169,36 @@ GeoIntegralBufferRefPropertyBase::TypeOb reinterpret_cast<InitalInsertDescFunc>(&GeoIntegralBufferRefProperty::classDescInserter), false, 0, - "<?xml version=\"1.0\"?>\n" - "\n" - "<FieldContainer\n" - " name=\"GeoIntegralBufferRefProperty\"\n" - " parent=\"GeoIntegralBufferProperty\"\n" - " library=\"Drawable\"\n" - " pointerfieldtypes=\"both\"\n" - " structure=\"concrete\"\n" - " systemcomponent=\"true\"\n" - " parentsystemcomponent=\"true\"\n" - " decoratable=\"false\"\n" - " childFields=\"both\"\n" - " docGroupBase=\"GrpDrawablesGeometry\"\n" - " >\n" + "<?xml version=\"1.0\"?>\n" + "\n" + "<FieldContainer\n" + " name=\"GeoIntegralBufferRefProperty\"\n" + " parent=\"GeoIntegralBufferProperty\"\n" + " library=\"Drawable\"\n" + " pointerfieldtypes=\"both\"\n" + " structure=\"concrete\"\n" + " systemcomponent=\"true\"\n" + " parentsystemcomponent=\"true\"\n" + " decoratable=\"false\"\n" + " childFields=\"both\"\n" + " docGroupBase=\"GrpDrawablesGeometry\"\n" + " >\n" + "\n" + " <Field\n" + " name=\"osgGLId\"\n" + " type=\"UInt32\"\n" + " cardinality=\"single\"\n" + " visibility=\"internal\"\n" + " access=\"public\"\n" + " defaultValue=\"0\"\n" + " fieldFlags=\"FClusterLocal\"\n" + "\t>\n" + " The OpenSG GL object id for this geo property buffer object. If osgGLId is set, the GL object id\n" + " is determined by OpenSG. If osgGLId equals 0, the GLId is used directly as the GL object id.\n" + " An API getOglGLId()/setOglGLId() is provided to get/set the inherited GLId. This brings the\n" + " interface more in line to the TextureObjRefChunk and the ShaderStorageBufferRefObjChunk\n" + " classes.\n" + " </Field>\n" "</FieldContainer>\n", "" ); @@ -181,6 +223,19 @@ UInt32 GeoIntegralBufferRefPropertyBase: /*------------------------- decorator get ------------------------------*/ +SFUInt32 *GeoIntegralBufferRefPropertyBase::editSFOsgGLId(void) +{ + editSField(OsgGLIdFieldMask); + + return &_sfOsgGLId; +} + +const SFUInt32 *GeoIntegralBufferRefPropertyBase::getSFOsgGLId(void) const +{ + return &_sfOsgGLId; +} + + @@ -191,6 +246,10 @@ SizeT GeoIntegralBufferRefPropertyBase:: { SizeT returnValue = Inherited::getBinSize(whichField); + if(FieldBits::NoField != (OsgGLIdFieldMask & whichField)) + { + returnValue += _sfOsgGLId.getBinSize(); + } return returnValue; } @@ -200,6 +259,10 @@ void GeoIntegralBufferRefPropertyBase::c { Inherited::copyToBin(pMem, whichField); + if(FieldBits::NoField != (OsgGLIdFieldMask & whichField)) + { + _sfOsgGLId.copyToBin(pMem); + } } void GeoIntegralBufferRefPropertyBase::copyFromBin(BinaryDataHandler &pMem, @@ -207,6 +270,11 @@ void GeoIntegralBufferRefPropertyBase::c { Inherited::copyFromBin(pMem, whichField); + if(FieldBits::NoField != (OsgGLIdFieldMask & whichField)) + { + editSField(OsgGLIdFieldMask); + _sfOsgGLId.copyFromBin(pMem); + } } //! create a new instance of the class @@ -331,12 +399,14 @@ FieldContainerTransitPtr GeoIntegralBuff /*------------------------- constructors ----------------------------------*/ GeoIntegralBufferRefPropertyBase::GeoIntegralBufferRefPropertyBase(void) : - Inherited() + Inherited(), + _sfOsgGLId (UInt32(0)) { } GeoIntegralBufferRefPropertyBase::GeoIntegralBufferRefPropertyBase(const GeoIntegralBufferRefPropertyBase &source) : - Inherited(source) + Inherited(source), + _sfOsgGLId (source._sfOsgGLId ) { } @@ -348,6 +418,31 @@ GeoIntegralBufferRefPropertyBase::~GeoIn } +GetFieldHandlePtr GeoIntegralBufferRefPropertyBase::getHandleOsgGLId (void) const +{ + SFUInt32::GetHandlePtr returnValue( + new SFUInt32::GetHandle( + &_sfOsgGLId, + this->getType().getFieldDesc(OsgGLIdFieldId), + const_cast<GeoIntegralBufferRefPropertyBase *>(this))); + + return returnValue; +} + +EditFieldHandlePtr GeoIntegralBufferRefPropertyBase::editHandleOsgGLId (void) +{ + SFUInt32::EditHandlePtr returnValue( + new SFUInt32::EditHandle( + &_sfOsgGLId, + this->getType().getFieldDesc(OsgGLIdFieldId), + this)); + + + editSField(OsgGLIdFieldMask); + + return returnValue; +} + #ifdef OSG_MT_CPTR_ASPECT void GeoIntegralBufferRefPropertyBase::execSyncV( FieldContainer &oFrom, diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefPropertyBase.h d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefPropertyBase.h --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefPropertyBase.h 2017-05-11 11:33:54.389564200 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefPropertyBase.h 2017-05-11 10:51:06.672413800 +0200 @@ -65,6 +65,7 @@ #include "OSGGeoIntegralBufferProperty.h" // Parent +#include "OSGSysFields.h" // OsgGLId type #include "OSGGeoIntegralBufferRefPropertyFields.h" @@ -91,6 +92,18 @@ class OSG_DRAWABLE_DLLMAPPING GeoIntegra public: + enum + { + OsgGLIdFieldId = Inherited::NextFieldId, + NextFieldId = OsgGLIdFieldId + 1 + }; + + static const OSG::BitVector OsgGLIdFieldMask = + (TypeTraits<BitVector>::One << OsgGLIdFieldId); + static const OSG::BitVector NextFieldMask = + (TypeTraits<BitVector>::One << NextFieldId); + + typedef SFUInt32 SFOsgGLIdType; /*---------------------------------------------------------------------*/ /*! \name Class Get */ @@ -112,6 +125,31 @@ class OSG_DRAWABLE_DLLMAPPING GeoIntegra /*! \} */ /*---------------------------------------------------------------------*/ + /*! \name Field Get */ + /*! \{ */ + + + SFUInt32 *editSFOsgGLId (void); + const SFUInt32 *getSFOsgGLId (void) const; + + + UInt32 &editOsgGLId (void); + UInt32 getOsgGLId (void) const; + + /*! \} */ + /*---------------------------------------------------------------------*/ + /*! \name Field Set */ + /*! \{ */ + + void setOsgGLId (const UInt32 value); + + /*! \} */ + /*---------------------------------------------------------------------*/ + /*! \name Ptr MField Set */ + /*! \{ */ + + /*! \} */ + /*---------------------------------------------------------------------*/ /*! \name Binary Access */ /*! \{ */ @@ -160,6 +198,13 @@ class OSG_DRAWABLE_DLLMAPPING GeoIntegra static const Char8 *getClassname (void ); /*---------------------------------------------------------------------*/ + /*! \name Fields */ + /*! \{ */ + + SFUInt32 _sfOsgGLId; + + /*! \} */ + /*---------------------------------------------------------------------*/ /*! \name Constructors */ /*! \{ */ @@ -184,6 +229,8 @@ class OSG_DRAWABLE_DLLMAPPING GeoIntegra /*! \name Generic Field Access */ /*! \{ */ + GetFieldHandlePtr getHandleOsgGLId (void) const; + EditFieldHandlePtr editHandleOsgGLId (void); /*! \} */ /*---------------------------------------------------------------------*/ diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefPropertyBase.inl d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefPropertyBase.inl --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefPropertyBase.inl 2017-05-11 11:33:54.390564300 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoIntegralBufferRefPropertyBase.inl 2017-05-11 10:51:06.667413500 +0200 @@ -74,6 +74,31 @@ OSG::UInt16 GeoIntegralBufferRefProperty /*------------------------------ get -----------------------------------*/ +//! Get the value of the GeoIntegralBufferRefProperty::_sfOsgGLId field. + +inline +UInt32 &GeoIntegralBufferRefPropertyBase::editOsgGLId(void) +{ + editSField(OsgGLIdFieldMask); + + return _sfOsgGLId.getValue(); +} + +//! Get the value of the GeoIntegralBufferRefProperty::_sfOsgGLId field. +inline + UInt32 GeoIntegralBufferRefPropertyBase::getOsgGLId(void) const +{ + return _sfOsgGLId.getValue(); +} + +//! Set the value of the GeoIntegralBufferRefProperty::_sfOsgGLId field. +inline +void GeoIntegralBufferRefPropertyBase::setOsgGLId(const UInt32 value) +{ + editSField(OsgGLIdFieldMask); + + _sfOsgGLId.setValue(value); +} #ifdef OSG_MT_CPTR_ASPECT @@ -85,6 +110,9 @@ void GeoIntegralBufferRefPropertyBase::e const UInt32 uiSyncInfo) { Inherited::execSync(pFrom, whichField, oOffsets, syncMode, uiSyncInfo); + + if(FieldBits::NoField != (OsgGLIdFieldMask & whichField)) + _sfOsgGLId.syncWith(pFrom->_sfOsgGLId); } #endif diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.cpp d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.cpp --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.cpp 2017-05-11 11:33:54.407565200 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.cpp 2017-05-11 11:13:03.402493500 +0200 @@ -117,6 +117,29 @@ void GeoVectorBufferRefProperty::dump( SLOG << "Dump GeoVectorBufferRefProperty NI" << std::endl; } +/*------------------------------ tools --------------------------------------*/ + +void GeoVectorBufferRefProperty::validate(DrawEnv *pEnv) +{ + if(this->getOsgGLId() != 0) + { + pEnv->getWindow()->validateGLObject(this->getOsgGLId(), + pEnv ); + } +} + +Int32 GeoVectorBufferRefProperty::getOpenGLId(DrawEnv *pEnv) +{ + if(this->getOsgGLId() != 0) + { + return pEnv->getWindow()->getGLObjectId(this->getOsgGLId()); + } + else + { + return this->getOglGLId(); + } +} + void GeoVectorBufferRefProperty::activate(DrawEnv *pEnv, UInt32 slot) { Window *pWin = pEnv->getWindow(); @@ -128,6 +151,9 @@ void GeoVectorBufferRefProperty::activat osgSinkUnusedWarning(pWin); + validate(pEnv); + GLuint id = this->getOpenGLId(pEnv); + if(hasVBO && isGeneric == true) { OSGGETGLFUNCBYID_GL3_ES( glVertexAttribPointer, @@ -135,15 +161,14 @@ void GeoVectorBufferRefProperty::activat _funcVertexAttribPointerARB, pWin); - if(getGLId() != 0 && getUseVBO()) // Do we have a VBO? + if((getOsgGLId() != 0 || getOglGLId() != 0) && getUseVBO()) // Do we have a VBO? { OSGGETGLFUNCBYID_GL3_ES( glBindBuffer, osgGlBindBuffer, _funcBindBuffer, pWin); - osgGlBindBuffer(GL_ARRAY_BUFFER_ARB, - getGLId()); + osgGlBindBuffer(GL_ARRAY_BUFFER_ARB, id); osgGlVertexAttribPointer(slot, getDimension(), @@ -188,12 +213,11 @@ void GeoVectorBufferRefProperty::activat _funcBindBuffer, pWin); - hasVBO &= getUseVBO() && (getGLId() != 0); + hasVBO &= getUseVBO() && (getOsgGLId() != 0 || getOglGLId() != 0); if(hasVBO == true) // Do we have a VBO? { - osgGlBindBuffer(GL_ARRAY_BUFFER_ARB, - getGLId()); + osgGlBindBuffer(GL_ARRAY_BUFFER_ARB, id); } else { @@ -292,10 +316,13 @@ void *GeoVectorBufferRefProperty::mapBuf { void *returnValue = NULL; - if((getUseVBO() == true) && (getGLId() != 0)) + if((getUseVBO() == true) && (getOsgGLId() != 0 || getOglGLId() != 0)) { Window *pWin = pEnv->getWindow(); + validate(pEnv); + GLuint id = this->getOpenGLId(pEnv); + osgSinkUnusedWarning(pWin); OSGGETGLFUNCBYID_GL3_ES( glBindBuffer, @@ -308,8 +335,7 @@ void *GeoVectorBufferRefProperty::mapBuf _funcMapBuffer, pWin); - osgGlBindBuffer(GL_ARRAY_BUFFER_ARB, - getGLId()); + osgGlBindBuffer(GL_ARRAY_BUFFER_ARB, id); returnValue = osgGlMapBuffer(GL_ARRAY_BUFFER_ARB, eAccess); @@ -323,10 +349,13 @@ bool GeoVectorBufferRefProperty::unmapBu { bool returnValue = true; - if((getUseVBO() == true) && (getGLId() != 0)) + if((getUseVBO() == true) && (getOsgGLId() != 0 || getOglGLId() != 0)) { Window *pWin = pEnv->getWindow(); + validate(pEnv); + GLuint id = this->getOpenGLId(pEnv); + osgSinkUnusedWarning(pWin); OSGGETGLFUNCBYID_GL3_ES( glBindBuffer, @@ -339,8 +368,7 @@ bool GeoVectorBufferRefProperty::unmapBu _funcUnmapBuffer, pWin); - osgGlBindBuffer(GL_ARRAY_BUFFER_ARB, - getGLId()); + osgGlBindBuffer(GL_ARRAY_BUFFER_ARB, id); returnValue = osgGlUnmapBuffer(GL_ARRAY_BUFFER_ARB) != 0; diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.fcd d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.fcd --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.fcd 2017-05-11 11:33:54.407565200 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.fcd 2017-05-11 10:47:12.042993800 +0200 @@ -12,4 +12,20 @@ childFields="both" docGroupBase="GrpDrawablesGeometry" > + + <Field + name="osgGLId" + type="UInt32" + cardinality="single" + visibility="internal" + access="public" + defaultValue="0" + fieldFlags="FClusterLocal" + > + The OpenSG GL object id for this geo property buffer object. If osgGLId is set, the GL object id + is determined by OpenSG. If osgGLId equals 0, the GLId is used directly as the GL object id. + An API getOglGLId()/setOglGLId() is provided to get/set the inherited GLId. This brings the + interface more in line to the TextureObjRefChunk and the ShaderStorageBufferRefObjChunk + classes. + </Field> </FieldContainer> diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.h d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.h --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.h 2017-05-11 11:33:54.408565300 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.h 2017-05-11 10:52:50.478074200 +0200 @@ -78,7 +78,10 @@ class OSG_DRAWABLE_DLLMAPPING GeoVectorB /*! \name State Commands */ /*! \{ */ - void setGLId(UInt32 uiGLId); + void setGLId (UInt32 uiGLId); + + UInt32 getOglGLId (void) const; + void setOglGLId (UInt32 uiGLId); /*! \} */ /*---------------------------------------------------------------------*/ @@ -98,6 +101,14 @@ class OSG_DRAWABLE_DLLMAPPING GeoVectorB /*! \} */ /*---------------------------------------------------------------------*/ + /*! \name OpenGL handling */ + /*! \{ */ + + virtual void validate (DrawEnv *pEnv); + virtual Int32 getOpenGLId (DrawEnv *pEnv); + + /*! \} */ + /*---------------------------------------------------------------------*/ /*! \name Output */ /*! \{ */ diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.inl d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.inl --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.inl 2017-05-11 11:33:54.408565300 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefProperty.inl 2017-05-11 11:00:17.894741000 +0200 @@ -46,4 +46,16 @@ void GeoVectorBufferRefProperty::setGLId Inherited::setGLId(uiGLId); } +inline +UInt32 GeoVectorBufferRefProperty::getOglGLId(void) const +{ + return Inherited::getGLId(); +} + +inline +void GeoVectorBufferRefProperty::setOglGLId(UInt32 uiGLId) +{ + Inherited::setGLId(uiGLId); +} + OSG_END_NAMESPACE diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefPropertyBase.cpp d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefPropertyBase.cpp --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefPropertyBase.cpp 2017-05-11 11:33:54.409565300 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefPropertyBase.cpp 2017-05-11 10:51:06.763419000 +0200 @@ -82,6 +82,14 @@ OSG_BEGIN_NAMESPACE * Field Documentation * \***************************************************************************/ +/*! \var UInt32 GeoVectorBufferRefPropertyBase::_sfOsgGLId + The OpenSG GL object id for this geo property buffer object. If osgGLId is set, the GL object id + is determined by OpenSG. If osgGLId equals 0, the GLId is used directly as the GL object id. + An API getOglGLId()/setOglGLId() is provided to get/set the inherited GLId. This brings the + interface more in line to the TextureObjRefChunk and the ShaderStorageBufferRefObjChunk + classes. +*/ + /***************************************************************************\ * FieldType/FieldTrait Instantiation * @@ -129,6 +137,24 @@ OSG_EXPORT_PTR_MFIELD(ChildPointerMField void GeoVectorBufferRefPropertyBase::classDescInserter(TypeObject &oType) { + FieldDescriptionBase *pDesc = NULL; + + + pDesc = new SFUInt32::Description( + SFUInt32::getClassType(), + "osgGLId", + "The OpenSG GL object id for this geo property buffer object. If osgGLId is set, the GL object id\n" + "is determined by OpenSG. If osgGLId equals 0, the GLId is used directly as the GL object id.\n" + "An API getOglGLId()/setOglGLId() is provided to get/set the inherited GLId. This brings the\n" + "interface more in line to the TextureObjRefChunk and the ShaderStorageBufferRefObjChunk\n" + "classes.\n", + OsgGLIdFieldId, OsgGLIdFieldMask, + true, + (Field::FClusterLocal), + static_cast<FieldEditMethodSig>(&GeoVectorBufferRefProperty::editHandleOsgGLId), + static_cast<FieldGetMethodSig >(&GeoVectorBufferRefProperty::getHandleOsgGLId)); + + oType.addInitialDesc(pDesc); } @@ -143,20 +169,36 @@ GeoVectorBufferRefPropertyBase::TypeObje reinterpret_cast<InitalInsertDescFunc>(&GeoVectorBufferRefProperty::classDescInserter), false, 0, - "<?xml version=\"1.0\"?>\n" - "\n" - "<FieldContainer\n" - " name=\"GeoVectorBufferRefProperty\"\n" - " parent=\"GeoVectorBufferProperty\"\n" - " library=\"Drawable\"\n" - " pointerfieldtypes=\"both\"\n" - " structure=\"concrete\"\n" - " systemcomponent=\"true\"\n" - " parentsystemcomponent=\"true\"\n" - " decoratable=\"false\"\n" - " childFields=\"both\"\n" - " docGroupBase=\"GrpDrawablesGeometry\"\n" - " >\n" + "<?xml version=\"1.0\"?>\n" + "\n" + "<FieldContainer\n" + " name=\"GeoVectorBufferRefProperty\"\n" + " parent=\"GeoVectorBufferProperty\"\n" + " library=\"Drawable\"\n" + " pointerfieldtypes=\"both\"\n" + " structure=\"concrete\"\n" + " systemcomponent=\"true\"\n" + " parentsystemcomponent=\"true\"\n" + " decoratable=\"false\"\n" + " childFields=\"both\"\n" + " docGroupBase=\"GrpDrawablesGeometry\"\n" + " >\n" + "\n" + " <Field\n" + " name=\"osgGLId\"\n" + " type=\"UInt32\"\n" + " cardinality=\"single\"\n" + " visibility=\"internal\"\n" + " access=\"public\"\n" + " defaultValue=\"0\"\n" + " fieldFlags=\"FClusterLocal\"\n" + "\t>\n" + " The OpenSG GL object id for this geo property buffer object. If osgGLId is set, the GL object id\n" + " is determined by OpenSG. If osgGLId equals 0, the GLId is used directly as the GL object id.\n" + " An API getOglGLId()/setOglGLId() is provided to get/set the inherited GLId. This brings the\n" + " interface more in line to the TextureObjRefChunk and the ShaderStorageBufferRefObjChunk\n" + " classes.\n" + " </Field>\n" "</FieldContainer>\n", "" ); @@ -181,6 +223,19 @@ UInt32 GeoVectorBufferRefPropertyBase::g /*------------------------- decorator get ------------------------------*/ +SFUInt32 *GeoVectorBufferRefPropertyBase::editSFOsgGLId(void) +{ + editSField(OsgGLIdFieldMask); + + return &_sfOsgGLId; +} + +const SFUInt32 *GeoVectorBufferRefPropertyBase::getSFOsgGLId(void) const +{ + return &_sfOsgGLId; +} + + @@ -191,6 +246,10 @@ SizeT GeoVectorBufferRefPropertyBase::ge { SizeT returnValue = Inherited::getBinSize(whichField); + if(FieldBits::NoField != (OsgGLIdFieldMask & whichField)) + { + returnValue += _sfOsgGLId.getBinSize(); + } return returnValue; } @@ -200,6 +259,10 @@ void GeoVectorBufferRefPropertyBase::cop { Inherited::copyToBin(pMem, whichField); + if(FieldBits::NoField != (OsgGLIdFieldMask & whichField)) + { + _sfOsgGLId.copyToBin(pMem); + } } void GeoVectorBufferRefPropertyBase::copyFromBin(BinaryDataHandler &pMem, @@ -207,6 +270,11 @@ void GeoVectorBufferRefPropertyBase::cop { Inherited::copyFromBin(pMem, whichField); + if(FieldBits::NoField != (OsgGLIdFieldMask & whichField)) + { + editSField(OsgGLIdFieldMask); + _sfOsgGLId.copyFromBin(pMem); + } } //! create a new instance of the class @@ -331,12 +399,14 @@ FieldContainerTransitPtr GeoVectorBuffer /*------------------------- constructors ----------------------------------*/ GeoVectorBufferRefPropertyBase::GeoVectorBufferRefPropertyBase(void) : - Inherited() + Inherited(), + _sfOsgGLId (UInt32(0)) { } GeoVectorBufferRefPropertyBase::GeoVectorBufferRefPropertyBase(const GeoVectorBufferRefPropertyBase &source) : - Inherited(source) + Inherited(source), + _sfOsgGLId (source._sfOsgGLId ) { } @@ -348,6 +418,31 @@ GeoVectorBufferRefPropertyBase::~GeoVect } +GetFieldHandlePtr GeoVectorBufferRefPropertyBase::getHandleOsgGLId (void) const +{ + SFUInt32::GetHandlePtr returnValue( + new SFUInt32::GetHandle( + &_sfOsgGLId, + this->getType().getFieldDesc(OsgGLIdFieldId), + const_cast<GeoVectorBufferRefPropertyBase *>(this))); + + return returnValue; +} + +EditFieldHandlePtr GeoVectorBufferRefPropertyBase::editHandleOsgGLId (void) +{ + SFUInt32::EditHandlePtr returnValue( + new SFUInt32::EditHandle( + &_sfOsgGLId, + this->getType().getFieldDesc(OsgGLIdFieldId), + this)); + + + editSField(OsgGLIdFieldMask); + + return returnValue; +} + #ifdef OSG_MT_CPTR_ASPECT void GeoVectorBufferRefPropertyBase::execSyncV( FieldContainer &oFrom, diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefPropertyBase.h d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefPropertyBase.h --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefPropertyBase.h 2017-05-11 11:33:54.409565300 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefPropertyBase.h 2017-05-11 10:51:06.771419500 +0200 @@ -65,6 +65,7 @@ #include "OSGGeoVectorBufferProperty.h" // Parent +#include "OSGSysFields.h" // OsgGLId type #include "OSGGeoVectorBufferRefPropertyFields.h" @@ -91,6 +92,18 @@ class OSG_DRAWABLE_DLLMAPPING GeoVectorB public: + enum + { + OsgGLIdFieldId = Inherited::NextFieldId, + NextFieldId = OsgGLIdFieldId + 1 + }; + + static const OSG::BitVector OsgGLIdFieldMask = + (TypeTraits<BitVector>::One << OsgGLIdFieldId); + static const OSG::BitVector NextFieldMask = + (TypeTraits<BitVector>::One << NextFieldId); + + typedef SFUInt32 SFOsgGLIdType; /*---------------------------------------------------------------------*/ /*! \name Class Get */ @@ -112,6 +125,31 @@ class OSG_DRAWABLE_DLLMAPPING GeoVectorB /*! \} */ /*---------------------------------------------------------------------*/ + /*! \name Field Get */ + /*! \{ */ + + + SFUInt32 *editSFOsgGLId (void); + const SFUInt32 *getSFOsgGLId (void) const; + + + UInt32 &editOsgGLId (void); + UInt32 getOsgGLId (void) const; + + /*! \} */ + /*---------------------------------------------------------------------*/ + /*! \name Field Set */ + /*! \{ */ + + void setOsgGLId (const UInt32 value); + + /*! \} */ + /*---------------------------------------------------------------------*/ + /*! \name Ptr MField Set */ + /*! \{ */ + + /*! \} */ + /*---------------------------------------------------------------------*/ /*! \name Binary Access */ /*! \{ */ @@ -160,6 +198,13 @@ class OSG_DRAWABLE_DLLMAPPING GeoVectorB static const Char8 *getClassname (void ); /*---------------------------------------------------------------------*/ + /*! \name Fields */ + /*! \{ */ + + SFUInt32 _sfOsgGLId; + + /*! \} */ + /*---------------------------------------------------------------------*/ /*! \name Constructors */ /*! \{ */ @@ -184,6 +229,8 @@ class OSG_DRAWABLE_DLLMAPPING GeoVectorB /*! \name Generic Field Access */ /*! \{ */ + GetFieldHandlePtr getHandleOsgGLId (void) const; + EditFieldHandlePtr editHandleOsgGLId (void); /*! \} */ /*---------------------------------------------------------------------*/ diff -rupN d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefPropertyBase.inl d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefPropertyBase.inl --- d:/_opensg_clone/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefPropertyBase.inl 2017-05-11 11:33:54.410565400 +0200 +++ d:/_opensg_merge/Comp/builder/support/opensg/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoVectorBufferRefPropertyBase.inl 2017-05-11 10:51:06.764419100 +0200 @@ -74,6 +74,31 @@ OSG::UInt16 GeoVectorBufferRefPropertyBa /*------------------------------ get -----------------------------------*/ +//! Get the value of the GeoVectorBufferRefProperty::_sfOsgGLId field. + +inline +UInt32 &GeoVectorBufferRefPropertyBase::editOsgGLId(void) +{ + editSField(OsgGLIdFieldMask); + + return _sfOsgGLId.getValue(); +} + +//! Get the value of the GeoVectorBufferRefProperty::_sfOsgGLId field. +inline + UInt32 GeoVectorBufferRefPropertyBase::getOsgGLId(void) const +{ + return _sfOsgGLId.getValue(); +} + +//! Set the value of the GeoVectorBufferRefProperty::_sfOsgGLId field. +inline +void GeoVectorBufferRefPropertyBase::setOsgGLId(const UInt32 value) +{ + editSField(OsgGLIdFieldMask); + + _sfOsgGLId.setValue(value); +} #ifdef OSG_MT_CPTR_ASPECT @@ -85,6 +110,9 @@ void GeoVectorBufferRefPropertyBase::exe const UInt32 uiSyncInfo) { Inherited::execSync(pFrom, whichField, oOffsets, syncMode, uiSyncInfo); + + if(FieldBits::NoField != (OsgGLIdFieldMask & whichField)) + _sfOsgGLId.syncWith(pFrom->_sfOsgGLId); } #endif
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Opensg-users mailing list Opensg-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensg-users