Added support for osg::MemoryManager which is based upon Paul Nettle's

memory manager published at flipcode.com.  This can be turned on
with the OSG_USE_MEMORY_MANGER option which then uses custom global
new and delete operators as well as provide osgNew and osgDelete macro's
which add ability to log line and file from which calls are made.

Updated osg,osgUtil,osgDB,osgText and osgPlugins/osg to use osgNew/osgDelete,
and fixed memory leaks highlighted by the new memory manager.
This commit is contained in:
Robert Osfield 2002-03-26 23:52:52 +00:00
parent 72ff3186df
commit 84d2d01163
107 changed files with 469 additions and 435 deletions

View File

@ -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}

View File

@ -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}

View File

@ -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}

View File

@ -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

View File

@ -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

View File

@ -33,4 +33,6 @@
#endif
#endif
#include <osg/MemoryManager>
#endif

View File

@ -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<const GeoSet*>(obj)!=NULL; }

View File

@ -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<const Image*>(obj)!=0; }
virtual const char* className() const { return "Image"; }

View File

@ -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<const ImpostorSprite*>(obj)!=NULL; }
virtual const char* className() const { return "ImpostorSprite"; }

View File

@ -5,7 +5,6 @@
#ifndef OSG_LIGHTSOURCE
#define OSG_LIGHTSOURCE 1
#include <osg/MemoryAdapter>
#include <osg/NodeVisitor>
#include <osg/Light>

View File

@ -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<const Matrix*>(obj)!=NULL; } \
virtual const char* className() const { return "Matrix"; }

View File

@ -14,6 +14,9 @@
#ifndef _H_MMGR
#define _H_MMGR
#include <stdlib.h>
#include <new>
// ---------------------------------------------------------------------------------------------------------------------------------
// 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." :)

View File

@ -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<const name *>(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<const Node*>(obj)!=NULL; }

View File

@ -9,6 +9,7 @@
#include <iostream>
#include <fstream>
#include <memory>
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<std::ofstream> g_NotifyNulStream;
/** global notify nul stream. added for Mac OSX */
SG_EXPORT extern bool g_NotifyInit;

View File

@ -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<const T *>(obj)!=NULL; } \
virtual const char* className() const { return #T; }

View File

@ -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<const name *>(obj)!=NULL; } \
virtual const char* className() const { return #name; } \
virtual const Type getType() const { return type; }

View File

@ -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<const StateSet*>(obj)!=NULL; }
virtual const char* className() const { return "StateSet"; }

View File

@ -170,7 +170,7 @@ class mem_ptr
// return s_newMemoryAdapter.get();
// }
//
// T* allocate(int no) { cout<<"Allocating Memory"<<endl;return new T[no]; }
// T* allocate(int no) { cout<<"Allocating Memory"<<endl;return osgNew T[no]; }
//
// virtual void ref_data(void* userData)
// {

View File

@ -23,4 +23,6 @@
# define OSGDB_EXPORT
#endif
#include <osg/MemoryManager>
#endif

View File

@ -5,10 +5,10 @@
#ifndef OSG_GLUT
#define OSG_GLUT 1
#ifdef __APPLE__
#include </System/Library/Frameworks/GLUT.Framework/Versions/A/Headers/glut.h>
#if defined(__DARWIN_OSX__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#include <GL/glut.h>
#endif
#endif // __osgGLUT_h

View File

@ -23,6 +23,8 @@
// nothing needed
#elif defined(__sun)
# include <sys/sockio.h>
#elif defined (__DARWIN_OSX__) // added
# include <sys/sockio.h> // added
#else
# error Teach me how to build on this system
#endif

View File

@ -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<osg::Camera> _hudCam;
osg::ref_ptr<osg::Camera> _hudCam;
osg::ref_ptr<osgUtil::SceneView> _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();

View File

@ -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"<<std::endl;
@ -452,7 +452,7 @@ void Camera::attachTransform(const TransformMode mode, Matrix* matrix)
if (_modelToEyeTransform.valid())
{
_attachedTransformMode = mode;
if (!_eyeToModelTransform.valid()) _eyeToModelTransform = new Matrix;
if (!_eyeToModelTransform.valid()) _eyeToModelTransform = osgNew Matrix;
if (!_eyeToModelTransform->invert(*_modelToEyeTransform))
{
notify(WARN)<<"Warning: Camera::attachTransform() failed to invert _modelToEyeTransform"<<std::endl;
@ -651,7 +651,7 @@ void Camera::calculateMatricesAndClippingVolume() const
float ty = -(top+bottom)/(top-bottom);
float tz = -(_zFar+_zNear)/(_zFar-_zNear);
_projectionMatrix = new Matrix(
_projectionMatrix = osgNew Matrix(
A, 0.0f, 0.0f, 0.0f,
0.0f, B, 0.0f, 0.0f,
0.0f, 0.0f, C, 0.0f,
@ -673,7 +673,7 @@ void Camera::calculateMatricesAndClippingVolume() const
float E = -(_zFar+_zNear) / (_zFar-_zNear);
float F = -(2.0*_zFar*_zNear) / (_zFar-_zNear);
_projectionMatrix = new Matrix(
_projectionMatrix = osgNew Matrix(
A, 0.0f, 0.0f, 0.0f,
0.0f, B, 0.0f, 0.0f,
C, D, E, -1.0f,
@ -695,7 +695,7 @@ void Camera::calculateMatricesAndClippingVolume() const
}
else
{
_modelViewMatrix = new Matrix;
_modelViewMatrix = osgNew Matrix;
_modelViewMatrix->makeIdentity();
}
break;
@ -711,7 +711,7 @@ void Camera::calculateMatricesAndClippingVolume() const
Vec3 u(s^f);
u.normalize();
ref_ptr<Matrix> matrix = new Matrix(
ref_ptr<Matrix> 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"<<std::endl;

View File

@ -20,7 +20,7 @@ class DisplaySettingsPtr
DisplaySettings* DisplaySettings::instance()
{
static DisplaySettingsPtr s_displaySettings = new DisplaySettings;
static DisplaySettingsPtr s_displaySettings = osgNew DisplaySettings;
return s_displaySettings.get();
}

View File

@ -9,7 +9,7 @@ using namespace osg;
*/
EarthSky::EarthSky()
{
StateSet* stateset = new StateSet;
StateSet* stateset = osgNew StateSet;
stateset->setRenderBinDetails(-1,"RenderBin");
setStateSet(stateset);

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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
// ---------------------------------------------------------------------------------------------------------------------------------

View File

@ -4,7 +4,7 @@
using namespace std;
osg::NotifySeverity osg::g_NotifyLevel = osg::NOTICE;
std::ofstream *osg::g_NotifyNulStream;
std::auto_ptr<ofstream> 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

View File

@ -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);
*/
}

View File

@ -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;
}

View File

@ -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 "<<fullLibraryName<<std::endl;
#elif !defined(macintosh)
HANDLE handle = dlopen( fullLibraryName, RTLD_LAZY );
if (handle) return new DynamicLibrary(libraryName,handle);
if (handle) return osgNew DynamicLibrary(libraryName,handle);
notify(WARN) << "DynamicLibrary::failed loading "<<fullLibraryName<<std::endl;
notify(WARN) << "DynamicLibrary::error "<<dlerror()<<std::endl;
#endif

View File

@ -33,7 +33,7 @@ Field& Field::operator = (const Field& ic)
void Field::_free()
{
// free all data
if (_fieldCache) delete [] _fieldCache;
if (_fieldCache) osgDelete [] _fieldCache;
_init();
@ -64,7 +64,7 @@ void Field::_copy(const Field& ic)
{
_fieldCacheCapacity = ic._fieldCacheCapacity;
_fieldCacheSize = ic._fieldCacheSize;
_fieldCache = new char [_fieldCacheCapacity];
_fieldCache = osgNew char [_fieldCacheCapacity];
strncpy(_fieldCache,ic._fieldCache,_fieldCacheCapacity);
}
else
@ -146,7 +146,7 @@ void Field::addChar(char c)
if (_fieldCache==NULL)
{
if (_fieldCacheCapacity<MIN_CACHE_SIZE) _fieldCacheCapacity=MIN_CACHE_SIZE;
_fieldCache = new char[_fieldCacheCapacity];
_fieldCache = osgNew char[_fieldCacheCapacity];
_fieldCacheSize = 0;
}
else if (_fieldCacheSize>=_fieldCacheCapacity-1)
@ -154,9 +154,9 @@ void Field::addChar(char c)
if (_fieldCacheCapacity<MIN_CACHE_SIZE) _fieldCacheCapacity=MIN_CACHE_SIZE;
while (_fieldCacheSize>=_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;

View File

@ -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<ic._fieldQueueCapacity;++i)
{
if (ic._fieldQueue[i])
{
_fieldQueue[i] = new Field(*ic._fieldQueue[i]);
_fieldQueue[i] = osgNew Field(*ic._fieldQueue[i]);
}
else
{
@ -128,7 +128,7 @@ void FieldReaderIterator::insert(int pos,Field* field)
int newCapacity = _fieldQueueCapacity*2;
if (newCapacity<MINIMUM_FIELD_READER_QUEUE_SIZE) newCapacity = MINIMUM_FIELD_READER_QUEUE_SIZE;
while(_fieldQueueSize>=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<MINIMUM_FIELD_READER_QUEUE_SIZE) newCapacity = MINIMUM_FIELD_READER_QUEUE_SIZE;
while(_fieldQueueSize>=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<no;++i)
{

View File

@ -289,7 +289,7 @@ char *osgDB::findDSO( const char *name )
// failed with direct paths,
// now try prepending the filename with "osgPlugins/"
char* prependosgPlugins = new char[strlen(name)+12];
char* prependosgPlugins = osgNew char[strlen(name)+12];
strcpy(prependosgPlugins,"osgPlugins/");
strcat(prependosgPlugins,name);

View File

@ -72,7 +72,7 @@ Node* osgDB::readNodeFiles(std::vector<std::string>& 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)

View File

@ -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();

View File

@ -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<GLUTEventAdapter> ea = new GLUTEventAdapter;
osg::ref_ptr<GLUTEventAdapter> 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<GLUTEventAdapter> ea = new GLUTEventAdapter;
osg::ref_ptr<GLUTEventAdapter> 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<GLUTEventAdapter> ea = new GLUTEventAdapter;
osg::ref_ptr<GLUTEventAdapter> 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<GLUTEventAdapter> ea = new GLUTEventAdapter;
osg::ref_ptr<GLUTEventAdapter> 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<GLUTEventAdapter> ea = new GLUTEventAdapter;
osg::ref_ptr<GLUTEventAdapter> 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<GLUTEventAdapter> ea = new GLUTEventAdapter;
osg::ref_ptr<GLUTEventAdapter> 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<GLUTEventAdapter> ea = new GLUTEventAdapter;
osg::ref_ptr<GLUTEventAdapter> 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<GLUTEventAdapter> ea = new GLUTEventAdapter;
osg::ref_ptr<GLUTEventAdapter> 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<osg::ShadeModel*>(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<osg::Texture> blank_texture = new osg::Texture;
static osg::ref_ptr<osg::Texture> 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<LightModel*>(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<osg::LineSegment> lineSegment = new osg::LineSegment;
osg::ref_ptr<osg::LineSegment> lineSegment = osgNew osg::LineSegment;
lineSegment->set(near_point,far_point);
osg::notify(osg::NOTICE) << "start("<<lineSegment->start()<<") end("<<lineSegment->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<GLUTEventAdapter> 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<GLUTEventAdapter> 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);

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -27,7 +27,7 @@ bool Drawable_readLocalData(Object& obj, Input& fr)
Drawable& drawable = static_cast<Drawable&>(obj);
static ref_ptr<StateSet> s_drawstate = new osg::StateSet;
static ref_ptr<StateSet> s_drawstate = osgNew osg::StateSet;
if (StateSet* readState = static_cast<StateSet*>(fr.readObjectOfType(*s_drawstate)))
{
drawable.setStateSet(readState);

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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;i<oldCapacity;++i)
{
list[i] = oldList[i];
}
delete [] oldList;
osgDelete [] oldList;
}
list[size] = primLength;
++size;
@ -225,7 +225,7 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
}
int size = 0;
coordList = new Vec3[capacity];
coordList = osgNew Vec3[capacity];
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
{
@ -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;i<oldCapacity;++i)
{
coordList[i][0] = oldList[i][0];
coordList[i][1] = oldList[i][1];
coordList[i][2] = oldList[i][2];
}
delete [] oldList;
osgDelete [] oldList;
}
coordList[size][0] = x;
coordList[size][1] = y;
@ -295,7 +295,7 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
}
int size = 0;
normalList = new Vec3[capacity];
normalList = osgNew Vec3[capacity];
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
{
@ -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;i<oldCapacity;++i)
{
normalList[i][0] = oldList[i][0];
normalList[i][1] = oldList[i][1];
normalList[i][2] = oldList[i][2];
}
delete [] oldList;
osgDelete [] oldList;
}
normalList[size][0] = x;
normalList[size][1] = y;
@ -364,7 +364,7 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
}
int size = 0;
colorList = new Vec4[capacity];
colorList = osgNew Vec4[capacity];
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
{
@ -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;i<oldCapacity;++i)
{
colorList[i][0] = oldList[i][0];
@ -387,7 +387,7 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
colorList[i][2] = oldList[i][2];
colorList[i][3] = oldList[i][3];
}
delete [] oldList;
osgDelete [] oldList;
}
colorList[size][0] = r;
@ -438,7 +438,7 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
}
int size = 0;
textureList = new Vec2[capacity];
textureList = osgNew Vec2[capacity];
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
{
@ -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;i<oldCapacity;++i)
{
textureList[i][0] = oldList[i][0];
textureList[i][1] = oldList[i][1];
}
delete [] oldList;
osgDelete [] oldList;
}
textureList[size][0] = r;
textureList[size][1] = s;
@ -532,9 +532,9 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
int rowLength = GeoSet_getInterleavedRowLength(iaType);
int size = 0;
unsigned char* dataList = new unsigned char[capacity*rowLength];
unsigned char* dataList = osgNew unsigned char[capacity*rowLength];
unsigned char* rowData = new unsigned char [rowLength];
unsigned char* rowData = osgNew unsigned char [rowLength];
float floatData;
int intData;
@ -569,9 +569,9 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
int oldCapacity = capacity;
while(capacity<=size) capacity *= 2;
unsigned char* oldList = dataList;
dataList = new unsigned char[capacity*rowLength];
dataList = osgNew unsigned char[capacity*rowLength];
memcpy(dataList,oldList,oldCapacity*rowLength);
delete [] oldList;
osgDelete [] oldList;
}
memcpy(dataList+size*rowLength,rowData,rowLength);
++size;
@ -583,7 +583,7 @@ bool GeoSet_readLocalData(Object& obj, Input& fr)
}
}
delete [] rowData;
osgDelete [] rowData;
interleavedArray = (float*)dataList;
}
@ -926,7 +926,7 @@ bool GeoSet_readIndexData(Input& fr, const char* IndexName, GeoSet::IndexPointer
if (is_ushort)
{
// read ushorts...
osg::ushort* coordIndexList = new osg::ushort[capacity];
osg::ushort* coordIndexList = osgNew osg::ushort[capacity];
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
{
@ -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;i<oldCapacity;++i)
{
coordIndexList[i] = oldList[i];
}
delete [] oldList;
osgDelete [] oldList;
}
coordIndexList[size] = index;
++size;
@ -962,7 +962,7 @@ bool GeoSet_readIndexData(Input& fr, const char* IndexName, GeoSet::IndexPointer
else
{
// read uints...
osg::uint* coordIndexList = new osg::uint[capacity];
osg::uint* coordIndexList = osgNew osg::uint[capacity];
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
{
@ -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<oldCapacity;++i)
{
coordIndexList[i] = oldList[i];
}
delete [] oldList;
osgDelete [] oldList;
}
coordIndexList[size] = index;
++size;

View File

@ -14,7 +14,7 @@ bool Geode_writeLocalData(const Object& obj, Output& fw);
// register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_GeodeProxy
(
new osg::Geode,
osgNew osg::Geode,
"Geode",
"Object Node Geode",
&Geode_readLocalData,

View File

@ -14,7 +14,7 @@ bool Group_writeLocalData(const Object& obj, Output& fw);
// register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_GroupProxy
(
new osg::Group,
osgNew osg::Group,
"Group",
"Object Node Group",
&Group_readLocalData,

View File

@ -14,7 +14,7 @@ bool Image_writeLocalData(const Object& obj, Output& fw);
// register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_ImageFuncProxy
(
new osg::Image,
osgNew osg::Image,
"Image",
"Object Image",
&Image_readLocalData,

View File

@ -14,7 +14,7 @@ bool Impostor_writeLocalData(const Object& obj, Output& fw);
// register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_ImpostorProxy
(
new osg::Impostor,
osgNew osg::Impostor,
"Impostor",
"Object Node Impostor LOD Group",
&Impostor_readLocalData,

View File

@ -14,7 +14,7 @@ bool LOD_writeLocalData(const Object& obj, Output& fw);
// register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_LODProxy
(
new osg::LOD,
osgNew osg::LOD,
"LOD",
"Object Node LOD Group",
&LOD_readLocalData,

View File

@ -18,7 +18,7 @@ bool Light_writeLocalData(const Object& obj, Output& fw);
// register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_LightProxy
(
new osg::Light,
osgNew osg::Light,
"Light",
"Object StateAttribute Light",
&Light_readLocalData,

View File

@ -15,7 +15,7 @@ bool LightModel_writeLocalData(const Object& obj, Output& fw);
// register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_LightModelProxy
(
new osg::LightModel,
osgNew osg::LightModel,
"LightModel",
"Object StateAttribute LightModel",
&LightModel_readLocalData,

View File

@ -14,7 +14,7 @@ bool LightSource_writeLocalData(const Object& obj, Output& fw);
// register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_LightSourceProxy
(
new osg::LightSource,
osgNew osg::LightSource,
"LightSource",
"Object Node LightSource",
&LightSource_readLocalData,
@ -27,7 +27,7 @@ bool LightSource_readLocalData(Object& obj, Input& fr)
LightSource& lightsource = static_cast<LightSource&>(obj);
static ref_ptr<Light> s_light = new osg::Light;
static ref_ptr<Light> s_light = osgNew osg::Light;
Light* light = static_cast<Light*>(fr.readObjectOfType(*s_light));
if (light)

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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<StateSet> s_drawstate = new osg::StateSet;
static ref_ptr<StateSet> s_drawstate = osgNew osg::StateSet;
if (StateSet* readState = static_cast<StateSet*>(fr.readObjectOfType(*s_drawstate)))
{
node.setStateSet(readState);

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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();

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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;
}

View File

@ -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,

View File

@ -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)
{

View File

@ -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;
}
}

View File

@ -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))
{

View File

@ -98,5 +98,7 @@
# define FTGL_EXPORT
#endif
#include <osg/MemoryManager>
#endif // __FTGL__

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -19,7 +19,7 @@ FTGlyphContainer::~FTGlyphContainer()
vector<FTGlyph*>::iterator iter;
for( iter = glyphs.begin(); iter != glyphs.end(); ++iter)
{
delete *iter;
osgDelete *iter;
}
glyphs.clear();

View File

@ -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;
// }

View File

@ -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;
}

View File

@ -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];

View File

@ -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;
}

View File

@ -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];

View File

@ -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);
}

View File

@ -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);

View File

@ -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<osg::LineSegment> s12 = new LineSegment(v1, v2);
osg::ref_ptr<osg::LineSegment> 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<CullViewState> nvs = new CullViewState;
osg::ref_ptr<CullViewState> 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<RenderToTextureStage> rtts = new RenderToTextureStage;
ref_ptr<RenderToTextureStage> 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<StateSet> dummyState = new StateSet;
ref_ptr<StateSet> 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);

View File

@ -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())

View File

@ -60,7 +60,7 @@ void DriveManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
bool cameraSet = false;
osg::ref_ptr<osg::LineSegment> segDown = new osg::LineSegment;
osg::ref_ptr<osg::LineSegment> 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<osg::LineSegment> segUp = new osg::LineSegment;
osg::ref_ptr<osg::LineSegment> 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<osg::LineSegment> segDown = new osg::LineSegment;
osg::ref_ptr<osg::LineSegment> 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<osg::LineSegment> segUp = new osg::LineSegment;
osg::ref_ptr<osg::LineSegment> 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<osg::LineSegment> segForward = new osg::LineSegment;
osg::ref_ptr<osg::LineSegment> 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<osg::LineSegment> segNormal = new osg::LineSegment;
osg::ref_ptr<osg::LineSegment> segNormal = osgNew osg::LineSegment;
segNormal->set(fp,lfp);
iv.addLineSegment(segNormal.get());
@ -515,7 +515,7 @@ bool DriveManipulator::calcMovement()
iv.reset();
osg::ref_ptr<osg::LineSegment> segFall = new osg::LineSegment;
osg::ref_ptr<osg::LineSegment> segFall = osgNew osg::LineSegment;
segFall->set(lfp,dp);
iv.addLineSegment(segFall.get());

View File

@ -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;ci<lod->getNumChildren();++ci)

Some files were not shown because too many files have changed in this diff Show More