Added support for releasing GLObjects, and renamed DisplayListVisitor the
GLObjectVisitor to better fit its function, and added support for releasing objects as well as compiling them.
This commit is contained in:
@@ -254,8 +254,11 @@ class SG_EXPORT Drawable : public Object
|
||||
/** Immediately compile this drawable into an OpenGL Display List.
|
||||
Note I, operation is ignored if _useDisplayList to false.
|
||||
Note II, compile is not intended to be overridden in subclasses.*/
|
||||
virtual void compile(State& state) const;
|
||||
virtual void compileGLObjects(State& state) const;
|
||||
|
||||
/** release any OpenGL display lists associated with graphics context specified
|
||||
in osg::State object is supplied, or release all display lists for all graphics contexts if state pointer is NULL*/
|
||||
virtual void releaseGLObjects(State* state=0) const;
|
||||
|
||||
struct UpdateCallback : public virtual osg::Object
|
||||
{
|
||||
|
||||
@@ -201,7 +201,12 @@ class SG_EXPORT FragmentProgram : public StateAttribute
|
||||
|
||||
virtual void apply(State& state) const;
|
||||
|
||||
virtual void compile(State& state) const { apply(state); }
|
||||
virtual void compileGLObjects(State& state) const { apply(state); }
|
||||
|
||||
/** release an OpenGL objects in specified graphics context if State
|
||||
object is passed, otherwise release OpenGL objexts for all graphics context if
|
||||
State object pointer NULL.*/
|
||||
virtual void releaseGLObjects(State* state=0) const;
|
||||
|
||||
/** Extensions class which encapsulates the querring of extensions and
|
||||
* associated function pointers, and provide convinience wrappers to
|
||||
|
||||
@@ -229,7 +229,13 @@ class SG_EXPORT StateAttribute : public Object
|
||||
virtual void apply(State&) const = 0;
|
||||
|
||||
/** default to nothing to compile - all state is applied immediately. */
|
||||
virtual void compile(State&) const {}
|
||||
virtual void compileGLObjects(State&) const {}
|
||||
|
||||
/** release an OpenGL objects in specified graphics context if State
|
||||
object is passed, otherwise release OpenGL objexts for all graphics context if
|
||||
State object pointer NULL.*/
|
||||
virtual void releaseGLObjects(State* =0) const {}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -221,7 +221,10 @@ class SG_EXPORT StateSet : public Object
|
||||
|
||||
|
||||
/** call compile on all StateAttributes contained within this StateSet.*/
|
||||
void compile(State& state) const;
|
||||
void compileGLObjects(State& state) const;
|
||||
|
||||
/** call release on all StateAttributes contained within this StateSet.*/
|
||||
virtual void releaseGLObjects(State* state=0) const;
|
||||
|
||||
protected :
|
||||
|
||||
|
||||
@@ -319,7 +319,12 @@ class SG_EXPORT Texture : public osg::StateAttribute
|
||||
virtual void apply(State& state) const = 0;
|
||||
|
||||
/** Calls apply(state) to compile the texture. */
|
||||
virtual void compile(State& state) const;
|
||||
virtual void compileGLObjects(State& state) const;
|
||||
|
||||
/** release an OpenGL objects in specified graphics context if State
|
||||
object is passed, otherwise release OpenGL objexts for all graphics context if
|
||||
State object pointer NULL.*/
|
||||
virtual void releaseGLObjects(State* state=0) const;
|
||||
|
||||
/** Extensions class which encapsulates the querring of extensions and
|
||||
* associated function pointers, and provide convinience wrappers to
|
||||
|
||||
@@ -193,7 +193,12 @@ class SG_EXPORT VertexProgram : public StateAttribute
|
||||
|
||||
virtual void apply(State& state) const;
|
||||
|
||||
virtual void compile(State& state) const { apply(state); }
|
||||
virtual void compileGLObjects(State& state) const { apply(state); }
|
||||
|
||||
/** release an OpenGL objects in specified graphics context if State
|
||||
object is passed, otherwise release OpenGL objexts for all graphics context if
|
||||
State object pointer NULL.*/
|
||||
virtual void releaseGLObjects(State* state=0) const;
|
||||
|
||||
/** Extensions class which encapsulates the querring of extensions and
|
||||
* associated function pointers, and provide convinience wrappers to
|
||||
|
||||
@@ -140,6 +140,21 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
/** get whether the removed subgraphs should be deleted in the database thread or not.*/
|
||||
bool getDeleteRemovedSubgraphsInDatabaseThread() const { return _deleteRemovedSubgraphsInDatabaseThread; }
|
||||
|
||||
|
||||
/** set whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.*/
|
||||
void setUnrefImageDataAfterApplyPolicy(bool changeAutoUnRef, bool valueAutoUnRef) { _changeAutoUnRef = changeAutoUnRef; _valueAutoUnRef = valueAutoUnRef; }
|
||||
|
||||
/** get whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.*/
|
||||
void getUnrefImageDataAfterApplyPolicy(bool& changeAutoUnRef, bool& valueAutoUnRef) const { changeAutoUnRef = _changeAutoUnRef; valueAutoUnRef = _valueAutoUnRef; }
|
||||
|
||||
|
||||
/** set whether newly loaded textures should have their MaxAnisotopy set to a specified value.*/
|
||||
void setMaxAnisotropyPolicy(bool changeAnisotropy, float valueAnisotropy) { _changeAnisotropy = changeAnisotropy; _valueAnisotropy = valueAnisotropy; }
|
||||
|
||||
/** set whether newly loaded textures should have their MaxAnisotopy set to a specified value.*/
|
||||
void getMaxAnisotropyPolicy(bool& changeAnisotropy, float& valueAnisotropy) const { changeAnisotropy = _changeAnisotropy; valueAnisotropy = _valueAnisotropy; }
|
||||
|
||||
|
||||
/** Iterate through the active PagedLOD nodes children removing
|
||||
* children which havn't been visited since specified expiryTime.
|
||||
* note, should be only be called from the update thread. */
|
||||
@@ -220,7 +235,11 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
|
||||
DatabaseRequestList _dataToCompileList;
|
||||
OpenThreads::Mutex _dataToCompileListMutex;
|
||||
|
||||
|
||||
bool _changeAutoUnRef;
|
||||
bool _valueAutoUnRef;
|
||||
bool _changeAnisotropy;
|
||||
float _valueAnisotropy;
|
||||
|
||||
bool _deleteRemovedSubgraphsInDatabaseThread;
|
||||
ObjectList _childrenToDeleteList;
|
||||
|
||||
@@ -86,7 +86,12 @@ class OSGGL2_EXPORT ProgramObject : public osg::StateAttribute
|
||||
* be pending. */
|
||||
virtual void apply(osg::State& state) const;
|
||||
|
||||
virtual void compile(osg::State& state) const { apply(state); }
|
||||
virtual void compileGLObjects(osg::State& state) const { apply(state); }
|
||||
|
||||
/** release an OpenGL objects in specified graphics context if State
|
||||
object is passed, otherwise release OpenGL objexts for all graphics context if
|
||||
State object pointer NULL.*/
|
||||
virtual void releaseGLObjects(osg::State* state=0) const;
|
||||
|
||||
// data access methods.
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
//#define OSG_FONT_USE_LUMINANCE_ALPHA
|
||||
|
||||
namespace osgText {
|
||||
|
||||
class Font;
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGUTIL_DISPLAYLISTVISITOR
|
||||
#define OSGUTIL_DISPLAYLISTVISITOR 1
|
||||
#ifndef OSGUTIL_GLOBJECTSVISITOR
|
||||
#define OSGUTIL_GLOBJECTSVISITOR 1
|
||||
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/Geode>
|
||||
@@ -26,7 +26,7 @@ namespace osgUtil {
|
||||
* with option to immediately compile osg::Drawable OpenGL Display lists and
|
||||
* osg::StateAttribute's.
|
||||
*/
|
||||
class OSGUTIL_EXPORT DisplayListVisitor : public osg::NodeVisitor
|
||||
class OSGUTIL_EXPORT GLObjectsVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -36,7 +36,9 @@ class OSGUTIL_EXPORT DisplayListVisitor : public osg::NodeVisitor
|
||||
SWITCH_ON_DISPLAY_LISTS = 0x1,
|
||||
SWITCH_OFF_DISPLAY_LISTS = 0x2,
|
||||
COMPILE_DISPLAY_LISTS = 0x4,
|
||||
COMPILE_STATE_ATTRIBUTES = 0x8
|
||||
COMPILE_STATE_ATTRIBUTES = 0x8,
|
||||
RELEASE_DISPLAY_LISTS = 0x10,
|
||||
RELEASE_STATE_ATTRIBUTES = 0x20
|
||||
};
|
||||
|
||||
typedef unsigned int Mode;
|
||||
@@ -45,7 +47,7 @@ class OSGUTIL_EXPORT DisplayListVisitor : public osg::NodeVisitor
|
||||
* with set specified display list mode. Default mode is to
|
||||
* gset->setUseDisplayList(true).
|
||||
*/
|
||||
DisplayListVisitor(Mode mode=COMPILE_DISPLAY_LISTS|COMPILE_STATE_ATTRIBUTES);
|
||||
GLObjectsVisitor(Mode mode=COMPILE_DISPLAY_LISTS|COMPILE_STATE_ATTRIBUTES);
|
||||
|
||||
/** Set the operational mode of how the visitor should set up osg::Drawable's.*/
|
||||
void setMode(Mode mode) { _mode = mode; }
|
||||
@@ -74,6 +76,9 @@ class OSGUTIL_EXPORT DisplayListVisitor : public osg::NodeVisitor
|
||||
*/
|
||||
virtual void apply(osg::Geode& node);
|
||||
|
||||
void apply(osg::Drawable& drawable);
|
||||
void apply(osg::StateSet& stateset);
|
||||
|
||||
protected:
|
||||
|
||||
Mode _mode;
|
||||
Reference in New Issue
Block a user