Added releaseGLObjects(..) and resizeGLObjectBuffers(..) to osgShadow::ShadowTechnique's

This commit is contained in:
Robert Osfield
2016-02-04 17:52:44 +00:00
parent f373bcf23d
commit dcadd69c5a
20 changed files with 346 additions and 15 deletions

View File

@@ -77,7 +77,16 @@ class OSGSHADOW_EXPORT DebugShadowMap : public ViewDependentShadowTechnique
/** Set the file name of debuging dump */
void setDebugDump( const std::string & debugDumpFile ) { _debugDump = debugDumpFile; }
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:
/** Classic protected OSG destructor */
virtual ~DebugShadowMap();
@@ -182,6 +191,11 @@ class OSGSHADOW_EXPORT DebugShadowMap : public ViewDependentShadowTechnique
const ConvexPolyhedron * hull );
void dump( const std::string & filename );
virtual void resizeGLObjectBuffers(unsigned int maxSize);
virtual void releaseGLObjects(osg::State* = 0) const;
};
META_ViewDependentShadowTechniqueData( ThisClass, ViewData )

View File

@@ -76,6 +76,9 @@ class OSGSHADOW_EXPORT MinimalDrawBoundsShadowMap
virtual void performBoundAnalysis( const osg::Camera& camera );
ViewData( void ): _boundAnalysisSize( 64, 64 ) {}
virtual void resizeGLObjectBuffers(unsigned int maxSize);
virtual void releaseGLObjects(osg::State* = 0) const;
};
friend struct ViewData;

View File

@@ -134,6 +134,14 @@ class OSGSHADOW_EXPORT ParallelSplitShadowMap : public ShadowTechnique
inline SplitCalcMode getSplitCalculationMode() const { return _SplitCalcMode; }
/** 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 ~ParallelSplitShadowMap() {}
@@ -169,7 +177,11 @@ class OSGSHADOW_EXPORT ParallelSplitShadowMap : public ShadowTechnique
unsigned int _splitID;
unsigned int _resolution;
osg::Uniform* _farDistanceSplit;
osg::ref_ptr<osg::Uniform> _farDistanceSplit;
void resizeGLObjectBuffers(unsigned int maxSize);
void releaseGLObjects(osg::State* = 0) const;
};
typedef std::map<unsigned int,PSSMShadowSplitTexture> PSSMShadowSplitTextureMap;

View File

@@ -83,6 +83,16 @@ class OSGSHADOW_EXPORT ShadowMap : public ShadowTechnique
/** Clean scene graph from any shadow technique specific nodes, state and drawables.*/
virtual void cleanSceneGraph();
/** 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;
// debug methods
osg::ref_ptr<osg::Camera> makeDebugHUD();

View File

@@ -35,7 +35,9 @@ class OSGSHADOW_EXPORT ShadowTechnique : public osg::Object
ShadowTechnique(const ShadowTechnique& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgShadow, ShadowTechnique);
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const ShadowTechnique*>(obj)!=NULL; } \
virtual const char* libraryName() const { return "osgShadow"; }\
virtual const char* className() const { return "ShadowTechnique"; }
ShadowedScene* getShadowedScene() { return _shadowedScene; }
@@ -58,7 +60,15 @@ class OSGSHADOW_EXPORT ShadowTechnique : public osg::Object
/** Dirty so that cached data structures are updated.*/
virtual void dirty() { _dirty = true; }
protected :
/** Resize any per context GLObject buffers to specified size. */
virtual void resizeGLObjectBuffers(unsigned int maxSize) = 0;
/** 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 = 0;
protected :
class OSGSHADOW_EXPORT CameraCullCallback : public osg::NodeCallback
{

View File

@@ -51,6 +51,14 @@ class OSGSHADOW_EXPORT ShadowTexture : public ShadowTechnique
virtual void cleanSceneGraph();
/** 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 ~ShadowTexture() {}

View File

@@ -53,6 +53,14 @@ class OSGSHADOW_EXPORT ShadowVolume : public ShadowTechnique
virtual void cleanSceneGraph();
/** 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 ~ShadowVolume();
@@ -60,7 +68,7 @@ class OSGSHADOW_EXPORT ShadowVolume : public ShadowTechnique
osgShadow::ShadowVolumeGeometry::DrawMode _drawMode;
bool _dynamicShadowVolumes;
osg::ref_ptr<osgShadow::OccluderGeometry> _occluder;
osg::ref_ptr<osgShadow::OccluderGeometry> _occluder;
OpenThreads::Mutex _shadowVolumeMutex;
osg::ref_ptr<osgShadow::ShadowVolumeGeometry> _shadowVolume;

View File

@@ -124,7 +124,16 @@ class OSGSHADOW_EXPORT StandardShadowMap : public DebugShadowMap
void setMainFragmentShader( osg::Shader * shader )
{ _mainFragmentShader = shader; }
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:
/** Classic protected OSG destructor */
virtual ~StandardShadowMap(void);
@@ -188,6 +197,9 @@ class OSGSHADOW_EXPORT StandardShadowMap : public DebugShadowMap
const osg::Vec3 &worldLightDir,
const osg::Vec3 &worldLightUp
= osg::Vec3(0,1,0) );
virtual void resizeGLObjectBuffers(unsigned int maxSize);
virtual void releaseGLObjects(osg::State* = 0) const;
};
friend struct ViewData;

View File

@@ -171,7 +171,6 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
virtual osg::StateSet* selectStateSetForRenderingShadow(ViewDependentData& vdd) const;
protected:
virtual ~ViewDependentShadowMap();

View File

@@ -17,9 +17,10 @@
#ifndef OSGSHADOW_VIEWDEPENDENTSHADOWTECHINIQUE
#define OSGSHADOW_VIEWDEPENDENTSHADOWTECHINIQUE 1
#include <osg/Identifier>
#include <osgShadow/ShadowTechnique>
#include <map>
#include <osgShadow/Export>
#include <map>
namespace osgShadow {
/**
@@ -139,7 +140,16 @@ class OSGSHADOW_EXPORT ViewDependentShadowTechnique
/** Traverse shadow scene graph.*/
virtual void traverse(osg::NodeVisitor& nv);
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:
/** Classic protected OSG destructor */
~ViewDependentShadowTechnique( void );
@@ -196,6 +206,12 @@ class OSGSHADOW_EXPORT ViewDependentShadowTechnique
*/
osg::observer_ptr< ViewDependentShadowTechnique > _st;
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 {}
};
/**
@@ -203,7 +219,7 @@ class OSGSHADOW_EXPORT ViewDependentShadowTechnique
ViewDependentShadowTechnique uses this map to find VieData for each cull vitior
*/
typedef std::map< osg::ref_ptr< osgUtil::CullVisitor >,
typedef std::map< osg::ref_ptr< osg::Identifier >,
osg::ref_ptr< ViewData > > ViewDataMap;
ViewDataMap _viewDataMap;