Added releaseGLObjects/resizeGLObjectBuffers support
This commit is contained in:
parent
966981f100
commit
0f14f53698
@ -52,7 +52,15 @@ class OSGSHADOW_EXPORT ShadowedScene : public osg::Group
|
||||
/** Dirty any cache data structures held in the attached ShadowTechnqiue.*/
|
||||
void dirty();
|
||||
|
||||
protected:
|
||||
/** Resize any per context GLObject buffers to specified size. */
|
||||
virtual void resizeGLObjectBuffers(unsigned int maxSize);
|
||||
|
||||
/** If State is non-zero, this function releases any associated OpenGL objects for
|
||||
* the specified graphics context. Otherwise, releases OpenGL objects
|
||||
* for all graphics contexts. */
|
||||
virtual void releaseGLObjects(osg::State* = 0) const;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~ShadowedScene();
|
||||
|
||||
|
@ -43,6 +43,14 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
|
||||
/** run the cull traversal of the ShadowedScene and set up the rendering for this ShadowTechnique.*/
|
||||
virtual void cull(osgUtil::CullVisitor& cv);
|
||||
|
||||
/** Resize any per context GLObject buffers to specified size. */
|
||||
virtual void resizeGLObjectBuffers(unsigned int maxSize);
|
||||
|
||||
/** If State is non-zero, this function releases any associated OpenGL objects for
|
||||
* the specified graphics context. Otherwise, releases OpenGL objects
|
||||
* for all graphics contexts. */
|
||||
virtual void releaseGLObjects(osg::State* = 0) const;
|
||||
|
||||
/** Clean scene graph from any shadow technique specific nodes, state and drawables.*/
|
||||
virtual void cleanSceneGraph();
|
||||
|
||||
@ -100,6 +108,8 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
|
||||
{
|
||||
ShadowData(ViewDependentData* vdd);
|
||||
|
||||
virtual void releaseGLObjects(osg::State* = 0) const;
|
||||
|
||||
ViewDependentData* _viewDependentData;
|
||||
|
||||
unsigned int _textureUnit;
|
||||
@ -124,6 +134,8 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
|
||||
|
||||
osg::StateSet* getStateSet() { return _stateset.get(); }
|
||||
|
||||
virtual void releaseGLObjects(osg::State* = 0) const;
|
||||
|
||||
protected:
|
||||
virtual ~ViewDependentData() {}
|
||||
|
||||
@ -156,8 +168,7 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
|
||||
void setShadowMapProjectionHint(ShadowMapProjectionHint hint) { _shadowMapProjectionHint = hint; }
|
||||
ShadowMapProjectionHint getShadowMapProjectionHint() const { return _shadowMapProjectionHint; }
|
||||
|
||||
|
||||
virtual void createShaders();
|
||||
virtual void createShaders();
|
||||
|
||||
virtual bool selectActiveLights(osgUtil::CullVisitor* cv, ViewDependentData* vdd) const;
|
||||
|
||||
@ -184,8 +195,8 @@ protected:
|
||||
virtual ~ViewDependentShadowMap();
|
||||
|
||||
typedef std::map< osgUtil::CullVisitor*, osg::ref_ptr<ViewDependentData> > ViewDependentDataMap;
|
||||
OpenThreads::Mutex _viewDependentDataMapMutex;
|
||||
ViewDependentDataMap _viewDependentDataMap;
|
||||
mutable OpenThreads::Mutex _viewDependentDataMapMutex;
|
||||
ViewDependentDataMap _viewDependentDataMap;
|
||||
|
||||
unsigned int _baseShadowTextureUnit;
|
||||
|
||||
|
@ -96,3 +96,15 @@ void ShadowedScene::dirty()
|
||||
_shadowTechnique->dirty();
|
||||
}
|
||||
}
|
||||
|
||||
void ShadowedScene::resizeGLObjectBuffers(unsigned int maxSize)
|
||||
{
|
||||
if (_shadowTechnique.valid()) _shadowTechnique->resizeGLObjectBuffers(maxSize);
|
||||
Group::resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
|
||||
void ShadowedScene::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
if (_shadowTechnique.valid()) _shadowTechnique->releaseGLObjects(state);
|
||||
Group::releaseGLObjects(state);
|
||||
}
|
||||
|
@ -355,6 +355,13 @@ ViewDependentShadowMap::ShadowData::ShadowData(ViewDependentShadowMap::ViewDepen
|
||||
}
|
||||
}
|
||||
|
||||
void ViewDependentShadowMap::ShadowData::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
OSG_INFO<<"ViewDependentShadowMap::ShadowData::releaseGLObjects"<<std::endl;
|
||||
_texture->releaseGLObjects(state);
|
||||
_camera->releaseGLObjects(state);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Frustum
|
||||
@ -495,6 +502,15 @@ ViewDependentShadowMap::ViewDependentData::ViewDependentData(ViewDependentShadow
|
||||
_stateset = new osg::StateSet;
|
||||
}
|
||||
|
||||
void ViewDependentShadowMap::ViewDependentData::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
for(ShadowDataList::const_iterator itr = _shadowDataList.begin();
|
||||
itr != _shadowDataList.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->releaseGLObjects(state);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -1769,3 +1785,23 @@ osg::StateSet* ViewDependentShadowMap::selectStateSetForRenderingShadow(ViewDepe
|
||||
|
||||
return vdd.getStateSet();
|
||||
}
|
||||
|
||||
void ViewDependentShadowMap::resizeGLObjectBuffers(unsigned int maxSize)
|
||||
{
|
||||
// the way that ViewDependentData is mapped shouldn't
|
||||
}
|
||||
|
||||
void ViewDependentShadowMap::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_viewDependentDataMapMutex);
|
||||
for(ViewDependentDataMap::const_iterator itr = _viewDependentDataMap.begin();
|
||||
itr != _viewDependentDataMap.end();
|
||||
++itr)
|
||||
{
|
||||
ViewDependentData* vdd = itr->second.get();
|
||||
if (vdd)
|
||||
{
|
||||
vdd->releaseGLObjects(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user