diff --git a/Make/makedefs.freebsd b/Make/makedefs.freebsd index 7b3a58473..70bbdbf91 100644 --- a/Make/makedefs.freebsd +++ b/Make/makedefs.freebsd @@ -11,7 +11,7 @@ YFLAGS = -d LCINCS += -I/usr/local/include -I/usr/X11R6/include LC++INCS += ${LCINCS} CFLAGS = -O2 -W -Wall $(LCINCS) -#CFLAGS = -O2 -DOSG_USE_MEMORY_TRACKING -W -Wall $(LCINCS) +#CFLAGS = -O2 -DOSG_USE_MEMORY_MANAGER -W -Wall $(LCINCS) C++FLAGS = ${CFLAGS} CPPFLAGS = ${CFLAGS} diff --git a/Make/makedefs.irix.std b/Make/makedefs.irix.std index 49c4a6319..c35bcc929 100644 --- a/Make/makedefs.irix.std +++ b/Make/makedefs.irix.std @@ -9,7 +9,7 @@ DEPFILES = $(OBJS:.o=.d) C++ = CC YFLAGS = -d CFLAGS = -O2 -n32 -LANG:std -OPT:Olimit=0 -DEBUG:woff=1682 -DEBUG:woff=3303 -#CFLAGS = -g -DOSG_USE_MEMORY_TRACKING -n32 -LANG:std -OPT:Olimit=0 -DEBUG:woff=1682 -DEBUG:woff=3303 +#CFLAGS = -g -DOSG_USE_MEMORY_MANAGER -n32 -LANG:std -OPT:Olimit=0 -DEBUG:woff=1682 -DEBUG:woff=3303 C++FLAGS = ${CFLAGS} CPPFLAGS = ${CFLAGS} diff --git a/Make/makedefs.irix.std.64 b/Make/makedefs.irix.std.64 index 9fd091756..a15d24101 100644 --- a/Make/makedefs.irix.std.64 +++ b/Make/makedefs.irix.std.64 @@ -9,7 +9,7 @@ DEPFILES = $(OBJS:.o=.d) C++ = CC YFLAGS = -d CFLAGS = -O2 -64 -LANG:std -OPT:Olimit=0 -DEBUG:woff=1682 -DEBUG:woff=3303 -#CFLAGS = -g -DOSG_USE_MEMORY_TRACKING -64 -LANG:std -OPT:Olimit=0 -DEBUG:woff=1682 -DEBUG:woff=3303 +#CFLAGS = -g -DOSG_USE_MEMORY_MANAGER -64 -LANG:std -OPT:Olimit=0 -DEBUG:woff=1682 -DEBUG:woff=3303 C++FLAGS = ${CFLAGS} CPPFLAGS = ${CFLAGS} diff --git a/Make/makedefs.linux b/Make/makedefs.linux index ee7c02489..79c6efb4b 100644 --- a/Make/makedefs.linux +++ b/Make/makedefs.linux @@ -11,15 +11,15 @@ YFLAGS = -d LCINCS += -I/usr/X11R6/include LC++INCS += ${LCINCS} CFLAGS = -O2 -W -Wall $(LCINCS) -#CFLAGS = -g -DOSG_USE_MEMORY_TRACKING -W -Wall $(LCINCS) +'CFLAGS = -g -DOSG_USE_MEMORY_MANAGER -W -Wall $(LCINCS) C++FLAGS = ${CFLAGS} CPPFLAGS = ${CFLAGS} SO_EXT = so DL_EXT = so -#LDFLAGS = -O2 -W -Wall -L/usr/X11R6/lib -LDFLAGS = -g -W -Wall -L/usr/X11R6/lib +LDFLAGS = -O2 -W -Wall -L/usr/X11R6/lib +#LDFLAGS = -g -W -Wall -L/usr/X11R6/lib LINKERARGS = -Xlinker DYNAMICLIBRARYLIB = -ldl diff --git a/Make/makedefs.macosx b/Make/makedefs.macosx index c88c64b7f..3a31fdd9e 100644 --- a/Make/makedefs.macosx +++ b/Make/makedefs.macosx @@ -10,7 +10,7 @@ YFLAGS = -d LCINCS += -I/usr/local/include -I/sw/include LC++INCS += ${LCINCS} CFLAGS = -O2 -W -Wall $(LCINCS) -D__DARWIN_OSX__ -#CFLAGS = -g -DOSG_USE_MEMORY_TRACKING -W -Wall $(LCINCS) -D__DARWIN_OSX__ +#CFLAGS = -g -DOSG_USE_MEMORY_MANAGER -W -Wall $(LCINCS) -D__DARWIN_OSX__ C++FLAGS = ${CFLAGS} CPPFLAGS = ${CFLAGS} # this distinction is necessary for Darwin / OS X as shared libs and loadable (dylib) modules diff --git a/include/osg/Export b/include/osg/Export index 5de474684..b8e548b90 100644 --- a/include/osg/Export +++ b/include/osg/Export @@ -33,4 +33,6 @@ #endif #endif +#include + #endif diff --git a/include/osg/GeoSet b/include/osg/GeoSet index f9ec3f775..c37ca28a3 100644 --- a/include/osg/GeoSet +++ b/include/osg/GeoSet @@ -150,9 +150,9 @@ class SG_EXPORT GeoSet : public Drawable /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ GeoSet(const GeoSet& geoset,const CopyOp& copyop=CopyOp::SHALLOW_COPY); - virtual Object* cloneType() const { return new GeoSet(); } + virtual Object* cloneType() const { return osgNew GeoSet(); } - virtual Object* clone(const CopyOp& copyop) const { return new GeoSet(*this,copyop); } + virtual Object* clone(const CopyOp& copyop) const { return osgNew GeoSet(*this,copyop); } virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast(obj)!=NULL; } diff --git a/include/osg/Image b/include/osg/Image index fcc366a5f..36c56beda 100644 --- a/include/osg/Image +++ b/include/osg/Image @@ -24,8 +24,8 @@ class SG_EXPORT Image : public Object /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ Image(const Image& image,const CopyOp& copyop=CopyOp::SHALLOW_COPY); - virtual Object* cloneType() const { return new Image(); } - virtual Object* clone(const CopyOp& copyop) const { return new Image(*this,copyop); } + virtual Object* cloneType() const { return osgNew Image(); } + virtual Object* clone(const CopyOp& copyop) const { return osgNew Image(*this,copyop); } virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast(obj)!=0; } virtual const char* className() const { return "Image"; } diff --git a/include/osg/ImpostorSprite b/include/osg/ImpostorSprite index 70d7c4063..7e2c26016 100644 --- a/include/osg/ImpostorSprite +++ b/include/osg/ImpostorSprite @@ -32,11 +32,11 @@ class SG_EXPORT ImpostorSprite : public Drawable ImpostorSprite(); /** Clone an object of the same type as an ImpostorSprite.*/ - virtual Object* cloneType() const { return new ImpostorSprite(); } + virtual Object* cloneType() const { return osgNew ImpostorSprite(); } /** Clone on ImpostorSprite just returns a clone of type, * since it is not appropriate to share data of an ImpostorSprite.*/ - virtual Object* clone(const CopyOp&) const { return new ImpostorSprite(); } + virtual Object* clone(const CopyOp&) const { return osgNew ImpostorSprite(); } virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast(obj)!=NULL; } virtual const char* className() const { return "ImpostorSprite"; } diff --git a/include/osg/LightSource b/include/osg/LightSource index 93bd19bce..65592a9d1 100644 --- a/include/osg/LightSource +++ b/include/osg/LightSource @@ -5,7 +5,6 @@ #ifndef OSG_LIGHTSOURCE #define OSG_LIGHTSOURCE 1 -#include #include #include diff --git a/include/osg/Matrix b/include/osg/Matrix index 89a882527..10b985a60 100644 --- a/include/osg/Matrix +++ b/include/osg/Matrix @@ -40,8 +40,8 @@ class SG_EXPORT Matrix : public Object float a20, float a21, float a22, float a23, float a30, float a31, float a32, float a33); - virtual Object* cloneType() const { return new Matrix(); } \ - virtual Object* clone(const CopyOp&) const { return new Matrix(*this); } \ + virtual Object* cloneType() const { return osgNew Matrix(); } \ + virtual Object* clone(const CopyOp&) const { return osgNew Matrix(*this); } \ virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast(obj)!=NULL; } \ virtual const char* className() const { return "Matrix"; } diff --git a/include/osg/MemoryManager b/include/osg/MemoryManager index a610c4d02..bbc952e52 100644 --- a/include/osg/MemoryManager +++ b/include/osg/MemoryManager @@ -14,6 +14,9 @@ #ifndef _H_MMGR #define _H_MMGR +#include +#include + // --------------------------------------------------------------------------------------------------------------------------------- // For systems that don't have the __FUNCTION__ variable, we can just define it here // --------------------------------------------------------------------------------------------------------------------------------- @@ -80,6 +83,7 @@ void m_setOwner(const char *file, const unsigned int line, const char *func); bool &m_breakOnRealloc(void *reportedAddress); bool &m_breakOnDealloc(void *reportedAddress); +void m_breakOnAllocation(unsigned int count); // --------------------------------------------------------------------------------------------------------------------------------- // The meat of the memory tracking software @@ -119,14 +123,14 @@ sMStats m_getMemoryStatistics(); // Variations of global operators new & delete // --------------------------------------------------------------------------------------------------------------------------------- -#ifdef OSG_USE_MEMORY_TRACKING +#ifdef OSG_USE_MEMORY_MANAGER - void *operator new(size_t reportedSize); - void *operator new[](size_t reportedSize); - void *operator new(size_t reportedSize, const char *sourceFile, int sourceLine); - void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine); - void operator delete(void *reportedAddress); - void operator delete[](void *reportedAddress); + void *operator new(size_t reportedSize) throw (std::bad_alloc); + void *operator new[](size_t reportedSize) throw (std::bad_alloc); + void *operator new(size_t reportedSize, const char *sourceFile, int sourceLine) throw (std::bad_alloc); + void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine) throw (std::bad_alloc); + void operator delete(void *reportedAddress) throw (); + void operator delete[](void *reportedAddress) throw (); // --------------------------------------------------------------------------------------------------------------------------------- // Macros -- "Kids, please don't try this at home. We're trained professionals here." :) diff --git a/include/osg/Node b/include/osg/Node index 51a0f8878..38e46b390 100644 --- a/include/osg/Node +++ b/include/osg/Node @@ -23,8 +23,8 @@ class Group; * and accept methods. Use when subclassing from Node to make it * more convinient to define the required pure virtual methods.*/ #define META_Node(name) \ - virtual osg::Object* cloneType() const { return new name (); } \ - virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new name (*this,copyop); } \ + virtual osg::Object* cloneType() const { return osgNew name (); } \ + virtual osg::Object* clone(const osg::CopyOp& copyop) const { return osgNew name (*this,copyop); } \ virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=NULL; } \ virtual const char* className() const { return #name; } \ virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } } \ @@ -46,10 +46,10 @@ class SG_EXPORT Node : public Object Node(const Node&,const CopyOp& copyop=CopyOp::SHALLOW_COPY); /** clone the an object of the same type as the node.*/ - virtual Object* cloneType() const { return new Node(); } + virtual Object* cloneType() const { return osgNew Node(); } /** return a clone of a node, with Object* return type.*/ - virtual Object* clone(const CopyOp& copyop) const { return new Node(*this,copyop); } + virtual Object* clone(const CopyOp& copyop) const { return osgNew Node(*this,copyop); } /** return true if this and obj are of the same kind of object.*/ virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast(obj)!=NULL; } diff --git a/include/osg/Notify b/include/osg/Notify index b0747e758..72b175e45 100644 --- a/include/osg/Notify +++ b/include/osg/Notify @@ -9,6 +9,7 @@ #include #include +#include namespace osg { @@ -32,7 +33,7 @@ enum NotifySeverity { SG_EXPORT extern NotifySeverity g_NotifyLevel; /** global notify nul stream. added for Mac OSX */ -SG_EXPORT extern std::ofstream *g_NotifyNulStream; +SG_EXPORT extern std::auto_ptr g_NotifyNulStream; /** global notify nul stream. added for Mac OSX */ SG_EXPORT extern bool g_NotifyInit; diff --git a/include/osg/Object b/include/osg/Object index 146c8301d..bc7aee797 100644 --- a/include/osg/Object +++ b/include/osg/Object @@ -15,8 +15,8 @@ namespace osg { * the standard pure virtual clone, isSameKindAs and className methods * which are required for all Object subclasses.*/ #define META_Object(T) \ - virtual osg::Object* cloneType() const { return new T (); } \ - virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new T (*this,copyop); } \ + virtual osg::Object* cloneType() const { return osgNew T (); } \ + virtual osg::Object* clone(const osg::CopyOp& copyop) const { return osgNew T (*this,copyop); } \ virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=NULL; } \ virtual const char* className() const { return #T; } diff --git a/include/osg/StateAttribute b/include/osg/StateAttribute index 0b9a09c6a..e7e3ad1fc 100644 --- a/include/osg/StateAttribute +++ b/include/osg/StateAttribute @@ -22,8 +22,8 @@ class StateSet; * the standard pure virtual methods which are required for all Object * subclasses.*/ #define META_StateAttribute(name,type) \ - virtual osg::Object* cloneType() const { return new name(); } \ - virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new name (*this,copyop); } \ + virtual osg::Object* cloneType() const { return osgNew name(); } \ + virtual osg::Object* clone(const osg::CopyOp& copyop) const { return osgNew name (*this,copyop); } \ virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=NULL; } \ virtual const char* className() const { return #name; } \ virtual const Type getType() const { return type; } diff --git a/include/osg/StateSet b/include/osg/StateSet index c8366454a..270b14a66 100644 --- a/include/osg/StateSet +++ b/include/osg/StateSet @@ -30,8 +30,8 @@ class SG_EXPORT StateSet : public Object StateSet(); StateSet(const StateSet&,const CopyOp& copyop=CopyOp::SHALLOW_COPY); - virtual Object* cloneType() const { return new StateSet(); } - virtual Object* clone(const CopyOp& copyop) const { return new StateSet(*this,copyop); } + virtual Object* cloneType() const { return osgNew StateSet(); } + virtual Object* clone(const CopyOp& copyop) const { return osgNew StateSet(*this,copyop); } virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast(obj)!=NULL; } virtual const char* className() const { return "StateSet"; } diff --git a/include/osg/mem_ptr b/include/osg/mem_ptr index 9984c1c47..1017c0f9b 100644 --- a/include/osg/mem_ptr +++ b/include/osg/mem_ptr @@ -170,7 +170,7 @@ class mem_ptr // return s_newMemoryAdapter.get(); // } // -// T* allocate(int no) { cout<<"Allocating Memory"< + #endif diff --git a/include/osgGLUT/glut b/include/osgGLUT/glut index 7b216d5e7..1ea07e0c0 100644 --- a/include/osgGLUT/glut +++ b/include/osgGLUT/glut @@ -5,10 +5,10 @@ #ifndef OSG_GLUT #define OSG_GLUT 1 -#ifdef __APPLE__ - #include +#if defined(__DARWIN_OSX__) + #include #else - #include + #include #endif #endif // __osgGLUT_h diff --git a/src/Demos/osgcluster/broadcaster.cpp b/src/Demos/osgcluster/broadcaster.cpp index 82fe590f4..6ee8bf48a 100644 --- a/src/Demos/osgcluster/broadcaster.cpp +++ b/src/Demos/osgcluster/broadcaster.cpp @@ -23,6 +23,8 @@ // nothing needed #elif defined(__sun) # include +#elif defined (__DARWIN_OSX__) // added +# include // added #else # error Teach me how to build on this system #endif diff --git a/src/Demos/osgtext/main.cpp b/src/Demos/osgtext/main.cpp index 4b042b758..591a11612 100644 --- a/src/Demos/osgtext/main.cpp +++ b/src/Demos/osgtext/main.cpp @@ -68,9 +68,9 @@ void set2dScene(osg::Group* rootNode) /////////////////////////////////////////////////////////////////////////// // BitmapFont - osgText::BitmapFont* bitmapFont=new osgText::BitmapFont(ttfPath, + osgText::BitmapFont* bitmapFont= osgNew osgText::BitmapFont(ttfPath, gFontSize1); - text=new osgText::Text(bitmapFont); + text= osgNew osgText::Text(bitmapFont); gTextList.push_back(text); text->setText(std::string("2d ")+std::string(TEXT_BITMAP)); text->setPosition(osg::Vec3(xOffset,yOffset,0)); @@ -78,14 +78,14 @@ void set2dScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNEMENT ); text->setAlignment(gAlignment); - geode = new osg::Geode(); + geode = osgNew osg::Geode(); geode->setName("BitmapFont"); geode->addDrawable( text ); - textMaterial = new osg::Material(); + textMaterial = osgNew osg::Material(); textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D); - textState = new osg::StateSet(); + textState = osgNew osg::StateSet(); textState->setAttribute(textMaterial ); geode->setStateSet( textState ); @@ -96,9 +96,9 @@ void set2dScene(osg::Group* rootNode) /////////////////////////////////////////////////////////////////////////// // PixmapFont - osgText::PixmapFont* pixmapFont=new osgText::PixmapFont(ttfPath, + osgText::PixmapFont* pixmapFont= osgNew osgText::PixmapFont(ttfPath, gFontSize1); - text=new osgText::Text(pixmapFont); + text= osgNew osgText::Text(pixmapFont); gTextList.push_back(text); text->setText(std::string("2d ")+std::string(TEXT_PIXMAP)); text->setPosition(osg::Vec3(xOffset,yOffset,0)); @@ -106,21 +106,21 @@ void set2dScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNEMENT ); text->setAlignment(gAlignment); - geode = new osg::Geode(); + geode = osgNew osg::Geode(); geode->setName("PixmapFont"); geode->addDrawable( text ); - textMaterial = new osg::Material(); + textMaterial = osgNew osg::Material(); textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_2D); // to get antiaA pixmapFonts we have to draw them with blending - osg::Transparency *transp=new osg::Transparency(); + osg::Transparency *transp= osgNew osg::Transparency(); transp->setFunction(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - textState = new osg::StateSet(); + textState = osgNew osg::StateSet(); textState->setAttribute(textMaterial ); textState->setAttribute(transp); textState->setMode(GL_BLEND,osg::StateAttribute::ON); @@ -136,9 +136,9 @@ void set2dScene(osg::Group* rootNode) /////////////////////////////////////////////////////////////////////////// // TextureFont - osgText::TextureFont* textureFont=new osgText::TextureFont(ttfPath1, + osgText::TextureFont* textureFont= osgNew osgText::TextureFont(ttfPath1, gFontSize1); - text=new osgText::Text(textureFont); + text= osgNew osgText::Text(textureFont); gTextList.push_back(text); text->setText(std::string("2d ")+std::string(TEXT_TEXTURE)); text->setPosition(osg::Vec3(xOffset,yOffset,0)); @@ -146,18 +146,18 @@ void set2dScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNEMENT ); text->setAlignment(gAlignment); - geode = new osg::Geode(); + geode = osgNew osg::Geode(); geode->setName("TextureFont"); geode->addDrawable( text ); - textMaterial = new osg::Material(); + textMaterial = osgNew osg::Material(); textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D); // to get antiaA pixmapFonts we have to draw them with blending - transp=new osg::Transparency(); + transp= osgNew osg::Transparency(); transp->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - textState = new osg::StateSet(); + textState = osgNew osg::StateSet(); textState->setAttribute(textMaterial ); textState->setAttribute(transp); @@ -172,10 +172,10 @@ void set2dScene(osg::Group* rootNode) /////////////////////////////////////////////////////////////////////////// // PolygonFont - osgText::PolygonFont* polygonFont=new osgText::PolygonFont(ttfPath, + osgText::PolygonFont* polygonFont= osgNew osgText::PolygonFont(ttfPath, gFontSize1, 3); - text=new osgText::Text(polygonFont); + text= osgNew osgText::Text(polygonFont); gTextList.push_back(text); text->setText(std::string("2d ")+std::string("TEXT_POLYGON")); text->setPosition(osg::Vec3(xOffset,yOffset,0)); @@ -183,14 +183,14 @@ void set2dScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNEMENT ); text->setAlignment(gAlignment); - geode = new osg::Geode(); + geode = osgNew osg::Geode(); geode->setName("PolygonFont"); geode->addDrawable( text ); - textMaterial = new osg::Material(); + textMaterial = osgNew osg::Material(); textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D); - textState = new osg::StateSet(); + textState = osgNew osg::StateSet(); textState->setAttribute(textMaterial ); geode->setStateSet( textState ); @@ -201,11 +201,11 @@ void set2dScene(osg::Group* rootNode) /////////////////////////////////////////////////////////////////////////// // OutlineFont - osgText::OutlineFont* outlineFont=new osgText::OutlineFont(ttfPath, + osgText::OutlineFont* outlineFont= osgNew osgText::OutlineFont(ttfPath, gFontSize1, 3); - text=new osgText::Text(outlineFont); + text= osgNew osgText::Text(outlineFont); gTextList.push_back(text); text->setText(std::string("2d ")+std::string(TEXT_OUTLINE)); text->setPosition(osg::Vec3(xOffset,yOffset,0)); @@ -213,14 +213,14 @@ void set2dScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNEMENT ); text->setAlignment(gAlignment); - geode = new osg::Geode(); + geode = osgNew osg::Geode(); geode->setName("OutlineFont"); geode->addDrawable( text ); - textMaterial = new osg::Material(); + textMaterial = osgNew osg::Material(); textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D); - textState = new osg::StateSet(); + textState = osgNew osg::StateSet(); textState->setAttribute(textMaterial ); geode->setStateSet( textState ); @@ -228,10 +228,10 @@ void set2dScene(osg::Group* rootNode) // now add a depth attribute to the scene to force it to draw on top. - osg::Depth* depth = new osg::Depth; + osg::Depth* depth = osgNew osg::Depth; depth->setRange(0.0,0.0); - osg::StateSet* rootState = new osg::StateSet(); + osg::StateSet* rootState = osgNew osg::StateSet(); rootState->setAttribute(depth); rootNode->setStateSet(rootState); @@ -251,9 +251,9 @@ void setScene(osg::Group* rootNode) // setup the texts /////////////////////////////////////////////////////////////////////////// // BitmapFont - osgText::BitmapFont* bitmapFont=new osgText::BitmapFont(ttfPath, + osgText::BitmapFont* bitmapFont= osgNew osgText::BitmapFont(ttfPath, gFontSize); - text=new osgText::Text(bitmapFont); + text= osgNew osgText::Text(bitmapFont); gTextList.push_back(text); text->setText(std::string(TEXT_BITMAP)); text->setPosition(osg::Vec3(xOffset,yOffset,0)); @@ -261,14 +261,14 @@ void setScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNEMENT ); text->setAlignment(gAlignment); - geode = new osg::Geode(); + geode = osgNew osg::Geode(); geode->setName("BitmapFont"); geode->addDrawable( text ); - textMaterial = new osg::Material(); + textMaterial = osgNew osg::Material(); textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D); - textState = new osg::StateSet(); + textState = osgNew osg::StateSet(); textState->setAttribute(textMaterial ); geode->setStateSet( textState ); @@ -278,9 +278,9 @@ void setScene(osg::Group* rootNode) /////////////////////////////////////////////////////////////////////////// // PixmapFont - osgText::PixmapFont* pixmapFont=new osgText::PixmapFont(ttfPath, + osgText::PixmapFont* pixmapFont= osgNew osgText::PixmapFont(ttfPath, gFontSize); - text=new osgText::Text(pixmapFont); + text= osgNew osgText::Text(pixmapFont); gTextList.push_back(text); text->setText(std::string(TEXT_PIXMAP)); text->setPosition(osg::Vec3(xOffset,yOffset,0)); @@ -288,18 +288,18 @@ void setScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNEMENT ); text->setAlignment(gAlignment); - geode = new osg::Geode(); + geode = osgNew osg::Geode(); geode->setName("PixmapFont"); geode->addDrawable( text ); - textMaterial = new osg::Material(); + textMaterial = osgNew osg::Material(); textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D); // to get antiaA pixmapFonts we have to draw them with blending - osg::Transparency *transp=new osg::Transparency(); + osg::Transparency *transp= osgNew osg::Transparency(); transp->setFunction(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - textState = new osg::StateSet(); + textState = osgNew osg::StateSet(); textState->setAttribute(textMaterial ); textState->setAttribute(transp); textState->setMode(GL_BLEND,osg::StateAttribute::ON); @@ -312,9 +312,9 @@ void setScene(osg::Group* rootNode) /////////////////////////////////////////////////////////////////////////// // TextureFont - osgText::TextureFont* textureFont=new osgText::TextureFont(ttfPath, + osgText::TextureFont* textureFont= osgNew osgText::TextureFont(ttfPath, gFontSize); - text=new osgText::Text(textureFont); + text= osgNew osgText::Text(textureFont); gTextList.push_back(text); text->setText(std::string(TEXT_TEXTURE)); text->setPosition(osg::Vec3(xOffset,yOffset,0)); @@ -322,18 +322,18 @@ void setScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNEMENT ); text->setAlignment(gAlignment); - geode = new osg::Geode(); + geode = osgNew osg::Geode(); geode->setName("TextureFont"); geode->addDrawable( text ); - textMaterial = new osg::Material(); + textMaterial = osgNew osg::Material(); textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D); // to get antiaA pixmapFonts we have to draw them with blending - transp=new osg::Transparency(); + transp= osgNew osg::Transparency(); transp->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - textState = new osg::StateSet(); + textState = osgNew osg::StateSet(); textState->setAttribute(textMaterial ); textState->setAttribute(transp); @@ -348,10 +348,10 @@ void setScene(osg::Group* rootNode) /////////////////////////////////////////////////////////////////////////// // PolygonFont - osgText::PolygonFont* polygonFont=new osgText::PolygonFont(ttfPath, + osgText::PolygonFont* polygonFont= osgNew osgText::PolygonFont(ttfPath, gFontSize, 3); - text=new osgText::Text(polygonFont); + text= osgNew osgText::Text(polygonFont); gTextList.push_back(text); text->setText(std::string(TEXT_POLYGON)); text->setPosition(osg::Vec3(xOffset,yOffset,0)); @@ -359,14 +359,14 @@ void setScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNEMENT ); text->setAlignment(gAlignment); - geode = new osg::Geode(); + geode = osgNew osg::Geode(); geode->setName("PolygonFont"); geode->addDrawable( text ); - textMaterial = new osg::Material(); + textMaterial = osgNew osg::Material(); textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D); - textState = new osg::StateSet(); + textState = osgNew osg::StateSet(); textState->setAttribute(textMaterial ); geode->setStateSet( textState ); @@ -376,11 +376,11 @@ void setScene(osg::Group* rootNode) /////////////////////////////////////////////////////////////////////////// // OutlineFont - osgText::OutlineFont* outlineFont=new osgText::OutlineFont(ttfPath, + osgText::OutlineFont* outlineFont= osgNew osgText::OutlineFont(ttfPath, gFontSize, 3); - text=new osgText::Text(outlineFont); + text= osgNew osgText::Text(outlineFont); gTextList.push_back(text); text->setText(std::string(TEXT_OUTLINE)); text->setPosition(osg::Vec3(xOffset,yOffset,0)); @@ -388,14 +388,14 @@ void setScene(osg::Group* rootNode) osgText::Text::BOUNDINGBOX | osgText::Text::ALIGNEMENT ); text->setAlignment(gAlignment); - geode = new osg::Geode(); + geode = osgNew osg::Geode(); geode->setName("OutlineFont"); geode->addDrawable( text ); - textMaterial = new osg::Material(); + textMaterial = osgNew osg::Material(); textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE); textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D); - textState = new osg::StateSet(); + textState = osgNew osg::StateSet(); textState->setAttribute(textMaterial ); geode->setStateSet( textState ); @@ -438,7 +438,7 @@ public: void addHUD(osg::Node* rootnode) { - _hudSceneView = new osgUtil::SceneView; + _hudSceneView = osgNew osgUtil::SceneView; _hudSceneView->setDefaults(); _hudSceneView->setSceneData(rootnode); @@ -466,7 +466,7 @@ public: _hudSceneView->getCullVisitor()->setCullingMode(osgUtil::CullViewState::NO_CULLING); _hudSceneView->setCalcNearFar(false); - _hudCam=new osg::Camera; + _hudCam = osgNew osg::Camera; // leftBottom _hudSceneView->setCamera(_hudCam.get()); @@ -478,9 +478,17 @@ public: protected: - osg::ref_ptr _hudCam; + osg::ref_ptr _hudCam; osg::ref_ptr _hudSceneView; + virtual void clear() + { + Viewer::clear(); + _hudCam = NULL; + _hudSceneView = NULL; + } + + virtual void keyboard(unsigned char key, int x, int y) { switch(key) @@ -559,16 +567,16 @@ int main( int argc, char **argv ) gFontSize1=8; } - osg::Group* rootNode = new osg::Group; - osg::Group* scene2d = new osg::Group; - osg::Transform* textGroup = new osg::Transform; + osg::Group* rootNode = osgNew osg::Group; + osg::Group* scene2d = osgNew osg::Group; + osg::Transform* textGroup = osgNew osg::Transform; // set the name for the hole group rootNode->setName("sceneGroup"); // turn off the culling // turn off the light - osg::StateSet* gstate = new osg::StateSet; + osg::StateSet* gstate = osgNew osg::StateSet; gstate->setMode(GL_CULL_FACE,osg::StateAttribute::OFF); gstate->setMode(GL_LIGHTING,osg::StateAttribute::OFF); gstate->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF); @@ -596,9 +604,9 @@ int main( int argc, char **argv ) viewer.addHUD(scene2d); // register trackball, flight and drive. - viewer.registerCameraManipulator(new osgUtil::TrackballManipulator); - viewer.registerCameraManipulator(new osgUtil::FlightManipulator); - viewer.registerCameraManipulator(new osgUtil::DriveManipulator); + viewer.registerCameraManipulator(osgNew osgUtil::TrackballManipulator); + viewer.registerCameraManipulator(osgNew osgUtil::FlightManipulator); + viewer.registerCameraManipulator(osgNew osgUtil::DriveManipulator); viewer.open(); viewer.run(); diff --git a/src/osg/Camera.cpp b/src/osg/Camera.cpp index d968b34ec..59ad5d938 100644 --- a/src/osg/Camera.cpp +++ b/src/osg/Camera.cpp @@ -433,7 +433,7 @@ void Camera::attachTransform(const TransformMode mode, Matrix* matrix) if (_eyeToModelTransform.valid()) { _attachedTransformMode = mode; - if (!_modelToEyeTransform.valid()) _modelToEyeTransform = new Matrix; + if (!_modelToEyeTransform.valid()) _modelToEyeTransform = osgNew Matrix; if (!_modelToEyeTransform->invert(*_eyeToModelTransform)) { notify(WARN)<<"Warning: Camera::attachTransform() failed to invert _modelToEyeTransform"<invert(*_modelToEyeTransform)) { notify(WARN)<<"Warning: Camera::attachTransform() failed to invert _modelToEyeTransform"<makeIdentity(); } break; @@ -711,7 +711,7 @@ void Camera::calculateMatricesAndClippingVolume() const Vec3 u(s^f); u.normalize(); - ref_ptr matrix = new Matrix( + ref_ptr matrix = osgNew Matrix( s[0], u[0], -f[0], 0.0f, s[1], u[1], -f[1], 0.0f, s[2], u[2], -f[2], 0.0f, @@ -721,7 +721,7 @@ void Camera::calculateMatricesAndClippingVolume() const if (_modelToEyeTransform.valid()) { - _modelViewMatrix = new Matrix; + _modelViewMatrix = osgNew Matrix; (*_modelViewMatrix) = (*matrix) * (*_modelToEyeTransform); } else @@ -791,10 +791,10 @@ void Camera::calculateMatricesAndClippingVolume() const _clippingVolume.transformProvidingInverse(*_modelViewMatrix); - if (!_mp.valid()) _mp = new Matrix; + if (!_mp.valid()) _mp = osgNew Matrix; _mp->mult(*_modelViewMatrix,*_projectionMatrix); - if (!_inversemp.valid()) _inversemp = new Matrix; + if (!_inversemp.valid()) _inversemp = osgNew Matrix; if (!_inversemp->invert(*_mp)) { notify(WARN)<<"Warning: Camera::calculateMatricesAndClippingVolume() failed to invert _mp"<setRenderBinDetails(-1,"RenderBin"); setStateSet(stateset); diff --git a/src/osg/GeoSet.cpp b/src/osg/GeoSet.cpp index 9f3a24b5a..9f39a2ebd 100644 --- a/src/osg/GeoSet.cpp +++ b/src/osg/GeoSet.cpp @@ -18,7 +18,7 @@ GeoSet::GeoSet() // we will use the a default delete functor which // assumes that users have allocated arrays with new only // and that now sharing of attributes exists between GeoSet's. - _adf = new AttributeDeleteFunctor; + _adf = osgNew AttributeDeleteFunctor; _coords = (Vec3 *)0; @@ -66,7 +66,7 @@ GeoSet::GeoSet(const GeoSet& geoset,const CopyOp& copyop): _flat_shaded_skip = geoset._flat_shaded_skip; if (geoset._primLengths) { - _primLengths = new int [_numprims]; + _primLengths = osgNew int [_numprims]; memcpy(_primLengths,geoset._primLengths,_numprims*sizeof(int)); } else @@ -78,7 +78,7 @@ GeoSet::GeoSet(const GeoSet& geoset,const CopyOp& copyop): _cindex = geoset._cindex; if (geoset._coords) { - _coords = new Vec3 [_numcoords]; + _coords = osgNew Vec3 [_numcoords]; memcpy(_coords,geoset._coords,_numcoords*sizeof(Vec3)); } else @@ -91,7 +91,7 @@ GeoSet::GeoSet(const GeoSet& geoset,const CopyOp& copyop): _nindex = geoset._nindex; if (geoset._normals) { - _normals = new Vec3 [_numnormals]; + _normals = osgNew Vec3 [_numnormals]; memcpy(_normals,geoset._normals,_numnormals*sizeof(Vec3)); } else @@ -104,7 +104,7 @@ GeoSet::GeoSet(const GeoSet& geoset,const CopyOp& copyop): _colindex = geoset._colindex; if (geoset._colors) { - _colors = new Vec4 [_numcolors]; + _colors = osgNew Vec4 [_numcolors]; memcpy(_colors,geoset._colors,_numcolors*sizeof(Vec4)); } else @@ -117,7 +117,7 @@ GeoSet::GeoSet(const GeoSet& geoset,const CopyOp& copyop): _tindex = geoset._tindex; if (geoset._tcoords) { - _tcoords = new Vec2 [_numtcoords]; + _tcoords = osgNew Vec2 [_numtcoords]; memcpy(_tcoords,geoset._tcoords,_numtcoords*sizeof(Vec2)); } else diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 394364885..2be3ba092 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -192,27 +192,27 @@ Geode* osg::createGeodeForImage(osg::Image* image,const float s,const float t) float x = y*(s/t); // set up the texture. - osg::Texture* texture = new osg::Texture; + osg::Texture* texture = osgNew osg::Texture; texture->setImage(image); // set up the drawstate. - osg::StateSet* dstate = new osg::StateSet; + osg::StateSet* dstate = osgNew osg::StateSet; dstate->setMode(GL_CULL_FACE,osg::StateAttribute::OFF); dstate->setMode(GL_LIGHTING,osg::StateAttribute::OFF); dstate->setAttributeAndModes(texture,osg::StateAttribute::ON); // set up the geoset. - osg::GeoSet* gset = new osg::GeoSet; + osg::GeoSet* gset = osgNew osg::GeoSet; gset->setStateSet(dstate); - osg::Vec3* coords = new Vec3[4]; + osg::Vec3* coords = osgNew Vec3[4]; coords[0].set(-x,0.0f,y); coords[1].set(-x,0.0f,-y); coords[2].set(x,0.0f,-y); coords[3].set(x,0.0f,y); gset->setCoords(coords); - osg::Vec2* tcoords = new Vec2[4]; + osg::Vec2* tcoords = osgNew Vec2[4]; tcoords[0].set(0.0f,1.0f); tcoords[1].set(0.0f,0.0f); tcoords[2].set(1.0f,0.0f); @@ -220,7 +220,7 @@ Geode* osg::createGeodeForImage(osg::Image* image,const float s,const float t) gset->setTextureCoords(tcoords); gset->setTextureBinding(osg::GeoSet::BIND_PERVERTEX); - osg::Vec4* colours = new Vec4[1]; + osg::Vec4* colours = osgNew Vec4[1]; colours->set(1.0f,1.0f,1.0,1.0f); gset->setColors(colours); gset->setColorBinding(osg::GeoSet::BIND_OVERALL); @@ -229,7 +229,7 @@ Geode* osg::createGeodeForImage(osg::Image* image,const float s,const float t) gset->setPrimType(osg::GeoSet::QUADS); // set up the geode. - osg::Geode* geode = new osg::Geode; + osg::Geode* geode = osgNew osg::Geode; geode->addDrawable(gset); return geode; diff --git a/src/osg/ImpostorSprite.cpp b/src/osg/ImpostorSprite.cpp index df04a95d5..a37997826 100644 --- a/src/osg/ImpostorSprite.cpp +++ b/src/osg/ImpostorSprite.cpp @@ -138,10 +138,10 @@ void ImpostorSprite::setTexture(Texture* tex,int s,int t) ImpostorSpriteManager::ImpostorSpriteManager() { - _texenv = new TexEnv; + _texenv = osgNew TexEnv; _texenv->setMode(TexEnv::REPLACE); - _alphafunc = new osg::AlphaFunc; + _alphafunc = osgNew osg::AlphaFunc; _alphafunc->setFunction( AlphaFunc::GREATER, 0.000f ); _first = NULL; @@ -248,24 +248,24 @@ ImpostorSprite* ImpostorSpriteManager::createOrReuseImpostorSprite(int s,int t,i // creating new impostor sprite. - StateSet* stateset = new StateSet; + StateSet* stateset = osgNew StateSet; stateset->setMode(GL_CULL_FACE,osg::StateAttribute::OFF); stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF); stateset->setMode(GL_BLEND,osg::StateAttribute::ON); - Texture* texture = new Texture; + Texture* texture = osgNew Texture; stateset->setAttributeAndModes(texture,StateAttribute::ON); stateset->setAttributeAndModes( _alphafunc.get(), StateAttribute::ON ); stateset->setAttribute(_texenv.get()); /* - TexEnv* texenv = new TexEnv; + TexEnv* texenv = osgNew TexEnv; texenv->setMode(TexEnv::REPLACE); stateset->setAttribute(texenv); - AlphaFunc* alphafunc = new osg::AlphaFunc; + AlphaFunc* alphafunc = osgNew osg::AlphaFunc; alphafunc->setFunction( AlphaFunc::GREATER, 0.000f ); stateset->setAttributeAndModes( alphafunc, StateAttribute::ON ); */ @@ -273,7 +273,7 @@ ImpostorSprite* ImpostorSpriteManager::createOrReuseImpostorSprite(int s,int t,i // stateset->setMode( GL_ALPHA_TEST, StateAttribute::OFF ); - ImpostorSprite* is = new ImpostorSprite; + ImpostorSprite* is = osgNew ImpostorSprite; is->setStateSet(stateset); is->setTexture(texture,s,t); diff --git a/src/osg/MemoryManager.cpp b/src/osg/MemoryManager.cpp index cf83aec8e..4369e2e4a 100644 --- a/src/osg/MemoryManager.cpp +++ b/src/osg/MemoryManager.cpp @@ -198,6 +198,32 @@ static bool staticDeinitTime = false; static sAllocUnit **reservoirBuffer = NULL; static unsigned int reservoirBufferSize = 0; +// --------------------------------------------------------------------------------------------------------------------------------- +// We use a static class to let us know when we're in the midst of static deinitialization +// --------------------------------------------------------------------------------------------------------------------------------- +static void dumpLeakReport(); +static void doCleanupLogOnFirstRun(); + +#ifdef OSG_USE_MEMORY_MANAGER + +class MemStaticTimeTracker +{ +public: + MemStaticTimeTracker() + { + doCleanupLogOnFirstRun(); + } + ~MemStaticTimeTracker() + { + staticDeinitTime = true; + dumpLeakReport(); + } +}; +static MemStaticTimeTracker mstt; + +#endif + + // --------------------------------------------------------------------------------------------------------------------------------- // Local functions only // --------------------------------------------------------------------------------------------------------------------------------- @@ -459,6 +485,7 @@ static void dumpLeakReport() // Open the report file FILE *fp = fopen("memleaks.log", "w+b"); + //FILE *fp = stderr; // If you hit this assert, then the memory report generator is unable to log information to a file (can't open the file for // some reason.) @@ -510,21 +537,6 @@ static void dumpLeakReport() fclose(fp); } -// --------------------------------------------------------------------------------------------------------------------------------- -// We use a static class to let us know when we're in the midst of static deinitialization -// --------------------------------------------------------------------------------------------------------------------------------- - -#ifdef OSG_USE_MEMORY_TRACKING - -class MemStaticTimeTracker -{ -public: - MemStaticTimeTracker() {doCleanupLogOnFirstRun();} - ~MemStaticTimeTracker() {staticDeinitTime = true; dumpLeakReport();} -}; -static MemStaticTimeTracker mstt; - -#endif // --------------------------------------------------------------------------------------------------------------------------------- // -DOC- Flags & options -- Call these routines to enable/disable the following options @@ -629,9 +641,9 @@ void m_setOwner(const char *file, const unsigned int line, const char *func) // memory tracking routines. // --------------------------------------------------------------------------------------------------------------------------------- -#ifdef OSG_USE_MEMORY_TRACKING +#ifdef OSG_USE_MEMORY_MANAGER -void *operator new(size_t reportedSize) +void *operator new(size_t reportedSize) throw (std::bad_alloc) { #ifdef TEST_MEMORY_MANAGER log("ENTER: new"); @@ -683,7 +695,7 @@ void *operator new(size_t reportedSize) // --------------------------------------------------------------------------------------------------------------------------------- -void *operator new[](size_t reportedSize) +void *operator new[](size_t reportedSize) throw (std::bad_alloc) { #ifdef TEST_MEMORY_MANAGER log("ENTER: new[]"); @@ -741,7 +753,7 @@ void *operator new[](size_t reportedSize) // our memory tracking routines. // --------------------------------------------------------------------------------------------------------------------------------- -void *operator new(size_t reportedSize, const char *sourceFile, int sourceLine) +void *operator new(size_t reportedSize, const char *sourceFile, int sourceLine) throw (std::bad_alloc) { #ifdef TEST_MEMORY_MANAGER log("ENTER: new"); @@ -793,7 +805,7 @@ void *operator new(size_t reportedSize, const char *sourceFile, int sourceLine) // --------------------------------------------------------------------------------------------------------------------------------- -void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine) +void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine) throw (std::bad_alloc) { #ifdef TEST_MEMORY_MANAGER log("ENTER: new[]"); @@ -850,7 +862,7 @@ void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine // but use our memory tracking routines. // --------------------------------------------------------------------------------------------------------------------------------- -void operator delete(void *reportedAddress) +void operator delete(void *reportedAddress) throw () { #ifdef TEST_MEMORY_MANAGER log("ENTER: delete"); @@ -869,7 +881,7 @@ void operator delete(void *reportedAddress) // --------------------------------------------------------------------------------------------------------------------------------- -void operator delete[](void *reportedAddress) +void operator delete[](void *reportedAddress) throw () { #ifdef TEST_MEMORY_MANAGER log("ENTER: delete[]"); @@ -1599,3 +1611,4 @@ sMStats m_getMemoryStatistics() // --------------------------------------------------------------------------------------------------------------------------------- // mmgr.cpp - End of file // --------------------------------------------------------------------------------------------------------------------------------- + diff --git a/src/osg/Notify.cpp b/src/osg/Notify.cpp index ee8bcb2d9..1a92f3719 100644 --- a/src/osg/Notify.cpp +++ b/src/osg/Notify.cpp @@ -4,7 +4,7 @@ using namespace std; osg::NotifySeverity osg::g_NotifyLevel = osg::NOTICE; -std::ofstream *osg::g_NotifyNulStream; +std::auto_ptr osg::g_NotifyNulStream; bool osg::g_NotifyInit = false; void osg::setNotifyLevel(osg::NotifySeverity severity) @@ -29,9 +29,9 @@ bool osg::initNotifyLevel() // set up global notify null stream for inline notify #if defined(WIN32) && !defined(__CYGWIN__) - g_NotifyNulStream = new std::ofstream ("nul"); + g_NotifyNulStream.reset(osgNew std::ofstream ("nul")); #else - g_NotifyNulStream = new std::ofstream ("/dev/null"); + g_NotifyNulStream.reset(osgNew std::ofstream ("/dev/null")); #endif // g_NotifyLevel diff --git a/src/osg/StateSet.cpp b/src/osg/StateSet.cpp index 367a070a4..70851b813 100644 --- a/src/osg/StateSet.cpp +++ b/src/osg/StateSet.cpp @@ -130,10 +130,10 @@ void StateSet::setGlobalDefaults() setRendingBinToInherit(); - setAttributeAndModes(new AlphaFunc,StateAttribute::OFF); - setAttributeAndModes(new Transparency,StateAttribute::OFF); + setAttributeAndModes(osgNew AlphaFunc,StateAttribute::OFF); + setAttributeAndModes(osgNew Transparency,StateAttribute::OFF); - Material *material = new Material; + Material *material = osgNew Material; material->setColorMode(Material::AMBIENT_AND_DIFFUSE); setAttributeAndModes(material,StateAttribute::ON); /* @@ -148,17 +148,17 @@ void StateSet::setGlobalDefaults() setMode(GL_TEXTURE_GEN_R,StateAttribute::OFF); setMode(GL_TEXTURE_GEN_Q,StateAttribute::OFF); - setAttributeAndModes(new AlphaFunc,StateAttribute::OFF); - setAttributeAndModes(new CullFace,StateAttribute::ON); - setAttributeAndModes(new FrontFace,StateAttribute::ON); + setAttributeAndModes(osgNew AlphaFunc,StateAttribute::OFF); + setAttributeAndModes(osgNew CullFace,StateAttribute::ON); + setAttributeAndModes(osgNew FrontFace,StateAttribute::ON); - Material *material = new Material; + Material *material = osgNew Material; material->setColorMode(Material::AMBIENT_AND_DIFFUSE); setAttributeAndModes(material,StateAttribute::ON); - setAttributeAndModes(new PolygonMode,StateAttribute::OFF); - setAttributeAndModes(new Transparency,StateAttribute::OFF); - setAttributeAndModes(new Depth,StateAttribute::ON); + setAttributeAndModes(osgNew PolygonMode,StateAttribute::OFF); + setAttributeAndModes(osgNew Transparency,StateAttribute::OFF); + setAttributeAndModes(osgNew Depth,StateAttribute::ON); */ } diff --git a/src/osg/Transform.cpp b/src/osg/Transform.cpp index a5c838ede..f76fc8668 100644 --- a/src/osg/Transform.cpp +++ b/src/osg/Transform.cpp @@ -7,8 +7,8 @@ Transform::Transform() _type = DYNAMIC; _mode = MODEL; - _matrix = new Matrix; - _inverse = new Matrix; + _matrix = osgNew Matrix; + _inverse = osgNew Matrix; _inverseDirty = false; } @@ -17,8 +17,8 @@ Transform::Transform(const Transform& transform,const CopyOp& copyop): _type(transform._type), _mode(transform._mode), _computeTransformCallback(_computeTransformCallback), - _matrix(new Matrix(*transform._matrix)), - _inverse(new Matrix(*transform._inverse)), + _matrix(osgNew Matrix(*transform._matrix)), + _inverse(osgNew Matrix(*transform._inverse)), _inverseDirty(transform._inverseDirty) { } @@ -28,8 +28,8 @@ Transform::Transform(const Matrix& mat ) _type = DYNAMIC; _mode = MODEL; - _matrix = new Matrix(mat); - _inverse = new Matrix(); + _matrix = osgNew Matrix(mat); + _inverse = osgNew Matrix(); _inverseDirty = false; } diff --git a/src/osgDB/DynamicLibrary.cpp b/src/osgDB/DynamicLibrary.cpp index 74c7bed5a..3826d46f0 100644 --- a/src/osgDB/DynamicLibrary.cpp +++ b/src/osgDB/DynamicLibrary.cpp @@ -41,11 +41,11 @@ DynamicLibrary* DynamicLibrary::loadLibrary(const std::string& libraryName) #if defined(WIN32) && !defined(__CYGWIN__) HANDLE handle = LoadLibrary( fullLibraryName ); - if (handle) return new DynamicLibrary(libraryName,handle); + if (handle) return osgNew DynamicLibrary(libraryName,handle); notify(WARN) << "DynamicLibrary::failed loading "<=_fieldCacheCapacity-1) @@ -154,9 +154,9 @@ void Field::addChar(char c) if (_fieldCacheCapacity=_fieldCacheCapacity-1) _fieldCacheCapacity *= 2; char* tmp_str = _fieldCache; - _fieldCache = new char[_fieldCacheCapacity]; + _fieldCache = osgNew char[_fieldCacheCapacity]; strncpy(_fieldCache,tmp_str,_fieldCacheSize); - delete [] tmp_str; + osgDelete [] tmp_str; } _fieldCache[_fieldCacheSize++] = c; diff --git a/src/osgDB/FieldReaderIterator.cpp b/src/osgDB/FieldReaderIterator.cpp index a05f05d72..656375084 100644 --- a/src/osgDB/FieldReaderIterator.cpp +++ b/src/osgDB/FieldReaderIterator.cpp @@ -66,17 +66,17 @@ void FieldReaderIterator::_copy(const FieldReaderIterator& ic) if (ic._previousField) { - _previousField = new Field(*ic._previousField); + _previousField = osgNew Field(*ic._previousField); } if (ic._fieldQueue && ic._fieldQueueCapacity>0) { - _fieldQueue = new Field* [ic._fieldQueueCapacity]; + _fieldQueue = osgNew Field* [ic._fieldQueueCapacity]; for(int i=0;i=newCapacity) newCapacity*=2; - Field** newFieldStack = new Field* [newCapacity]; + Field** newFieldStack = osgNew Field* [newCapacity]; for(i=0;i<_fieldQueueCapacity;++i) { newFieldStack[i] = _fieldQueue[i]; @@ -154,7 +154,7 @@ void FieldReaderIterator::insert(int pos,const char* str) { if (str) { - Field* field = new Field; + Field* field = osgNew Field; while(*str!=0) { field->addChar(*str); @@ -190,7 +190,7 @@ Field& FieldReaderIterator::field (int pos) int newCapacity = _fieldQueueCapacity*2; if (newCapacity=newCapacity) newCapacity*=2; - Field** newFieldStack = new Field* [newCapacity]; + Field** newFieldStack = osgNew Field* [newCapacity]; int i; for(i=0;i<_fieldQueueCapacity;++i) { @@ -205,7 +205,7 @@ Field& FieldReaderIterator::field (int pos) } while(!_reader.eof() && pos>=_fieldQueueSize) { - if (_fieldQueue[_fieldQueueSize]==NULL) _fieldQueue[_fieldQueueSize] = new Field; + if (_fieldQueue[_fieldQueueSize]==NULL) _fieldQueue[_fieldQueueSize] = osgNew Field; if (_reader.readField(*_fieldQueue[_fieldQueueSize])) { ++_fieldQueueSize; @@ -243,7 +243,7 @@ FieldReaderIterator& FieldReaderIterator::operator += (int no) } else if (no>0) { - Field** tmpFields = new Field* [no]; + Field** tmpFields = osgNew Field* [no]; int i; for(i=0;i& commandLine) } else // size >1 { - osg::Group* group = new osg::Group; + osg::Group* group = osgNew osg::Group; for(NodeList::iterator itr=nodeList.begin(); itr!=nodeList.end(); ++itr) diff --git a/src/osgDB/Registry.cpp b/src/osgDB/Registry.cpp index 0515b6568..88800dc95 100644 --- a/src/osgDB/Registry.cpp +++ b/src/osgDB/Registry.cpp @@ -34,7 +34,7 @@ class RegistryPtr Registry* Registry::instance() { - static RegistryPtr s_nodeFactory = new Registry; + static RegistryPtr s_nodeFactory = osgNew Registry; return s_nodeFactory.get(); } @@ -253,7 +253,6 @@ bool Registry::loadLibrary(const std::string& fileName) if (dl) { - dl->ref(); _dlList.push_back(dl); return true; } @@ -635,7 +634,7 @@ ReaderWriter::ReadResult Registry::readObject(const std::string& fileName) // now look for a plug-in to load the file. std::string libraryName = createLibraryNameForFile(fileName); - if (Registry::instance()->loadLibrary(libraryName)) + if (loadLibrary(libraryName)) { for(ReaderWriterList::iterator itr=_rwList.begin(); itr!=_rwList.end(); @@ -882,7 +881,7 @@ ReaderWriter::WriteResult Registry::writeNode(const Node& node,const std::string // now look for a plug-in to save the file. std::string libraryName = createLibraryNameForFile(fileName); - if (Registry::instance()->loadLibrary(libraryName)) + if (loadLibrary(libraryName)) { for(ReaderWriterList::iterator itr=_rwList.begin(); itr!=_rwList.end(); diff --git a/src/osgGLUT/Viewer.cpp b/src/osgGLUT/Viewer.cpp index 5f4578889..db47fe919 100644 --- a/src/osgGLUT/Viewer.cpp +++ b/src/osgGLUT/Viewer.cpp @@ -94,7 +94,7 @@ Viewer::Viewer() _printStats = 0; // gwm change from bool was : false; #ifdef SGV_USE_RTFS - fs = new RTfs( RTFS_MODE_RTC_SPIN ); + fs = osgNew RTfs( RTFS_MODE_RTC_SPIN ); frame_rate = 16; fs->setUpdateRate( frame_rate ); #endif @@ -118,9 +118,9 @@ Viewer::Viewer() _focusedViewport = 0; // The viewport with mouse/keyboard focus - _frameStamp = new osg::FrameStamp; + _frameStamp = osgNew osg::FrameStamp; - _displaySettings = new osg::DisplaySettings; + _displaySettings = osgNew osg::DisplaySettings; } @@ -166,9 +166,9 @@ bool Viewer::open() { osg::notify(osg::INFO)<<"osgGLUT::Viewer::open() called without any camara manipulators registered for a viewport,"<< std::endl; osg::notify(osg::INFO)<<"automatically registering trackball,flight and drive manipulators."<< std::endl; - registerCameraManipulator(new osgUtil::TrackballManipulator, index); - registerCameraManipulator(new osgUtil::FlightManipulator, index); - registerCameraManipulator(new osgUtil::DriveManipulator, index); + registerCameraManipulator(osgNew osgUtil::TrackballManipulator, index); + registerCameraManipulator(osgNew osgUtil::FlightManipulator, index); + registerCameraManipulator(osgNew osgUtil::DriveManipulator, index); } if (!itr->_cameraManipulator.valid()) @@ -195,7 +195,7 @@ bool Viewer::open() sceneView->setViewport(view[0], view[1], view[2], view[3]); - osg::ref_ptr ea = new GLUTEventAdapter; + osg::ref_ptr ea = osgNew GLUTEventAdapter; ea->adaptResize(clockSeconds(), view[0], view[1], view[0]+view[2], view[1]+view[3]); @@ -310,7 +310,7 @@ void Viewer::selectCameraManipulator(unsigned int pos, unsigned int viewport) viewp._cameraManipulator->setCamera(sceneView->getCamera()); viewp._cameraManipulator->setNode(sceneView->getSceneData()); - osg::ref_ptr ea = new GLUTEventAdapter; + osg::ref_ptr ea = osgNew GLUTEventAdapter; viewp._cameraManipulator->init(*ea,*this); } @@ -332,7 +332,7 @@ float Viewer::app(unsigned int viewport) // update the camera manipulator. - osg::ref_ptr ea = new GLUTEventAdapter; + osg::ref_ptr ea = osgNew GLUTEventAdapter; ea->adaptFrame(_frameStamp->getReferenceTime()); if (_viewportList[viewport]._cameraManipulator->handle(*ea,*this)) @@ -568,7 +568,7 @@ void Viewer::showStats(const unsigned int /*viewport*/) //osg::notify(osg::INFO) << "ntop "<< ntop<< std::endl; } maxbins=(primStats[0].getBins()>maxbins)?primStats[0].getBins():maxbins; - delete [] primStats; // free up + osgDelete [] primStats; // free up } if (_printStats==Statistics::STAT_DC) { // yet more stats - read the depth complexity int wid=_ww, ht=_wh; // temporary local screen size - must change during this section @@ -608,9 +608,9 @@ void Viewer::showStats(const unsigned int /*viewport*/) displaytext(0,(int)(0.86f*vh),ctext); glEnable(GL_STENCIL_TEST); // re-enable stencil buffer counting - delete [] buffer; + osgDelete [] buffer; } - delete [] clin; + osgDelete [] clin; } } @@ -693,7 +693,7 @@ void Viewer::reshape(GLint w, GLint h) sceneView->setViewport(view[0], view[1], view[2], view[3]); - osg::ref_ptr ea = new GLUTEventAdapter; + osg::ref_ptr ea = osgNew GLUTEventAdapter; ea->adaptResize(clockSeconds(), view[0], view[1], view[0]+view[2], view[1]+view[3]); @@ -708,7 +708,7 @@ void Viewer::reshape(GLint w, GLint h) void Viewer::mouseMotion(int x, int y) { - osg::ref_ptr ea = new GLUTEventAdapter; + osg::ref_ptr ea = osgNew GLUTEventAdapter; ea->adaptMouseMotion(clockSeconds(),x,y); if (_viewportList[_focusedViewport]._cameraManipulator->handle(*ea,*this)) @@ -724,7 +724,7 @@ void Viewer::mouseMotion(int x, int y) void Viewer::mousePassiveMotion(int x, int y) { - osg::ref_ptr ea = new GLUTEventAdapter; + osg::ref_ptr ea = osgNew GLUTEventAdapter; ea->adaptMousePassiveMotion(clockSeconds(),x,y); // Switch viewport focus if no buttons are pressed @@ -744,7 +744,7 @@ void Viewer::mousePassiveMotion(int x, int y) void Viewer::mouse(int button, int state, int x, int y) { - osg::ref_ptr ea = new GLUTEventAdapter; + osg::ref_ptr ea = osgNew GLUTEventAdapter; ea->adaptMouse(clockSeconds(),button,state,x,y); // Switch viewport focus if button is pressed, and it is the only one @@ -769,7 +769,7 @@ void Viewer::mouse(int button, int state, int x, int y) void Viewer::keyboard(unsigned char key, int x, int y) { - osg::ref_ptr ea = new GLUTEventAdapter; + osg::ref_ptr ea = osgNew GLUTEventAdapter; ea->adaptKeyboard(clockSeconds(),key,x,y); if (_viewportList[_focusedViewport]._cameraManipulator->handle(*ea,*this)) @@ -885,7 +885,7 @@ void Viewer::keyboard(unsigned char key, int x, int y) osg::ShadeModel* shademodel = dynamic_cast(stateset->getAttribute(osg::StateAttribute::SHADEMODEL)); if (!shademodel) { - shademodel = new osg::ShadeModel; + shademodel = osgNew osg::ShadeModel; stateset->setAttribute(shademodel,osg::StateAttribute::OVERRIDE); } @@ -958,7 +958,7 @@ void Viewer::keyboard(unsigned char key, int x, int y) // use blank texture to override all local texture in scene graph. // thus causing them to all use the same texture attribute, hence // preventing a state attribute change due to unused textures. - static osg::ref_ptr blank_texture = new osg::Texture; + static osg::ref_ptr blank_texture = osgNew osg::Texture; sceneView->getGlobalStateSet()->setMode(GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE_OFF); // sceneView->getGlobalStateSet()->setAttribute(blank_texture.get(),true); } @@ -969,7 +969,7 @@ void Viewer::keyboard(unsigned char key, int x, int y) osg::LightModel* lightmodel = dynamic_cast(sceneView->getGlobalStateSet()->getAttribute(osg::StateAttribute::LIGHTMODEL)); if (lightmodel) { - lightmodel = new osg::LightModel; + lightmodel = osgNew osg::LightModel; sceneView->getGlobalStateSet()->setAttribute(lightmodel); } lightmodel->setTwoSided(!lightmodel->getTwoSided()); @@ -979,7 +979,7 @@ void Viewer::keyboard(unsigned char key, int x, int y) case 'w' : { polymode = (polymode+1)%3; - osg::PolygonMode* polyModeObj = new osg::PolygonMode; + osg::PolygonMode* polyModeObj = osgNew osg::PolygonMode; polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,polymodes[polymode]); sceneView->getGlobalStateSet()->setAttribute(polyModeObj); } @@ -1065,7 +1065,7 @@ void Viewer::keyboard(unsigned char key, int x, int y) return; } - osg::ref_ptr lineSegment = new osg::LineSegment; + osg::ref_ptr lineSegment = osgNew osg::LineSegment; lineSegment->set(near_point,far_point); osg::notify(osg::NOTICE) << "start("<start()<<") end("<end()<<")"<< std::endl; @@ -1190,7 +1190,7 @@ void Viewer::help(std::ostream& fout) <<" current mouse x and mouse y position."<< std::endl << std::endl <<"r Calculate and report the intersections with the scene under the"<< std::endl - <<" current mouse x and mouse y position and delete the nearest"<< std::endl + <<" current mouse x and mouse y position and osgDelete the nearest"<< std::endl <<" interesected geoset."<< std::endl << std::endl <<"7 Set the background color to black."<< std::endl @@ -1232,16 +1232,18 @@ osg::Timer_t Viewer::updateFrameTick() bool Viewer::run() { - // Reset the views of all of SceneViews - osg::ref_ptr ea = new GLUTEventAdapter; - - for(ViewportList::iterator itr=_viewportList.begin(); - itr!=_viewportList.end(); - ++itr) { - itr->_cameraManipulator->home(*ea,*this); - } + // Reset the views of all of SceneViews + osg::ref_ptr ea = osgNew GLUTEventAdapter; + for(ViewportList::iterator itr=_viewportList.begin(); + itr!=_viewportList.end(); + ++itr) + { + itr->_cameraManipulator->home(*ea,*this); + } + } + updateFrameTick(); return Window::run(); } @@ -1266,7 +1268,7 @@ void Viewer::addViewport(osgUtil::SceneView* sv, void Viewer::addViewport(osg::Node* rootnode, float x, float y, float width, float height) { - osgUtil::SceneView *sceneView = new osgUtil::SceneView(_displaySettings.get()); + osgUtil::SceneView *sceneView = osgNew osgUtil::SceneView(_displaySettings.get()); sceneView->setDefaults(); sceneView->setSceneData(rootnode); diff --git a/src/osgPlugins/osg/AlphaFunc.cpp b/src/osgPlugins/osg/AlphaFunc.cpp index 05fd236e4..220d19d4f 100644 --- a/src/osgPlugins/osg/AlphaFunc.cpp +++ b/src/osgPlugins/osg/AlphaFunc.cpp @@ -16,7 +16,7 @@ const char* AlphaFunc_getFuncStr(AlphaFunc::ComparisonFunction func); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_AlphaFuncProxy ( - new osg::AlphaFunc, + osgNew osg::AlphaFunc, "AlphaFunc", "Object StateAttribute AlphaFunc", &AlphaFunc_readLocalData, diff --git a/src/osgPlugins/osg/Billboard.cpp b/src/osgPlugins/osg/Billboard.cpp index 1914aa2b1..875094efa 100644 --- a/src/osgPlugins/osg/Billboard.cpp +++ b/src/osgPlugins/osg/Billboard.cpp @@ -14,7 +14,7 @@ bool Billboard_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_BillboardProxy ( - new osg::Billboard, + osgNew osg::Billboard, "Billboard", "Object Node Geode Billboard", &Billboard_readLocalData, diff --git a/src/osgPlugins/osg/ClipPlane.cpp b/src/osgPlugins/osg/ClipPlane.cpp index 944877575..c45c43da7 100644 --- a/src/osgPlugins/osg/ClipPlane.cpp +++ b/src/osgPlugins/osg/ClipPlane.cpp @@ -18,7 +18,7 @@ bool ClipPlane_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_ClipPlaneProxy ( - new osg::ClipPlane, + osgNew osg::ClipPlane, "ClipPlane", "Object StateAttribute ClipPlane", &ClipPlane_readLocalData, diff --git a/src/osgPlugins/osg/ColorMask.cpp b/src/osgPlugins/osg/ColorMask.cpp index e1ae1fcbe..0ae194f21 100644 --- a/src/osgPlugins/osg/ColorMask.cpp +++ b/src/osgPlugins/osg/ColorMask.cpp @@ -16,7 +16,7 @@ const char* ColorMask_getModeStr(bool mode); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_ColorMaskProxy ( - new osg::ColorMask, + osgNew osg::ColorMask, "ColorMask", "Object StateAttribute ColorMask", &ColorMask_readLocalData, diff --git a/src/osgPlugins/osg/ColorMatrix.cpp b/src/osgPlugins/osg/ColorMatrix.cpp index eaf522012..104738263 100644 --- a/src/osgPlugins/osg/ColorMatrix.cpp +++ b/src/osgPlugins/osg/ColorMatrix.cpp @@ -14,7 +14,7 @@ bool ColorMatrix_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_ColorMatrixProxy ( - new osg::ColorMatrix, + osgNew osg::ColorMatrix, "ColorMatrix", "Object StateAttribute ColorMatrix", &ColorMatrix_readLocalData, diff --git a/src/osgPlugins/osg/CullFace.cpp b/src/osgPlugins/osg/CullFace.cpp index 60e79ae84..44926d8b3 100644 --- a/src/osgPlugins/osg/CullFace.cpp +++ b/src/osgPlugins/osg/CullFace.cpp @@ -14,7 +14,7 @@ bool CullFace_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_CullFaceFuncProxy ( - new osg::CullFace, + osgNew osg::CullFace, "CullFace", "Object StateAttribute CullFace", &CullFace_readLocalData, diff --git a/src/osgPlugins/osg/Depth.cpp b/src/osgPlugins/osg/Depth.cpp index 3fa441a63..d7d5352b7 100644 --- a/src/osgPlugins/osg/Depth.cpp +++ b/src/osgPlugins/osg/Depth.cpp @@ -18,7 +18,7 @@ const char* Depth_getFuncStr(Depth::Function func); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_DepthProxy ( - new osg::Depth, + osgNew osg::Depth, "Depth", "Object StateAttribute Depth", &Depth_readLocalData, diff --git a/src/osgPlugins/osg/Drawable.cpp b/src/osgPlugins/osg/Drawable.cpp index 947967d98..342cb5132 100644 --- a/src/osgPlugins/osg/Drawable.cpp +++ b/src/osgPlugins/osg/Drawable.cpp @@ -27,7 +27,7 @@ bool Drawable_readLocalData(Object& obj, Input& fr) Drawable& drawable = static_cast(obj); - static ref_ptr s_drawstate = new osg::StateSet; + static ref_ptr s_drawstate = osgNew osg::StateSet; if (StateSet* readState = static_cast(fr.readObjectOfType(*s_drawstate))) { drawable.setStateSet(readState); diff --git a/src/osgPlugins/osg/EarthSky.cpp b/src/osgPlugins/osg/EarthSky.cpp index d76b50f98..0a572a416 100644 --- a/src/osgPlugins/osg/EarthSky.cpp +++ b/src/osgPlugins/osg/EarthSky.cpp @@ -14,7 +14,7 @@ bool EarthSky_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_EarthSkyProxy ( - new osg::EarthSky, + osgNew osg::EarthSky, "EarthSky", "Object Node EarthSky Group", &EarthSky_readLocalData, diff --git a/src/osgPlugins/osg/Fog.cpp b/src/osgPlugins/osg/Fog.cpp index 703887894..60c5a140c 100644 --- a/src/osgPlugins/osg/Fog.cpp +++ b/src/osgPlugins/osg/Fog.cpp @@ -20,7 +20,7 @@ const char* Fog_getModeStr(Fog::Mode mode); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_FogProxy ( - new osg::Fog, + osgNew osg::Fog, "Fog", "Object StateAttribute Fog", &Fog_readLocalData, diff --git a/src/osgPlugins/osg/FrontFace.cpp b/src/osgPlugins/osg/FrontFace.cpp index f9c96fe26..debffb963 100644 --- a/src/osgPlugins/osg/FrontFace.cpp +++ b/src/osgPlugins/osg/FrontFace.cpp @@ -14,7 +14,7 @@ bool FrontFace_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_FrontFaceProxy ( - new osg::FrontFace, + osgNew osg::FrontFace, "FrontFace", "Object StateAttribute FrontFace", &FrontFace_readLocalData, diff --git a/src/osgPlugins/osg/GeoSet.cpp b/src/osgPlugins/osg/GeoSet.cpp index 066a16477..25da6f4df 100644 --- a/src/osgPlugins/osg/GeoSet.cpp +++ b/src/osgPlugins/osg/GeoSet.cpp @@ -27,7 +27,7 @@ int GeoSet_getInterleavedRowLength(GeoSet::InterleaveArrayType at); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_GeoSetFuncProxy ( - new osg::GeoSet, + osgNew osg::GeoSet, "GeoSet", "Object Drawable GeoSet", &GeoSet_readLocalData, @@ -38,7 +38,7 @@ RegisterDotOsgWrapperProxy g_GeoSetFuncProxy // register the old style 'Geoset' keyword read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_GeosetFuncProxy ( - new osg::GeoSet, + osgNew osg::GeoSet, "Geoset", "Object Drawable Geoset", &GeoSet_readLocalData, @@ -136,7 +136,7 @@ bool GeoSet_readLocalData(Object& obj, Input& fr) int capacity; if (!fr[1].getInt(capacity)) capacity=100; int size = 0; - int* list = new int [capacity]; + int* list = osgNew int [capacity]; while (!fr.eof() && fr[0].getNoNestedBrackets()>entry) { @@ -149,12 +149,12 @@ bool GeoSet_readLocalData(Object& obj, Input& fr) int oldCapacity = capacity; while(capacity<=size) capacity *= 2; int* oldList = list; - list = new int[capacity]; + list = osgNew int[capacity]; for(int i=0;ientry) { @@ -239,14 +239,14 @@ bool GeoSet_readLocalData(Object& obj, Input& fr) int oldCapacity = capacity; while(capacity<=size) capacity *= 2; Vec3* oldList = coordList; - coordList = new Vec3[capacity]; + coordList = osgNew Vec3[capacity]; for(int i=0;ientry) { @@ -309,14 +309,14 @@ bool GeoSet_readLocalData(Object& obj, Input& fr) int oldCapacity = capacity; while(capacity<=size) capacity *= 2; Vec3* oldList = normalList; - normalList = new Vec3[capacity]; + normalList = osgNew Vec3[capacity]; for(int i=0;ientry) { @@ -379,7 +379,7 @@ bool GeoSet_readLocalData(Object& obj, Input& fr) int oldCapacity = capacity; while(capacity<=size) capacity *= 2; Vec4* oldList = colorList; - colorList = new Vec4[capacity]; + colorList = osgNew Vec4[capacity]; for(int i=0;ientry) { @@ -451,13 +451,13 @@ bool GeoSet_readLocalData(Object& obj, Input& fr) int oldCapacity = capacity; while(capacity<=size) capacity *= 2; Vec2* oldList = textureList; - textureList = new Vec2[capacity]; + textureList = osgNew Vec2[capacity]; for(int i=0;ientry) { @@ -939,12 +939,12 @@ bool GeoSet_readIndexData(Input& fr, const char* IndexName, GeoSet::IndexPointer int oldCapacity = capacity; while(capacity<=size) capacity *= 2; osg::ushort* oldList = coordIndexList; - coordIndexList = new osg::ushort[capacity]; + coordIndexList = osgNew osg::ushort[capacity]; for(int i=0;ientry) { @@ -975,12 +975,12 @@ bool GeoSet_readIndexData(Input& fr, const char* IndexName, GeoSet::IndexPointer int oldCapacity = capacity; while(capacity<=size) capacity *= 2; osg::uint* oldList = coordIndexList; - coordIndexList = new osg::uint[capacity]; + coordIndexList = osgNew osg::uint[capacity]; for(int i=0;i(obj); - static ref_ptr s_light = new osg::Light; + static ref_ptr s_light = osgNew osg::Light; Light* light = static_cast(fr.readObjectOfType(*s_light)); if (light) diff --git a/src/osgPlugins/osg/LineStipple.cpp b/src/osgPlugins/osg/LineStipple.cpp index 1bed8d7d4..f03a3cfc5 100644 --- a/src/osgPlugins/osg/LineStipple.cpp +++ b/src/osgPlugins/osg/LineStipple.cpp @@ -15,7 +15,7 @@ bool LineStipple_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_LineStippleProxy ( - new osg::LineStipple, + osgNew osg::LineStipple, "LineStipple", "Object StateAttribute LineStipple", &LineStipple_readLocalData, diff --git a/src/osgPlugins/osg/LineWidth.cpp b/src/osgPlugins/osg/LineWidth.cpp index fabf69ff0..9689654b9 100644 --- a/src/osgPlugins/osg/LineWidth.cpp +++ b/src/osgPlugins/osg/LineWidth.cpp @@ -18,7 +18,7 @@ bool LineWidth_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_LineWidthProxy ( - new osg::LineWidth, + osgNew osg::LineWidth, "LineWidth", "Object StateAttribute LineWidth", &LineWidth_readLocalData, diff --git a/src/osgPlugins/osg/Material.cpp b/src/osgPlugins/osg/Material.cpp index 727d211ba..282f5d193 100644 --- a/src/osgPlugins/osg/Material.cpp +++ b/src/osgPlugins/osg/Material.cpp @@ -19,7 +19,7 @@ bool Material_matchFaceAndColor(Input& fr,const char* name,Material::Face& mf,Ve // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_MaterialProxy ( - new osg::Material, + osgNew osg::Material, "Material", "Object StateAttribute Material", &Material_readLocalData, diff --git a/src/osgPlugins/osg/Matrix.cpp b/src/osgPlugins/osg/Matrix.cpp index dae9807c8..9240231f5 100644 --- a/src/osgPlugins/osg/Matrix.cpp +++ b/src/osgPlugins/osg/Matrix.cpp @@ -14,7 +14,7 @@ bool Matrix_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_MatrixFuncProxy ( - new osg::Matrix, + osgNew osg::Matrix, "Matrix", "Object Matrix", &Matrix_readLocalData, diff --git a/src/osgPlugins/osg/Node.cpp b/src/osgPlugins/osg/Node.cpp index 9d13db2d0..0db91a658 100644 --- a/src/osgPlugins/osg/Node.cpp +++ b/src/osgPlugins/osg/Node.cpp @@ -14,7 +14,7 @@ bool Node_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_NodeProxy ( - new osg::Node, + osgNew osg::Node, "Node", "Object Node", &Node_readLocalData, @@ -87,7 +87,7 @@ bool Node_readLocalData(Object& obj, Input& fr) iteratorAdvanced = true; } - static ref_ptr s_drawstate = new osg::StateSet; + static ref_ptr s_drawstate = osgNew osg::StateSet; if (StateSet* readState = static_cast(fr.readObjectOfType(*s_drawstate))) { node.setStateSet(readState); diff --git a/src/osgPlugins/osg/Point.cpp b/src/osgPlugins/osg/Point.cpp index 6652eed3d..2c7b32bf9 100644 --- a/src/osgPlugins/osg/Point.cpp +++ b/src/osgPlugins/osg/Point.cpp @@ -18,7 +18,7 @@ bool Point_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_PointProxy ( - new osg::Point, + osgNew osg::Point, "Point", "Object StateAttribute Point", &Point_readLocalData, diff --git a/src/osgPlugins/osg/PolygonMode.cpp b/src/osgPlugins/osg/PolygonMode.cpp index 6f9ee9dc7..e3a969b79 100644 --- a/src/osgPlugins/osg/PolygonMode.cpp +++ b/src/osgPlugins/osg/PolygonMode.cpp @@ -14,7 +14,7 @@ bool PolygonMode_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_PolygonModeProxy ( - new osg::PolygonMode, + osgNew osg::PolygonMode, "PolygonMode", "Object StateAttribute PolygonMode", &PolygonMode_readLocalData, diff --git a/src/osgPlugins/osg/PolygonOffset.cpp b/src/osgPlugins/osg/PolygonOffset.cpp index 35dde873b..f8f3af5fb 100644 --- a/src/osgPlugins/osg/PolygonOffset.cpp +++ b/src/osgPlugins/osg/PolygonOffset.cpp @@ -14,7 +14,7 @@ bool PolygonOffset_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_PolygonOffsetProxy ( - new osg::PolygonOffset, + osgNew osg::PolygonOffset, "PolygonOffset", "Object StateAttribute PolygonOffset", &PolygonOffset_readLocalData, diff --git a/src/osgPlugins/osg/ReaderWriterOSG.cpp b/src/osgPlugins/osg/ReaderWriterOSG.cpp index 1ff40ea02..95047d03b 100644 --- a/src/osgPlugins/osg/ReaderWriterOSG.cpp +++ b/src/osgPlugins/osg/ReaderWriterOSG.cpp @@ -53,7 +53,7 @@ class OSGReaderWriter : public ReaderWriter } else { - Group* group = new Group; + Group* group = osgNew Group; group->setName("import group"); for(NodeList::iterator itr=nodeList.begin(); itr!=nodeList.end(); diff --git a/src/osgPlugins/osg/ShadeModel.cpp b/src/osgPlugins/osg/ShadeModel.cpp index 9b02b4da2..5a158adfa 100644 --- a/src/osgPlugins/osg/ShadeModel.cpp +++ b/src/osgPlugins/osg/ShadeModel.cpp @@ -14,7 +14,7 @@ bool ShadeModel_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_ShadeModelFuncProxy ( - new osg::ShadeModel, + osgNew osg::ShadeModel, "ShadeModel", "Object StateAttribute ShadeModel", &ShadeModel_readLocalData, diff --git a/src/osgPlugins/osg/StateSet.cpp b/src/osgPlugins/osg/StateSet.cpp index 2eca9b188..6fbc653cc 100644 --- a/src/osgPlugins/osg/StateSet.cpp +++ b/src/osgPlugins/osg/StateSet.cpp @@ -24,7 +24,7 @@ const char* StateSet_getRenderBinModeStr(StateSet::RenderBinMode mode); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_StateSetFuncProxy ( - new osg::StateSet, + osgNew osg::StateSet, "StateSet", "Object StateSet", &StateSet_readLocalData, @@ -35,7 +35,7 @@ RegisterDotOsgWrapperProxy g_StateSetFuncProxy // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_GeoStateFuncProxy ( - new osg::StateSet, + osgNew osg::StateSet, "GeoState", "Object GeoState", &GeoState_readLocalData, diff --git a/src/osgPlugins/osg/Stencil.cpp b/src/osgPlugins/osg/Stencil.cpp index b186aa22f..74e6463ff 100644 --- a/src/osgPlugins/osg/Stencil.cpp +++ b/src/osgPlugins/osg/Stencil.cpp @@ -20,7 +20,7 @@ const char* Stencil_getOperationStr(Stencil::Operation op); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_StencilProxy ( - new osg::Stencil, + osgNew osg::Stencil, "Stencil", "Object StateAttribute Stencil", &Stencil_readLocalData, diff --git a/src/osgPlugins/osg/Switch.cpp b/src/osgPlugins/osg/Switch.cpp index 4fe7ca25f..fd5558181 100644 --- a/src/osgPlugins/osg/Switch.cpp +++ b/src/osgPlugins/osg/Switch.cpp @@ -14,7 +14,7 @@ bool Switch_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_SwitchProxy ( - new osg::Switch, + osgNew osg::Switch, "Switch", "Object Node Group Switch", &Switch_readLocalData, diff --git a/src/osgPlugins/osg/TexEnv.cpp b/src/osgPlugins/osg/TexEnv.cpp index cdbd922b0..4eaed2cfc 100644 --- a/src/osgPlugins/osg/TexEnv.cpp +++ b/src/osgPlugins/osg/TexEnv.cpp @@ -16,7 +16,7 @@ const char* TexEnv_getModeStr(TexEnv::Mode mode); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_TexEnvProxy ( - new osg::TexEnv, + osgNew osg::TexEnv, "TexEnv", "Object StateAttribute TexEnv", &TexEnv_readLocalData, diff --git a/src/osgPlugins/osg/TexGen.cpp b/src/osgPlugins/osg/TexGen.cpp index e37b557e2..6526aa4e2 100644 --- a/src/osgPlugins/osg/TexGen.cpp +++ b/src/osgPlugins/osg/TexGen.cpp @@ -20,7 +20,7 @@ const char* TexGen_getModeStr(TexGen::Mode mode); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_TexGenProxy ( - new osg::TexGen, + osgNew osg::TexGen, "TexGen", "Object StateAttribute TexGen", &TexGen_readLocalData, diff --git a/src/osgPlugins/osg/TexMat.cpp b/src/osgPlugins/osg/TexMat.cpp index afebcc7a2..049482223 100644 --- a/src/osgPlugins/osg/TexMat.cpp +++ b/src/osgPlugins/osg/TexMat.cpp @@ -14,7 +14,7 @@ bool TexMat_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_TexMatProxy ( - new osg::TexMat, + osgNew osg::TexMat, "TexMat", "Object StateAttribute TexMat", &TexMat_readLocalData, diff --git a/src/osgPlugins/osg/Texture.cpp b/src/osgPlugins/osg/Texture.cpp index fa157e65e..d198e0fd8 100644 --- a/src/osgPlugins/osg/Texture.cpp +++ b/src/osgPlugins/osg/Texture.cpp @@ -25,7 +25,7 @@ const char* Texture_getSubloadModeStr(Texture::SubloadMode value); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_TextureProxy ( - new osg::Texture, + osgNew osg::Texture, "Texture", "Object StateAttribute Texture", &Texture_readLocalData, diff --git a/src/osgPlugins/osg/TextureCubeMap.cpp b/src/osgPlugins/osg/TextureCubeMap.cpp index c5e9e341c..158975345 100644 --- a/src/osgPlugins/osg/TextureCubeMap.cpp +++ b/src/osgPlugins/osg/TextureCubeMap.cpp @@ -25,7 +25,7 @@ const char* TextureCubeMap_getSubloadModeStr(TextureCubeMap::SubloadMode value); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_TextureCubeMapProxy ( - new osg::TextureCubeMap, + osgNew osg::TextureCubeMap, "TextureCubeMap", "Object StateAttribute TextureCubeMap Texture", &TextureCubeMap_readLocalData, diff --git a/src/osgPlugins/osg/Transform.cpp b/src/osgPlugins/osg/Transform.cpp index 749fe4935..51de17912 100644 --- a/src/osgPlugins/osg/Transform.cpp +++ b/src/osgPlugins/osg/Transform.cpp @@ -14,7 +14,7 @@ bool Transform_writeLocalData(const Object& obj, Output& fw); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_TransformProxy ( - new osg::Transform, + osgNew osg::Transform, "Transform", "Object Node Transform Group", &Transform_readLocalData, @@ -25,7 +25,7 @@ RegisterDotOsgWrapperProxy g_TransformProxy // register old style 'DCS' read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_DCSProxy ( - new osg::Transform, + osgNew osg::Transform, "DCS", "Object Node Group DCS", &Transform_readLocalData, @@ -62,7 +62,7 @@ bool Transform_readLocalData(Object& obj, Input& fr) transform.setMatrix(*tmpMatrix); - delete tmpMatrix; + osgDelete tmpMatrix; iteratorAdvanced = true; } diff --git a/src/osgPlugins/osg/Transparency.cpp b/src/osgPlugins/osg/Transparency.cpp index e45afa946..0e38ada32 100644 --- a/src/osgPlugins/osg/Transparency.cpp +++ b/src/osgPlugins/osg/Transparency.cpp @@ -17,7 +17,7 @@ const char* Transparency_getModeStr(int value); // register the read and write functions with the osgDB::Registry. RegisterDotOsgWrapperProxy g_TransparencyProxy ( - new osg::Transparency, + osgNew osg::Transparency, "Transparency", "Object StateAttribute Transparency", &Transparency_readLocalData, diff --git a/src/osgText/FTBitmapGlyph.cpp b/src/osgText/FTBitmapGlyph.cpp index ff942fe6e..d95bbd587 100644 --- a/src/osgText/FTBitmapGlyph.cpp +++ b/src/osgText/FTBitmapGlyph.cpp @@ -31,7 +31,7 @@ FTBitmapGlyph::FTBitmapGlyph( FT_Glyph glyph) destWidth = srcWidth; destHeight = srcHeight; - data = new unsigned char[srcPitch * destHeight]; + data = osgNew unsigned char[srcPitch * destHeight]; for(int y = 0; y < srcHeight; ++y) { diff --git a/src/osgText/FTFace.cpp b/src/osgText/FTFace.cpp index dae78f178..5a258707f 100644 --- a/src/osgText/FTFace.cpp +++ b/src/osgText/FTFace.cpp @@ -15,7 +15,7 @@ FTFace::FTFace() FTFace::~FTFace() { - delete charMap; + osgDelete charMap; charMap = 0; Close(); } @@ -23,18 +23,18 @@ FTFace::~FTFace() bool FTFace::Open( const char* filename) { - ftFace = new FT_Face; + ftFace = osgNew FT_Face; err = FT_New_Face( *FTLibrary::Instance().GetLibrary(), filename, 0, ftFace); if( err) { - delete ftFace; + osgDelete ftFace; ftFace = 0; return false; } else { - charMap = new FTCharmap( *ftFace); + charMap = osgNew FTCharmap( *ftFace); return true; } } @@ -45,7 +45,7 @@ void FTFace::Close() if( ftFace) { FT_Done_Face( *ftFace); - delete ftFace; + osgDelete ftFace; ftFace = 0; } } diff --git a/src/osgText/FTFont.cpp b/src/osgText/FTFont.cpp index 671b96f1f..816bfbb52 100644 --- a/src/osgText/FTFont.cpp +++ b/src/osgText/FTFont.cpp @@ -44,8 +44,8 @@ bool FTFont::Open( const char* fontname ) void FTFont::Close() { GlyphContextContainer::iterator itr; - for(itr=_contextGlyphList.begin();itr<_contextGlyphList.begin();itr++) - delete *itr; + for(itr=_contextGlyphList.begin();itr!=_contextGlyphList.end();itr++) + osgDelete *itr; _contextGlyphList.clear(); } @@ -61,9 +61,9 @@ bool FTFont::FaceSize( const unsigned int size, const unsigned int res , unsigne FTGlyphContainer*& glyphList=_contextGlyphList[renderContext]; if( glyphList) - delete glyphList; + osgDelete glyphList; - glyphList = new FTGlyphContainer( &face, numGlyphs); + glyphList = osgNew FTGlyphContainer( &face, numGlyphs); if( MakeGlyphList(renderContext)) { diff --git a/src/osgText/FTGL.h b/src/osgText/FTGL.h index 72cc9c299..ea174f10b 100644 --- a/src/osgText/FTGL.h +++ b/src/osgText/FTGL.h @@ -98,5 +98,7 @@ # define FTGL_EXPORT #endif +#include + #endif // __FTGL__ diff --git a/src/osgText/FTGLBitmapFont.cpp b/src/osgText/FTGLBitmapFont.cpp index 829180268..1f8d1a6eb 100644 --- a/src/osgText/FTGLBitmapFont.cpp +++ b/src/osgText/FTGLBitmapFont.cpp @@ -25,7 +25,7 @@ bool FTGLBitmapFont::MakeGlyphList(unsigned int renderContext) if( ftGlyph) { - FTBitmapGlyph* tempGlyph = new FTBitmapGlyph( *ftGlyph); + FTBitmapGlyph* tempGlyph = osgNew FTBitmapGlyph( *ftGlyph); glyphList->Add( tempGlyph); } else diff --git a/src/osgText/FTGLOutlineFont.cpp b/src/osgText/FTGLOutlineFont.cpp index be7b4c7de..e59c736f8 100644 --- a/src/osgText/FTGLOutlineFont.cpp +++ b/src/osgText/FTGLOutlineFont.cpp @@ -23,7 +23,7 @@ bool FTGLOutlineFont::MakeGlyphList( unsigned int renderContext) if( ftGlyph) { - FTOutlineGlyph* tempGlyph = new FTOutlineGlyph( *ftGlyph); + FTOutlineGlyph* tempGlyph = osgNew FTOutlineGlyph( *ftGlyph); glyphList->Add( tempGlyph); } else diff --git a/src/osgText/FTGLPixmapFont.cpp b/src/osgText/FTGLPixmapFont.cpp index 33b2e1d7d..0417b150a 100644 --- a/src/osgText/FTGLPixmapFont.cpp +++ b/src/osgText/FTGLPixmapFont.cpp @@ -25,7 +25,7 @@ bool FTGLPixmapFont::MakeGlyphList(unsigned int renderContext) if( ftGlyph) { - FTPixmapGlyph* tempGlyph = new FTPixmapGlyph( *ftGlyph); + FTPixmapGlyph* tempGlyph = osgNew FTPixmapGlyph( *ftGlyph); glyphList->Add( tempGlyph); } else diff --git a/src/osgText/FTGLPolygonFont.cpp b/src/osgText/FTGLPolygonFont.cpp index ccf5fdc04..826a6c793 100644 --- a/src/osgText/FTGLPolygonFont.cpp +++ b/src/osgText/FTGLPolygonFont.cpp @@ -24,7 +24,7 @@ bool FTGLPolygonFont::MakeGlyphList( unsigned int renderContext) if( ftGlyph) { - FTPolyGlyph* tempGlyph = new FTPolyGlyph( *ftGlyph); + FTPolyGlyph* tempGlyph = osgNew FTPolyGlyph( *ftGlyph); glyphList->Add( tempGlyph); } else diff --git a/src/osgText/FTGLTextureFont.cpp b/src/osgText/FTGLTextureFont.cpp index 9f8ae8319..0a43d6f91 100644 --- a/src/osgText/FTGLTextureFont.cpp +++ b/src/osgText/FTGLTextureFont.cpp @@ -50,7 +50,7 @@ FTGLTextureFont::~FTGLTextureFont() for(itr=glContextTextureID.begin();itr != glContextTextureID.end(); itr++) { glDeleteTextures( numTextures, (const GLuint*)*itr); - delete *itr; + osgDelete [] *itr; } } @@ -93,7 +93,7 @@ bool FTGLTextureFont::MakeGlyphList(unsigned int renderContext) glGenTextures( numTextures, (GLuint*)&glTextureID[0]); - textMem = new unsigned char[totalMem]; // GL_ALPHA texture; + textMem = osgNew unsigned char[totalMem]; // GL_ALPHA texture; memset( textMem, 0, totalMem); unsigned int glyphNum = 0; @@ -120,14 +120,14 @@ bool FTGLTextureFont::MakeGlyphList(unsigned int renderContext) glGenTextures( numTextures, (GLuint*)&glTextureID[0]); - textMem = new unsigned char[totalMem]; // GL_ALPHA texture; + textMem = osgNew unsigned char[totalMem]; // GL_ALPHA texture; memset( textMem, 0, totalMem); FillGlyphs( 0, glTextureID[0], textureWidth, textureHeight, textMem,renderContext); CreateTexture( glTextureID[0], textureWidth, textureHeight, textMem); } - delete [] textMem; + osgDelete [] textMem; return !err; } @@ -154,7 +154,7 @@ unsigned int FTGLTextureFont::FillGlyphs( unsigned int glyphStart, GLuint id, GL currTextU = (float)currentTextX / (float)width; - FTTextureGlyph* tempGlyph = new FTTextureGlyph( *ftGlyph, id, data, width, height, currTextU, currTextV); + FTTextureGlyph* tempGlyph = osgNew FTTextureGlyph( *ftGlyph, id, data, width, height, currTextU, currTextV); glyphList->Add( tempGlyph); currentTextX += glyphWidth; diff --git a/src/osgText/FTGlyphContainer.cpp b/src/osgText/FTGlyphContainer.cpp index e5f89d785..010d5db6b 100644 --- a/src/osgText/FTGlyphContainer.cpp +++ b/src/osgText/FTGlyphContainer.cpp @@ -19,7 +19,7 @@ FTGlyphContainer::~FTGlyphContainer() vector::iterator iter; for( iter = glyphs.begin(); iter != glyphs.end(); ++iter) { - delete *iter; + osgDelete *iter; } glyphs.clear(); diff --git a/src/osgText/FTLibrary.cpp b/src/osgText/FTLibrary.cpp index 72788c023..fab5ad689 100644 --- a/src/osgText/FTLibrary.cpp +++ b/src/osgText/FTLibrary.cpp @@ -14,7 +14,7 @@ FTLibrary::~FTLibrary() { FT_Done_FreeType( *lib); - delete lib; + osgDelete lib; lib= 0; } @@ -22,7 +22,7 @@ FTLibrary::~FTLibrary() // { // FTC_Manager_Done( manager ); // -// delete manager; +// osgDelete manager; // manager= 0; // } } @@ -41,12 +41,12 @@ bool FTLibrary::Init() if( lib != 0 ) return true; - lib = new FT_Library; + lib = osgNew FT_Library; err = FT_Init_FreeType( lib); if( err) { - delete lib; + osgDelete lib; lib = 0; return false; } @@ -55,7 +55,7 @@ bool FTLibrary::Init() // // if( FTC_Manager_New( lib, 0, 0, 0, my_face_requester, 0, manager ) // { -// delete manager; +// osgDelete manager; // manager= 0; // return false; // } diff --git a/src/osgText/FTOutlineGlyph.cpp b/src/osgText/FTOutlineGlyph.cpp index 81f912270..6d29a5433 100644 --- a/src/osgText/FTOutlineGlyph.cpp +++ b/src/osgText/FTOutlineGlyph.cpp @@ -18,11 +18,11 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph) return; } - vectoriser = new FTVectoriser( glyph); + vectoriser = osgNew FTVectoriser( glyph); vectoriser->Process(); numContours = vectoriser->contours(); - contourLength = new int[ numContours]; + contourLength = osgNew int[ numContours]; for( int cn = 0; cn < numContours; ++cn) { @@ -30,12 +30,12 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph) } numPoints = vectoriser->points(); - data = new double[ numPoints * 3]; + data = osgNew double[ numPoints * 3]; vectoriser->MakeOutline( data); advance = glyph->advance.x >> 16; - delete vectoriser; + osgDelete vectoriser; if ( ( numContours < 1) || ( numPoints < 3)) return; @@ -63,8 +63,8 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph) FTOutlineGlyph::~FTOutlineGlyph() { - delete [] data; - delete [] contourLength; + osgDelete [] data; + osgDelete [] contourLength; } diff --git a/src/osgText/FTPixmapGlyph.cpp b/src/osgText/FTPixmapGlyph.cpp index 8e8d2357d..108ff5499 100644 --- a/src/osgText/FTPixmapGlyph.cpp +++ b/src/osgText/FTPixmapGlyph.cpp @@ -36,7 +36,7 @@ FTPixmapGlyph::FTPixmapGlyph( FT_Glyph glyph) destWidth = srcWidth; destHeight = srcHeight; - data = new unsigned char[destWidth * destHeight * 4]; + data = osgNew unsigned char[destWidth * destHeight * 4]; // Get the current glColor. float ftglColour[4]; diff --git a/src/osgText/FTPolyGlyph.cpp b/src/osgText/FTPolyGlyph.cpp index 21b67f6ee..36b6452f3 100644 --- a/src/osgText/FTPolyGlyph.cpp +++ b/src/osgText/FTPolyGlyph.cpp @@ -35,8 +35,8 @@ void CALLBACK ftglEnd() void CALLBACK ftglCombine( GLdouble coords[3], void* vertex_data[4], GLfloat weight[4], void** outData) { - double* vertex = new double[3]; // FIXME MEM LEAK - + double* vertex = osgNew double[3]; // FIXME MEM LEAK + vertex[0] = coords[0]; vertex[1] = coords[1]; vertex[2] = coords[2]; @@ -57,11 +57,11 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph) if( ft_glyph_format_outline != glyph->format) { return;} - vectoriser = new FTVectoriser( glyph); + vectoriser = osgNew FTVectoriser( glyph); vectoriser->Process(); numContours = vectoriser->contours(); - contourLength = new int[ numContours]; + contourLength = osgNew int[ numContours]; for( int c = 0; c < numContours; ++c) { @@ -69,14 +69,14 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph) } numPoints = vectoriser->points(); - data = new double[ numPoints * 3]; + data = osgNew double[ numPoints * 3]; // FIXME MakeMesh vectoriser->MakeOutline( data); contourFlag = vectoriser->ContourFlag(); advance = glyph->advance.x >> 16; - delete vectoriser; + osgDelete vectoriser; if ( ( numContours < 1) || ( numPoints < 3)) return; @@ -135,8 +135,8 @@ void FTPolyGlyph::Tesselate() FTPolyGlyph::~FTPolyGlyph() { - delete [] data; - delete [] contourLength; + osgDelete [] data; + osgDelete [] contourLength; } diff --git a/src/osgText/FTVectoriser.cpp b/src/osgText/FTVectoriser.cpp index 9a6d69046..efb67a7fa 100644 --- a/src/osgText/FTVectoriser.cpp +++ b/src/osgText/FTVectoriser.cpp @@ -43,7 +43,7 @@ FTVectoriser::~FTVectoriser() { for( int c = 0; c < contours(); ++c) { - delete contourList[c]; + osgDelete contourList[c]; } contourList.clear(); @@ -70,7 +70,7 @@ bool FTVectoriser::Process() for( short c = 0; c < cont; ++c) { - contour = new FTContour; + contour = osgNew FTContour; contourFlag = ftOutline.flags; last = ftOutline.contours[c]; diff --git a/src/osgText/Font.cpp b/src/osgText/Font.cpp index d56995167..b78a1d4f1 100644 --- a/src/osgText/Font.cpp +++ b/src/osgText/Font.cpp @@ -157,7 +157,7 @@ void Font::clear() if(_font) { - delete _font; + osgDelete _font; _font=NULL; } @@ -221,7 +221,7 @@ RasterFont() FTFont* BitmapFont:: createFontObj(void) { - return (FTFont*)(new FTGLBitmapFont); + return (FTFont*)(osgNew FTGLBitmapFont); } // BitmapFont @@ -245,7 +245,7 @@ RasterFont(font) FTFont* PixmapFont:: createFontObj(void) { - return (FTFont*)(new FTGLPixmapFont); + return (FTFont*)(osgNew FTGLPixmapFont); } // PixmapFont @@ -285,7 +285,7 @@ RasterFont(font) FTFont* TextureFont:: createFontObj(void) { - return (FTFont*)(new FTGLTextureFont(_textureSize)); + return (FTFont*)(osgNew FTGLTextureFont(_textureSize)); } // TextureFont @@ -311,7 +311,7 @@ VectorFont(font) FTFont* OutlineFont:: createFontObj(void) { - return (FTFont*)(new FTGLOutlineFont); + return (FTFont*)(osgNew FTGLOutlineFont); } // _FTGLOutlineFont @@ -349,7 +349,7 @@ VectorFont(std::string(font)) FTFont* PolygonFont:: createFontObj(void) { - return (FTFont*)(new FTGLPolygonFont); + return (FTFont*)(osgNew FTGLPolygonFont); } diff --git a/src/osgText/Paragraph.cpp b/src/osgText/Paragraph.cpp index 05f7ede4d..1211abd88 100644 --- a/src/osgText/Paragraph.cpp +++ b/src/osgText/Paragraph.cpp @@ -117,7 +117,7 @@ void Paragraph::createDrawables() ++itr) { - osgText::Text* textDrawable = new osgText::Text(_font.get()); + osgText::Text* textDrawable = osgNew osgText::Text(_font.get()); textDrawable->setAlignment(_alignment); textDrawable->setPosition(pos); textDrawable->setText(*itr); diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index 5a96cbd2c..ad1c5ee46 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -299,7 +299,7 @@ void TriangleViewFrustumIntersect::intersect_triangle(const osg::Vec3& vert1, co //construct line segment of two triangle vertices and check if they intersect any clipping plane //but within correct clipping plane triangle - osg::ref_ptr s12 = new LineSegment(v1, v2); + osg::ref_ptr s12 = osgNew LineSegment(v1, v2); //left triangle @@ -395,7 +395,7 @@ CullVisitor::CullVisitor() // unless there is bug somewhere... _cullingModeStack.push_back(CullViewState::ENABLE_ALL_CULLING); - _tvs = new CullViewState; + _tvs = osgNew CullViewState; _tvs->_eyePoint.set(0.0f,0.0f,1.0f); _tvs->_centerPoint.set(0.0f,0.0f,0.0f); _tvs->_lookVector.set(0.0f,0.0f,-1.0f); @@ -416,7 +416,7 @@ CullVisitor::CullVisitor() _depthSortImpostorSprites = false; _impostorPixelErrorThreshold = 4.0f; _numFramesToKeepImpostorSprites = 10; - _impostorSpriteManager = new ImpostorSpriteManager; + _impostorSpriteManager = osgNew ImpostorSpriteManager; //SandB change _detailedCulling = false; @@ -491,7 +491,7 @@ void CullVisitor::pushCullViewState(Matrix* matrix) { if (matrix) { - osg::Matrix* inverse = new osg::Matrix; + osg::Matrix* inverse = osgNew osg::Matrix; inverse->invert(*matrix); pushCullViewState(matrix,inverse); } @@ -502,7 +502,7 @@ void CullVisitor::pushCullViewState(Matrix* matrix) void CullVisitor::pushCullViewState(Matrix* matrix,osg::Matrix* inverse) { - osg::ref_ptr nvs = new CullViewState; + osg::ref_ptr nvs = osgNew CullViewState; Matrix* inverse_world = NULL; @@ -1359,7 +1359,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node) // one for use. // create the render to texture stage. - ref_ptr rtts = new RenderToTextureStage; + ref_ptr rtts = osgNew RenderToTextureStage; // set up lighting. // currently ignore lights in the scene graph itself.. @@ -1376,7 +1376,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node) rtts->setRenderStageLighting(previous_stage->getRenderStageLighting()); - osg::Camera* camera = new osg::Camera(*_camera); + osg::Camera* camera = osgNew osg::Camera(*_camera); rtts->setCamera(camera); // record the render bin, to be restored after creation @@ -1391,7 +1391,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node) Vec3 rotate_from = bs.center()-eye_local; Vec3 rotate_to = getLookVectorLocal(); - osg::Matrix* rotate_matrix = new osg::Matrix( + osg::Matrix* rotate_matrix = osgNew osg::Matrix( osg::Matrix::translate(-eye_local)* osg::Matrix::rotate(rotate_from,rotate_to)* osg::Matrix::translate(eye_local)); @@ -1410,7 +1410,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node) _calculated_znear = FLT_MAX; _calculated_zfar = -FLT_MAX; - ref_ptr dummyState = new StateSet; + ref_ptr dummyState = osgNew StateSet; // dummyState->setMode(GL_BLEND,osg::StateAttribute::OVERRIDE_OFF); @@ -1647,7 +1647,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node) int center_x = _viewport->x()+_viewport->width()/2; int center_y = _viewport->y()+_viewport->height()/2; - Viewport* viewport = new Viewport; + Viewport* viewport = osgNew Viewport; viewport->setViewport(center_x-new_s/2,center_y-new_t/2,new_s,new_t); rtts->setViewport(viewport); diff --git a/src/osgUtil/DisplayRequirementsVisitor.cpp b/src/osgUtil/DisplayRequirementsVisitor.cpp index 42a253bdc..d95efff8a 100644 --- a/src/osgUtil/DisplayRequirementsVisitor.cpp +++ b/src/osgUtil/DisplayRequirementsVisitor.cpp @@ -20,7 +20,7 @@ DisplayRequirementsVisitor::DisplayRequirementsVisitor() void DisplayRequirementsVisitor::applyStateSet(StateSet& stateset) { - if (!_ds) _ds = new osg::DisplaySettings; + if (!_ds) _ds = osgNew osg::DisplaySettings; unsigned int min = 0; // assume stencil not needed by this stateset. @@ -63,7 +63,7 @@ void DisplayRequirementsVisitor::apply(Geode& geode) void DisplayRequirementsVisitor::apply(Impostor& impostor) { - if (!_ds) _ds = new osg::DisplaySettings; + if (!_ds) _ds = osgNew osg::DisplaySettings; unsigned int min = 1; // number alpha bits we need at least. if (min>_ds->getMinimumNumAlphaBits()) diff --git a/src/osgUtil/DriveManipulator.cpp b/src/osgUtil/DriveManipulator.cpp index 1c15f4b62..002d6031a 100644 --- a/src/osgUtil/DriveManipulator.cpp +++ b/src/osgUtil/DriveManipulator.cpp @@ -60,7 +60,7 @@ void DriveManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us) bool cameraSet = false; - osg::ref_ptr segDown = new osg::LineSegment; + osg::ref_ptr segDown = osgNew osg::LineSegment; segDown->set(ep,bp); iv.addLineSegment(segDown.get()); @@ -99,7 +99,7 @@ void DriveManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us) bp = ep; bp.z() += _modelScale; - osg::ref_ptr segUp = new osg::LineSegment; + osg::ref_ptr segUp = osgNew osg::LineSegment; segUp->set(ep,bp); iv.addLineSegment(segUp.get()); @@ -175,7 +175,7 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us) bool cameraSet = false; - osg::ref_ptr segDown = new osg::LineSegment; + osg::ref_ptr segDown = osgNew osg::LineSegment; segDown->set(ep,bp); iv.addLineSegment(segDown.get()); @@ -214,7 +214,7 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us) bp = ep; bp.z() += _modelScale; - osg::ref_ptr segUp = new osg::LineSegment; + osg::ref_ptr segUp = osgNew osg::LineSegment; segUp->set(ep,bp); iv.addLineSegment(segUp.get()); @@ -452,7 +452,7 @@ bool DriveManipulator::calcMovement() // check to see if any obstruction in front. IntersectVisitor iv; - osg::ref_ptr segForward = new osg::LineSegment; + osg::ref_ptr segForward = osgNew osg::LineSegment; segForward->set(ep,ep+lv*(signedBuffer+distanceToMove)); iv.addLineSegment(segForward.get()); @@ -477,7 +477,7 @@ bool DriveManipulator::calcMovement() iv.reset(); - osg::ref_ptr segNormal = new osg::LineSegment; + osg::ref_ptr segNormal = osgNew osg::LineSegment; segNormal->set(fp,lfp); iv.addLineSegment(segNormal.get()); @@ -515,7 +515,7 @@ bool DriveManipulator::calcMovement() iv.reset(); - osg::ref_ptr segFall = new osg::LineSegment; + osg::ref_ptr segFall = osgNew osg::LineSegment; segFall->set(lfp,dp); iv.addLineSegment(segFall.get()); diff --git a/src/osgUtil/InsertImpostorsVisitor.cpp b/src/osgUtil/InsertImpostorsVisitor.cpp index 30914050c..20c028701 100644 --- a/src/osgUtil/InsertImpostorsVisitor.cpp +++ b/src/osgUtil/InsertImpostorsVisitor.cpp @@ -92,7 +92,7 @@ void InsertImpostorsVisitor::insertImpostors() // to an impostor. Node::ParentList parentList = group->getParents(); - Impostor* impostor = new Impostor; + Impostor* impostor = osgNew Impostor; // standard LOD settings impostor->addChild(group); @@ -141,7 +141,7 @@ void InsertImpostorsVisitor::insertImpostors() // to an impostor. Node::ParentList parentList = lod->getParents(); - osg::Impostor* impostor = new Impostor; + osg::Impostor* impostor = osgNew Impostor; // standard LOD settings for(int ci=0;cigetNumChildren();++ci) diff --git a/src/osgUtil/IntersectVisitor.cpp b/src/osgUtil/IntersectVisitor.cpp index 44b50792c..2c7d90e82 100644 --- a/src/osgUtil/IntersectVisitor.cpp +++ b/src/osgUtil/IntersectVisitor.cpp @@ -154,7 +154,7 @@ void IntersectVisitor::reset() _intersectStateStack.clear(); // create a empty IntersectState on the the intersectStateStack. - IntersectState* nis = new IntersectState; + IntersectState* nis = osgNew IntersectState; _intersectStateStack.push_back(nis); @@ -193,7 +193,7 @@ void IntersectVisitor::addLineSegment(LineSegment* seg) // create a new segment transformed to local coordintes. IntersectState* cis = _intersectStateStack.back().get(); - LineSegment* ns = new LineSegment; + LineSegment* ns = osgNew LineSegment; if (cis->_inverse.valid()) ns->mult(*seg,*(cis->_inverse)); else *ns = *seg; @@ -205,21 +205,21 @@ void IntersectVisitor::addLineSegment(LineSegment* seg) void IntersectVisitor::pushMatrix(const Matrix& matrix) { - IntersectState* nis = new IntersectState; + IntersectState* nis = osgNew IntersectState; IntersectState* cis = _intersectStateStack.back().get(); if (cis->_matrix.valid()) { - nis->_matrix = new Matrix; + nis->_matrix = osgNew Matrix; nis->_matrix->mult(matrix,*(cis->_matrix)); } else { - nis->_matrix = new Matrix(matrix); + nis->_matrix = osgNew Matrix(matrix); } - Matrix* inverse_world = new Matrix; + Matrix* inverse_world = osgNew Matrix; inverse_world->invert(*(nis->_matrix)); nis->_inverse = inverse_world; @@ -231,7 +231,7 @@ void IntersectVisitor::pushMatrix(const Matrix& matrix) { if ((segMaskIn & mask)) { - LineSegment* seg = new LineSegment; + LineSegment* seg = osgNew LineSegment; seg->mult(*(sitr->first),*inverse_world); nis->addLineSegmentPair(sitr->first.get(),seg); } @@ -540,7 +540,7 @@ void IntersectVisitor::apply(Transform& node) { if (!enterNode(node)) return; - osg::ref_ptr matrix = new Matrix; + osg::ref_ptr matrix = osgNew Matrix; node.getLocalToWorldMatrix(*matrix,this); pushMatrix(*matrix); diff --git a/src/osgUtil/NvTriStripObjects.cpp b/src/osgUtil/NvTriStripObjects.cpp index 92c3c40da..c244d00fd 100644 --- a/src/osgUtil/NvTriStripObjects.cpp +++ b/src/osgUtil/NvTriStripObjects.cpp @@ -21,7 +21,7 @@ VertexCache::VertexCache(int size) { numEntries = size; - entries = new int[numEntries]; + entries = osgNew int[numEntries]; for(int i = 0; i < numEntries; i++) entries[i] = -1; @@ -169,7 +169,7 @@ void NvStripifier::BuildStripifyInfo(NvFaceInfoVec &faceInfos, NvEdgeInfoVec &ed // create the face info and add it to the list of faces, but only if this exact face doesn't already // exist in the list - NvFaceInfo *faceInfo = new NvFaceInfo(v0, v1, v2); + NvFaceInfo *faceInfo = osgNew NvFaceInfo(v0, v1, v2); if(!AlreadyExists(faceInfo, faceInfos)) { faceInfos.push_back(faceInfo); @@ -180,7 +180,7 @@ void NvStripifier::BuildStripifyInfo(NvFaceInfoVec &faceInfos, NvEdgeInfoVec &ed { // create the info - edgeInfo01 = new NvEdgeInfo(v0, v1); + edgeInfo01 = osgNew NvEdgeInfo(v0, v1); // update the linked list on both edgeInfo01->m_nextV0 = edgeInfos[v0]; @@ -205,7 +205,7 @@ void NvStripifier::BuildStripifyInfo(NvFaceInfoVec &faceInfos, NvEdgeInfoVec &ed { // create the info - edgeInfo12 = new NvEdgeInfo(v1, v2); + edgeInfo12 = osgNew NvEdgeInfo(v1, v2); // update the linked list on both edgeInfo12->m_nextV0 = edgeInfos[v1]; @@ -230,7 +230,7 @@ void NvStripifier::BuildStripifyInfo(NvFaceInfoVec &faceInfos, NvEdgeInfoVec &ed { // create the info - edgeInfo20 = new NvEdgeInfo(v2, v0); + edgeInfo20 = osgNew NvEdgeInfo(v2, v0); // update the linked list on both edgeInfo20->m_nextV0 = edgeInfos[v2]; @@ -789,7 +789,7 @@ void NvStripifier::RemoveSmallStrips(NvStripInfoVec& allStrips, NvStripInfoVec& tempFaceList.push_back(allStrips[i]->m_faces[j]); //and free memory - delete allStrips[i]; + osgDelete allStrips[i]; } else { @@ -797,10 +797,10 @@ void NvStripifier::RemoveSmallStrips(NvStripInfoVec& allStrips, NvStripInfoVec& } } - bool *bVisitedList = new bool[tempFaceList.size()]; + bool *bVisitedList = osgNew bool[tempFaceList.size()]; memset(bVisitedList, 0, tempFaceList.size()*sizeof(bool)); - VertexCache* vcache = new VertexCache(cacheSize); + VertexCache* vcache = osgNew VertexCache(cacheSize); int bestNumHits = -1; int numHits; @@ -831,7 +831,7 @@ void NvStripifier::RemoveSmallStrips(NvStripInfoVec& allStrips, NvStripInfoVec& faceList.push_back(tempFaceList[bestIndex]); } - delete vcache; + osgDelete vcache; delete[] bVisitedList; } @@ -875,7 +875,7 @@ void NvStripifier::Stripify(const WordVec &in_indices, const int in_numVertices, int i; for(i = 0; i < (int)allStrips.size(); i++) { - delete allStrips[i]; + osgDelete allStrips[i]; } for (i = 0; i < (int)allEdgeInfos.size(); i++) @@ -921,7 +921,7 @@ NvEdgeInfoVec& edgeInfos, NvFaceInfoVec& outFaceList) int j; for(j = 0; j < numTimes; j++) { - currentStrip = new NvStripInfo(startInfo, 0, -1); + currentStrip = osgNew NvStripInfo(startInfo, 0, -1); for(int faceCtr = j*threshold; faceCtr < threshold+(j*threshold); faceCtr++) { @@ -935,7 +935,7 @@ NvEdgeInfoVec& edgeInfos, NvFaceInfoVec& outFaceList) if(numLeftover != 0) { - currentStrip = new NvStripInfo(startInfo, 0, -1); + currentStrip = osgNew NvStripInfo(startInfo, 0, -1); for(int k = 0; k < numLeftover; k++) { @@ -948,8 +948,8 @@ NvEdgeInfoVec& edgeInfos, NvFaceInfoVec& outFaceList) else { //we're not just doing a tempStrips.push_back(allBigStrips[i]) because - // this way we can delete allBigStrips later to free the memory - currentStrip = new NvStripInfo(startInfo, 0, -1); + // this way we can osgDelete allBigStrips later to free the memory + currentStrip = osgNew NvStripInfo(startInfo, 0, -1); for(unsigned int j = 0; j < allStrips[i]->m_faces.size(); j++) currentStrip->m_faces.push_back(allStrips[i]->m_faces[j]); @@ -966,7 +966,7 @@ NvEdgeInfoVec& edgeInfos, NvFaceInfoVec& outFaceList) if(tempStrips2.size() != 0) { //Optimize for the vertex cache - VertexCache* vcache = new VertexCache(cacheSize); + VertexCache* vcache = osgNew VertexCache(cacheSize); float bestNumHits = -1.0f; float numHits; @@ -1025,7 +1025,7 @@ NvEdgeInfoVec& edgeInfos, NvFaceInfoVec& outFaceList) outStrips.push_back(tempStrips2[bestIndex]); } - delete vcache; + osgDelete vcache; } } @@ -1195,7 +1195,7 @@ int numSamples) // // PHASE 1: Set up numSamples * numEdges experiments // - NvStripInfoVec *experiments = new NvStripInfoVec [numSamples * 6]; + NvStripInfoVec *experiments = osgNew NvStripInfoVec [numSamples * 6]; int experimentIndex = 0; std::set resetPoints; int i; @@ -1226,32 +1226,32 @@ int numSamples) // build the strip off of this face's 0-1 edge NvEdgeInfo *edge01 = FindEdgeInfo(allEdgeInfos, nextFace->m_v0, nextFace->m_v1); - NvStripInfo *strip01 = new NvStripInfo(NvStripStartInfo(nextFace, edge01, true), stripId++, experimentId++); + NvStripInfo *strip01 = osgNew NvStripInfo(NvStripStartInfo(nextFace, edge01, true), stripId++, experimentId++); experiments[experimentIndex++].push_back(strip01); // build the strip off of this face's 1-0 edge NvEdgeInfo *edge10 = FindEdgeInfo(allEdgeInfos, nextFace->m_v0, nextFace->m_v1); - NvStripInfo *strip10 = new NvStripInfo(NvStripStartInfo(nextFace, edge10, false), stripId++, experimentId++); + NvStripInfo *strip10 = osgNew NvStripInfo(NvStripStartInfo(nextFace, edge10, false), stripId++, experimentId++); experiments[experimentIndex++].push_back(strip10); // build the strip off of this face's 1-2 edge NvEdgeInfo *edge12 = FindEdgeInfo(allEdgeInfos, nextFace->m_v1, nextFace->m_v2); - NvStripInfo *strip12 = new NvStripInfo(NvStripStartInfo(nextFace, edge12, true), stripId++, experimentId++); + NvStripInfo *strip12 = osgNew NvStripInfo(NvStripStartInfo(nextFace, edge12, true), stripId++, experimentId++); experiments[experimentIndex++].push_back(strip12); // build the strip off of this face's 2-1 edge NvEdgeInfo *edge21 = FindEdgeInfo(allEdgeInfos, nextFace->m_v1, nextFace->m_v2); - NvStripInfo *strip21 = new NvStripInfo(NvStripStartInfo(nextFace, edge21, false), stripId++, experimentId++); + NvStripInfo *strip21 = osgNew NvStripInfo(NvStripStartInfo(nextFace, edge21, false), stripId++, experimentId++); experiments[experimentIndex++].push_back(strip21); // build the strip off of this face's 2-0 edge NvEdgeInfo *edge20 = FindEdgeInfo(allEdgeInfos, nextFace->m_v2, nextFace->m_v0); - NvStripInfo *strip20 = new NvStripInfo(NvStripStartInfo(nextFace, edge20, true), stripId++, experimentId++); + NvStripInfo *strip20 = osgNew NvStripInfo(NvStripStartInfo(nextFace, edge20, true), stripId++, experimentId++); experiments[experimentIndex++].push_back(strip20); // build the strip off of this face's 0-2 edge NvEdgeInfo *edge02 = FindEdgeInfo(allEdgeInfos, nextFace->m_v2, nextFace->m_v0); - NvStripInfo *strip02 = new NvStripInfo(NvStripStartInfo(nextFace, edge02, false), stripId++, experimentId++); + NvStripInfo *strip02 = osgNew NvStripInfo(NvStripStartInfo(nextFace, edge02, false), stripId++, experimentId++); experiments[experimentIndex++].push_back(strip02); } @@ -1276,7 +1276,7 @@ int numSamples) { // create the new strip info - stripIter = new NvStripInfo(startInfo, stripId++, experimentId); + stripIter = osgNew NvStripInfo(startInfo, stripId++, experimentId); // build the next strip stripIter->Build(allEdgeInfos, allFaceInfos); @@ -1319,13 +1319,13 @@ int numSamples) int numStrips = experiments[i].size(); for (int j = 0; j < numStrips; j++) { - delete experiments[i][j]; + osgDelete experiments[i][j]; } } } - // delete the array that we used for all experiments - delete [] experiments; + // osgDelete the array that we used for all experiments + osgDelete [] experiments; } } @@ -1525,7 +1525,7 @@ MyVertexVec& optimizedVerts) //caches oldIndex --> newIndex conversion int *indexCache; - indexCache = new int[vertices.size()]; + indexCache = osgNew int[vertices.size()]; memset(indexCache, -1, sizeof(int)*vertices.size()); diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index 664e1d482..31046395e 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -335,7 +335,7 @@ void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Transform& transform) } else { - osg::ref_ptr matrix = new osg::Matrix; + osg::ref_ptr matrix = osgNew osg::Matrix; transform.getLocalToWorldMatrix(*matrix,this); if (!_matrixStack.empty()) @@ -526,7 +526,7 @@ void Optimizer::FlattenStaticTransformsVisitor::removeTransforms() osg::ref_ptr transform = titr->first; - osg::ref_ptr group = new osg::Group; + osg::ref_ptr group = osgNew osg::Group; int i; for(i=0;igetNumChildren();++i) @@ -695,7 +695,7 @@ void Optimizer::CombineLODsVisitor::combineLODs() } // create new LOD containing all other LOD's children. - osg::LOD* newLOD = new osg::LOD; + osg::LOD* newLOD = osgNew osg::LOD; newLOD->setName("newLOD"); newLOD->setCenter(bb.center()); diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index 5e2ca20a6..e22a7bdcd 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -31,7 +31,7 @@ SceneView::SceneView(DisplaySettings* ds) _prioritizeTextures = false; - _viewport = new Viewport; + _viewport = osgNew Viewport; _initCalled = false; @@ -49,21 +49,21 @@ SceneView::~SceneView() void SceneView::setDefaults() { - _globalState = new osg::StateSet; + _globalState = osgNew osg::StateSet; _lightingMode=HEADLIGHT; - _light = new osg::Light; + _light = osgNew osg::Light; _light->setLightNum(0); _light->setAmbient(Vec4(0.00f,0.0f,0.00f,1.0f)); _light->setDiffuse(Vec4(0.8f,0.8f,0.8f,1.0f)); _light->setSpecular(Vec4(1.0f,1.0f,1.0f,1.0f)); - _state = new State; + _state = osgNew State; - _camera = new Camera(_displaySettings.get()); + _camera = osgNew Camera(_displaySettings.get()); - _rendergraph = new RenderGraph; - _renderStage = new RenderStage; + _rendergraph = osgNew RenderGraph; + _renderStage = osgNew RenderStage; //#ifndef __sgi @@ -71,15 +71,15 @@ void SceneView::setDefaults() // lighting state with the display list, and the display list visitor doesn't currently apply // state before creating display lists. So will disable the init visitor default, this won't // affect functionality since the display lists will be created as and when needed. - DisplayListVisitor* dlv = new DisplayListVisitor(); + DisplayListVisitor* dlv = osgNew DisplayListVisitor(); dlv->setState(_state.get()); dlv->setNodeMaskOverride(0xffffffff); _initVisitor = dlv; //#endif - _appVisitor = new AppVisitor; + _appVisitor = osgNew AppVisitor; - _cullVisitor = new CullVisitor; + _cullVisitor = osgNew CullVisitor; _cullVisitor->setRenderGraph(_rendergraph.get()); _cullVisitor->setRenderStage(_renderStage.get()); @@ -94,16 +94,16 @@ void SceneView::setDefaults() _globalState->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON); // set up an alphafunc by default to speed up blending operations. - osg::AlphaFunc* alphafunc = new osg::AlphaFunc; + osg::AlphaFunc* alphafunc = osgNew osg::AlphaFunc; alphafunc->setFunction(osg::AlphaFunc::GREATER,0.0f); _globalState->setAttributeAndModes(alphafunc, osg::StateAttribute::ON); // set up an alphafunc by default to speed up blending operations. - osg::TexEnv* texenv = new osg::TexEnv; + osg::TexEnv* texenv = osgNew osg::TexEnv; texenv->setMode(osg::TexEnv::MODULATE); _globalState->setAttributeAndModes(texenv, osg::StateAttribute::ON); - osg::LightModel* lightmodel = new osg::LightModel; + osg::LightModel* lightmodel = osgNew osg::LightModel; lightmodel->setAmbientIntensity(osg::Vec4(0.0f,0.0f,0.0f,1.0f)); _globalState->setAttributeAndModes(lightmodel, osg::StateAttribute::ON); @@ -163,8 +163,8 @@ void SceneView::cull() _camera->setScreenDistance(_displaySettings->getScreenDistance()); - _cameraLeft = new osg::Camera(*_camera); - _cameraRight = new osg::Camera(*_camera); + _cameraLeft = osgNew osg::Camera(*_camera); + _cameraRight = osgNew osg::Camera(*_camera); float iod = _displaySettings->getEyeSeperation(); @@ -216,11 +216,11 @@ void SceneView::cullStage(osg::Camera* camera, osgUtil::CullVisitor* cullVisitor } // get the camera's modelview - osg::Matrix* modelview = new osg::Matrix(camera->getModelViewMatrix()); + osg::Matrix* modelview = osgNew osg::Matrix(camera->getModelViewMatrix()); // take a copy of camera, and init it home - osg::Camera* local_camera = new Camera(*camera); + osg::Camera* local_camera = osgNew Camera(*camera); local_camera->home(); local_camera->attachTransform(osg::Camera::NO_ATTACHED_TRANSFORM); @@ -364,8 +364,8 @@ void SceneView::draw() break; case(osg::DisplaySettings::ANAGLYPHIC): { - osg::ref_ptr red = new osg::ColorMask; - osg::ref_ptr green = new osg::ColorMask; + osg::ref_ptr red = osgNew osg::ColorMask; + osg::ref_ptr green = osgNew osg::ColorMask; red->setMask(true,false,false,true); green->setMask(false,true,true,true); @@ -408,7 +408,7 @@ void SceneView::drawStage(osgUtil::RenderStage* renderStage) osg::notify(osg::WARN) << " creating a state automatically."<< std::endl; // note the constructor for osg::State will set ContextID to 0. - _state = new osg::State; + _state = osgNew osg::State; } // we in theory should be able to _state->reset(); diff --git a/src/osgUtil/SceneViewManipulator.cpp b/src/osgUtil/SceneViewManipulator.cpp index 602fbdc26..f77011025 100644 --- a/src/osgUtil/SceneViewManipulator.cpp +++ b/src/osgUtil/SceneViewManipulator.cpp @@ -4,8 +4,8 @@ using namespace osgUtil; SceneViewManipulator::SceneViewManipulator(): - _cm(new TrackballManipulator), - _gm(new StateSetManipulator) + _cm(osgNew TrackballManipulator), + _gm(osgNew StateSetManipulator) { } diff --git a/src/osgUtil/SmoothingVisitor.cpp b/src/osgUtil/SmoothingVisitor.cpp index 284836e33..41791a958 100644 --- a/src/osgUtil/SmoothingVisitor.cpp +++ b/src/osgUtil/SmoothingVisitor.cpp @@ -108,7 +108,7 @@ void SmoothingVisitor::smooth(osg::GeoSet& gset) int ncoords = gset.getNumCoords(); osg::Vec3 *coords = gset.getCoords(); osg::GeoSet::IndexPointer cindex = gset.getCoordIndices(); - osg::Vec3 *norms = new osg::Vec3[ncoords]; + osg::Vec3 *norms = osgNew osg::Vec3[ncoords]; int j; for(j = 0; j < ncoords; j++ ) diff --git a/src/osgUtil/TriStripVisitor.cpp b/src/osgUtil/TriStripVisitor.cpp index a1130e856..b3c7ed167 100644 --- a/src/osgUtil/TriStripVisitor.cpp +++ b/src/osgUtil/TriStripVisitor.cpp @@ -48,7 +48,7 @@ void createStrips( assert(nStripCount > 0); noPrims = strips.size()+leftoverFaces.size(); - *lens = new int [noPrims]; + *lens = osgNew int [noPrims]; int* lensPtr = *lens; @@ -61,7 +61,7 @@ void createStrips( noIndices += leftoverFaces.size()*3; - *osg_indices = new osg::ushort[noIndices]; + *osg_indices = osgNew osg::ushort[noIndices]; osg::ushort *osg_indicesPtr = *osg_indices; for (i = 0; i < strips.size(); i++)