From f1d8a584d80e6cb43aac7d708893a2fe87686318 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 21 Dec 2003 23:02:32 +0000 Subject: [PATCH] Fixed memory leak and utilised DrawArrayLengths in place of multiple DrawArray calls. --- src/osgPlugins/txp/TrPageParser.cpp | 50 ++++++++++------------------- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/src/osgPlugins/txp/TrPageParser.cpp b/src/osgPlugins/txp/TrPageParser.cpp index 42edde5d1..289e9c390 100644 --- a/src/osgPlugins/txp/TrPageParser.cpp +++ b/src/osgPlugins/txp/TrPageParser.cpp @@ -402,61 +402,45 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf) break; case trpgGeometry::TriStrips: { - // Need primitive lengths too - int* primitives = new int[numPrims]; - geom.GetPrimLengths(primitives); - - // Define Geomtry - geometry = new Geometry; - int first=0; - for(int i=0;iaddPrimitiveSet(new DrawArrays(PrimitiveSet::TRIANGLE_STRIP,first,primitives[i])); - first += primitives[i]; - - } + geometry = new osg::Geometry; + osg::DrawArrayLengths* dal = new osg::DrawArrayLengths(osg::PrimitiveSet::TRIANGLE_STRIP,0,numPrims); + geom.GetPrimLengths(&(dal->front())); + geometry->addPrimitiveSet(dal); } break; case trpgGeometry::TriFans: { - // Need primitive lengths too - int* primitives = new int[numPrims]; - geom.GetPrimLengths(primitives); - - - // create the trifan primitives. - geometry = new Geometry; - int first=0; - int i; - for(i=0;iaddPrimitiveSet(new DrawArrays(PrimitiveSet::TRIANGLE_FAN,first,primitives[i])); - first += primitives[i]; - } + geometry = new osg::Geometry; + osg::DrawArrayLengths* dal = new osg::DrawArrayLengths(osg::PrimitiveSet::TRIANGLE_FAN,0,numPrims); + geom.GetPrimLengths(&(dal->front())); + geometry->addPrimitiveSet(dal); // Need to flip the fans coords. int ind = 0; + int i; for (i=0;i