Fixed crash on exit issues with osgFX, osgParticle, osgSim and the osgforest example
This commit is contained in:
@@ -385,6 +385,8 @@ QueryGeometry::getNumPixels( const osg::Camera* cam )
|
||||
void
|
||||
QueryGeometry::releaseGLObjects( osg::State* state ) const
|
||||
{
|
||||
Geometry::releaseGLObjects(state);
|
||||
|
||||
if (!state)
|
||||
{
|
||||
// delete all query IDs for all contexts.
|
||||
|
||||
@@ -135,6 +135,20 @@ void Effect::traverse(osg::NodeVisitor& nv)
|
||||
// wow, we're finished! :)
|
||||
}
|
||||
|
||||
void Effect::resizeGLObjectBuffers(unsigned int maxSize)
|
||||
{
|
||||
Group::resizeGLObjectBuffers(maxSize);
|
||||
if (_dummy_for_validation) _dummy_for_validation->resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
|
||||
void Effect::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
Group::releaseGLObjects(state);
|
||||
if (_dummy_for_validation) _dummy_for_validation->releaseGLObjects(state);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Effect::build_dummy_node()
|
||||
{
|
||||
_dummy_for_validation = new osg::Geode;
|
||||
|
||||
@@ -659,6 +659,8 @@ osg::BoundingBox osgParticle::ParticleSystem::computeBoundingBox() const
|
||||
|
||||
void osgParticle::ParticleSystem::resizeGLObjectBuffers(unsigned int maxSize)
|
||||
{
|
||||
Drawable::resizeGLObjectBuffers(maxSize);
|
||||
|
||||
_bufferedArrayData.resize(maxSize);
|
||||
for(unsigned int i=0; i<_bufferedArrayData.size(); ++i)
|
||||
{
|
||||
@@ -668,6 +670,8 @@ void osgParticle::ParticleSystem::resizeGLObjectBuffers(unsigned int maxSize)
|
||||
|
||||
void osgParticle::ParticleSystem::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
Drawable::releaseGLObjects(state);
|
||||
|
||||
if (state)
|
||||
{
|
||||
_bufferedArrayData[state->getContextID()].releaseGLObjects(state);
|
||||
|
||||
@@ -121,22 +121,64 @@ void PrecipitationEffect::snow(float intensity)
|
||||
|
||||
void PrecipitationEffect::compileGLObjects(osg::RenderInfo& renderInfo) const
|
||||
{
|
||||
if (_quadGeometry.valid())
|
||||
{
|
||||
_quadGeometry->compileGLObjects(renderInfo);
|
||||
if (_quadGeometry->getStateSet()) _quadGeometry->getStateSet()->compileGLObjects(*renderInfo.getState());
|
||||
}
|
||||
if (_quadGeometry.valid()) _quadGeometry->compileGLObjects(renderInfo);
|
||||
if (_lineGeometry.valid()) _lineGeometry->compileGLObjects(renderInfo);
|
||||
if (_pointGeometry.valid()) _pointGeometry->compileGLObjects(renderInfo);
|
||||
|
||||
if (_lineGeometry.valid())
|
||||
{
|
||||
_lineGeometry->compileGLObjects(renderInfo);
|
||||
if (_lineGeometry->getStateSet()) _lineGeometry->getStateSet()->compileGLObjects(*renderInfo.getState());
|
||||
}
|
||||
if (_quadStateSet.valid()) _quadStateSet->compileGLObjects(*renderInfo.getState());
|
||||
if (_lineStateSet.valid()) _lineStateSet->compileGLObjects(*renderInfo.getState());
|
||||
if (_pointStateSet.valid()) _pointStateSet->compileGLObjects(*renderInfo.getState());
|
||||
|
||||
if (_pointGeometry.valid())
|
||||
for(ViewDrawableMap::const_iterator itr = _viewDrawableMap.begin();
|
||||
itr != _viewDrawableMap.end();
|
||||
++itr)
|
||||
{
|
||||
_pointGeometry->compileGLObjects(renderInfo);
|
||||
if (_pointGeometry->getStateSet()) _pointGeometry->getStateSet()->compileGLObjects(*renderInfo.getState());
|
||||
const PrecipitationDrawableSet& pds = itr->second;
|
||||
if (pds._quadPrecipitationDrawable.valid()) pds._quadPrecipitationDrawable->compileGLObjects(renderInfo);
|
||||
if (pds._linePrecipitationDrawable.valid()) pds._linePrecipitationDrawable->compileGLObjects(renderInfo);
|
||||
if (pds._pointPrecipitationDrawable.valid()) pds._pointPrecipitationDrawable->compileGLObjects(renderInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void PrecipitationEffect::resizeGLObjectBuffers(unsigned int maxSize)
|
||||
{
|
||||
if (_quadGeometry.valid()) _quadGeometry->resizeGLObjectBuffers(maxSize);
|
||||
if (_lineGeometry.valid()) _lineGeometry->resizeGLObjectBuffers(maxSize);
|
||||
if (_pointGeometry.valid()) _pointGeometry->resizeGLObjectBuffers(maxSize);
|
||||
|
||||
if (_quadStateSet.valid()) _quadStateSet->resizeGLObjectBuffers(maxSize);
|
||||
if (_lineStateSet.valid()) _lineStateSet->resizeGLObjectBuffers(maxSize);
|
||||
if (_pointStateSet.valid()) _pointStateSet->resizeGLObjectBuffers(maxSize);
|
||||
|
||||
for(ViewDrawableMap::const_iterator itr = _viewDrawableMap.begin();
|
||||
itr != _viewDrawableMap.end();
|
||||
++itr)
|
||||
{
|
||||
const PrecipitationDrawableSet& pds = itr->second;
|
||||
if (pds._quadPrecipitationDrawable.valid()) pds._quadPrecipitationDrawable->resizeGLObjectBuffers(maxSize);
|
||||
if (pds._linePrecipitationDrawable.valid()) pds._linePrecipitationDrawable->resizeGLObjectBuffers(maxSize);
|
||||
if (pds._pointPrecipitationDrawable.valid()) pds._pointPrecipitationDrawable->resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
}
|
||||
|
||||
void PrecipitationEffect::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
if (_quadGeometry.valid()) _quadGeometry->releaseGLObjects(state);
|
||||
if (_lineGeometry.valid()) _lineGeometry->releaseGLObjects(state);
|
||||
if (_pointGeometry.valid()) _pointGeometry->releaseGLObjects(state);
|
||||
|
||||
if (_quadStateSet.valid()) _quadStateSet->releaseGLObjects(state);
|
||||
if (_lineStateSet.valid()) _lineStateSet->releaseGLObjects(state);
|
||||
if (_pointStateSet.valid()) _pointStateSet->releaseGLObjects(state);
|
||||
|
||||
for(ViewDrawableMap::const_iterator itr = _viewDrawableMap.begin();
|
||||
itr != _viewDrawableMap.end();
|
||||
++itr)
|
||||
{
|
||||
const PrecipitationDrawableSet& pds = itr->second;
|
||||
if (pds._quadPrecipitationDrawable.valid()) pds._quadPrecipitationDrawable->releaseGLObjects(state);
|
||||
if (pds._linePrecipitationDrawable.valid()) pds._linePrecipitationDrawable->releaseGLObjects(state);
|
||||
if (pds._pointPrecipitationDrawable.valid()) pds._pointPrecipitationDrawable->releaseGLObjects(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,7 +871,24 @@ PrecipitationEffect::PrecipitationDrawable::PrecipitationDrawable(const Precipit
|
||||
{
|
||||
}
|
||||
|
||||
PrecipitationEffect::PrecipitationDrawable::~PrecipitationDrawable()
|
||||
{
|
||||
OSG_NOTICE<<"PrecipitationEffect::~PrecipitationDrawable() "<<this<<std::endl;
|
||||
}
|
||||
|
||||
void PrecipitationEffect::PrecipitationDrawable::resizeGLObjectBuffers(unsigned int maxSize)
|
||||
{
|
||||
Drawable::resizeGLObjectBuffers(maxSize);
|
||||
|
||||
if (_geometry) _geometry->resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
|
||||
void PrecipitationEffect::PrecipitationDrawable::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
Drawable::releaseGLObjects(state);
|
||||
|
||||
if (_geometry) _geometry->releaseGLObjects(state);
|
||||
}
|
||||
|
||||
void PrecipitationEffect::PrecipitationDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
|
||||
{
|
||||
|
||||
@@ -54,6 +54,11 @@ LightPointDrawable::LightPointDrawable(const LightPointDrawable& lpd,const osg::
|
||||
{
|
||||
}
|
||||
|
||||
LightPointDrawable::~LightPointDrawable()
|
||||
{
|
||||
OSG_NOTICE<<"LightPointDrawable::~LightPointDrawable()"<<std::endl;
|
||||
}
|
||||
|
||||
void LightPointDrawable::reset()
|
||||
{
|
||||
SizedLightPointList::iterator itr;
|
||||
|
||||
@@ -102,7 +102,7 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~LightPointDrawable() {}
|
||||
virtual ~LightPointDrawable();
|
||||
|
||||
osg::Endian _endian;
|
||||
|
||||
|
||||
@@ -93,6 +93,32 @@ void SphereSegment::traverse(osg::NodeVisitor& nv)
|
||||
}
|
||||
}
|
||||
|
||||
void SphereSegment::resizeGLObjectBuffers(unsigned int maxSize)
|
||||
{
|
||||
if (_surfaceGeometry.valid()) _surfaceGeometry->resizeGLObjectBuffers(maxSize);
|
||||
if (_spokesGeometry.valid()) _spokesGeometry->resizeGLObjectBuffers(maxSize);
|
||||
if (_edgeLineGeometry.valid()) _edgeLineGeometry->resizeGLObjectBuffers(maxSize);
|
||||
if (_sidesGeometry.valid()) _sidesGeometry->resizeGLObjectBuffers(maxSize);
|
||||
|
||||
if (_litOpaqueState.valid()) _litOpaqueState->resizeGLObjectBuffers(maxSize);
|
||||
if (_unlitOpaqueState.valid()) _unlitOpaqueState->resizeGLObjectBuffers(maxSize);
|
||||
if (_litTransparentState.valid()) _litTransparentState->resizeGLObjectBuffers(maxSize);
|
||||
if (_unlitTransparentState.valid()) _unlitTransparentState->resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
|
||||
void SphereSegment::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
if (_surfaceGeometry.valid()) _surfaceGeometry->releaseGLObjects(state);
|
||||
if (_spokesGeometry.valid()) _spokesGeometry->releaseGLObjects(state);
|
||||
if (_edgeLineGeometry.valid()) _edgeLineGeometry->releaseGLObjects(state);
|
||||
if (_sidesGeometry.valid()) _sidesGeometry->releaseGLObjects(state);
|
||||
|
||||
if (_litOpaqueState.valid()) _litOpaqueState->releaseGLObjects(state);
|
||||
if (_unlitOpaqueState.valid()) _unlitOpaqueState->releaseGLObjects(state);
|
||||
if (_litTransparentState.valid()) _litTransparentState->releaseGLObjects(state);
|
||||
if (_unlitTransparentState.valid()) _unlitTransparentState->releaseGLObjects(state);
|
||||
}
|
||||
|
||||
osg::BoundingSphere SphereSegment::computeBound() const
|
||||
{
|
||||
_bbox.init();
|
||||
|
||||
Reference in New Issue
Block a user