[osg-users] crash with setTextureAttributeAndModes
Hi, I'm having a crash with setTextureAttributeAndModes I don't know how to fix. To explain the issue. I have a list of data sets which hold a pointer to a osg::Texture3D. The texture mixing is done in a shader and my texture update function containing the following loop is called from an update callback. Since the order of the textures can/must change i loop over the textures and do this Code: osg::StateSet* sliceState = m_sliceNode-getOrCreateStateSet(); for ( size_t i = 0; i datasetList.size(); ++i) { osg::Texture3D* texture3D = datasetList[i] )-getTexture3D(); sliceState-setTextureAttributeAndModes( i, texture3D, osg::StateAttribute::ON ); } This works just find when adding one texture after another. However when the order changes, thus overwriting a different order it crashes. So apparently I'm doing it wrong. Any help would be greatly appreciated. ... Thank you! Cheers, Otto -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=18753#18753 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] crash with setTextureAttributeAndModes
Hi Otto We don't have enough information to solve you problem. Have you try to debug you application ? Have you an available callstack to found where you application crash ? Have you a simple program test which isolate the problem ? but more simply, is your datasetList array store texture pointer in osg::ref_ptr ? Nobody can help you with this too little description. This probably a misusing of osg code more than a bug in OSG. HTH David Callu 2009/10/27 Otto Cologne schur...@gmx.de Hi, I'm having a crash with setTextureAttributeAndModes I don't know how to fix. To explain the issue. I have a list of data sets which hold a pointer to a osg::Texture3D. The texture mixing is done in a shader and my texture update function containing the following loop is called from an update callback. Since the order of the textures can/must change i loop over the textures and do this Code: osg::StateSet* sliceState = m_sliceNode-getOrCreateStateSet(); for ( size_t i = 0; i datasetList.size(); ++i) { osg::Texture3D* texture3D = datasetList[i] )-getTexture3D(); sliceState-setTextureAttributeAndModes( i, texture3D, osg::StateAttribute::ON ); } This works just find when adding one texture after another. However when the order changes, thus overwriting a different order it crashes. So apparently I'm doing it wrong. Any help would be greatly appreciated. ... Thank you! Cheers, Otto -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=18753#18753 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] crash with setTextureAttributeAndModes
Hi Otto, On 27/10/09 10:12 AM, Otto Cologne wrote: I'm having a crash with setTextureAttributeAndModes I don't know how to fix. To explain the issue. I have a list of data sets which hold a pointer to a osg::Texture3D. The texture mixing is done in a shader and my texture update function containing the following loop is called from an update callback. Since the order of the textures can/must change i loop over the textures and do this ... osg::StateSet* sliceState = m_sliceNode-getOrCreateStateSet(); for ( size_t i = 0; i datasetList.size(); ++i) { osg::Texture3D* texture3D = datasetList[i] )-getTexture3D(); sliceState-setTextureAttributeAndModes( i, texture3D, osg::StateAttribute::ON ); } This works just find when adding one texture after another. However when the order changes, thus overwriting a different order it crashes. So apparently I'm doing it wrong. David already hinted at the answer: you need to use ref_ptrTexture3D for your datasetList, not Texture3D*. Or manually do a 'ref' on each object. Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] crash with setTextureAttributeAndModes
Yes you are right :) I was just about to post that i followed that hint and used it. It works now. Thanks. Ulrich Hertlein wrote: Hi Otto, On 27/10/09 10:12 AM, Otto Cologne wrote: I'm having a crash with setTextureAttributeAndModes I don't know how to fix. To explain the issue. I have a list of data sets which hold a pointer to a osg::Texture3D. The texture mixing is done in a shader and my texture update function containing the following loop is called from an update callback. Since the order of the textures can/must change i loop over the textures and do this ... osg::StateSet* sliceState = m_sliceNode-getOrCreateStateSet(); for ( size_t i = 0; i datasetList.size(); ++i) { osg::Texture3D* texture3D = datasetList[i] )-getTexture3D(); sliceState-setTextureAttributeAndModes( i, texture3D, osg::StateAttribute::ON ); } This works just find when adding one texture after another. However when the order changes, thus overwriting a different order it crashes. So apparently I'm doing it wrong. David already hinted at the answer: you need to use ref_ptrTexture3D for your datasetList, not Texture3D*. Or manually do a 'ref' on each object. Cheers, /ulrich ___ osg-users mailing list http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Post generated by Mail2Forum -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=18770#18770 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org