|
im using visual studio 2003, and im using the following code to detect
my memory leaks: // Memory leak information #ifdef _DEBUG #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) #include <crtdbg.h> #else #define DEBUG_NEW new #endif Here is a class that i use to call GLTextString, its still leaking. I changed the code in GLTextString to look like this: osgText::Text* GetText(void) { return m_Text.get(); } and it still leaks. In the following code lines like: osg::ref_ptr<osg::ShapeDrawable> drawable = new osg::ShapeDrawable(cylinder.get(), hints.get()); also leak! So im completely lost with osg::ref_ptr thing now. Again my sleeves are empty! :) //////////////////////////////////// //TwoDAxis.h /////////////////////////////////// TwoDAxis::TwoDAxis(double size, string upLabel, string rightLabel) { osg::ref_ptr<osg::Geode> geode = new osg::Geode(); osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet(); stateset->setMode(GL_LIGHTING, osg::StateAttribute::ON); stateset->setMode(GL_BLEND, osg::StateAttribute::ON); stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); geode->setStateSet(stateset.get()); osg::ref_ptr<osg::TessellationHints> hints = new osg::TessellationHints; hints->setDetailRatio(0.5f); float coneRadius = size * 0.12; float coneHeight = size * 0.12; float cylinderRadius = size * 0.05; // right axis osg::Vec3 right(size, 0, 0); osg::ref_ptr<osg::Cylinder> cylinder = new osg::Cylinder(right/2.0f, cylinderRadius, size); cylinder->setRotation(osg::Quat(M_PI_2, osg::Vec3d(0, 1, 0))); osg::ref_ptr<osg::ShapeDrawable> drawable = new osg::ShapeDrawable(cylinder.get(), hints.get()); drawable->setColor(Colors::m_AxisRightColor); geode->addDrawable(drawable.get()); osg::ref_ptr<osg::Cone> cone = new osg::Cone(right, coneRadius, coneHeight); cone->setRotation(osg::Quat(M_PI_2, osg::Vec3d(0, 1, 0))); drawable = new osg::ShapeDrawable(cone.get(), hints.get()); drawable->setColor(Colors::m_AxisRightColor); geode->addDrawable(drawable.get()); osg::ref_ptr<GLTextString> rightText = new GLTextString(rightLabel, size * 0.3); rightText->GetText()->setAutoRotateToScreen(true); rightText->GetText()->setPosition(right + osg::Vec3(8, 0, 0)); geode->addDrawable(rightText->GetText()); // up axis osg::Vec3 up(0, size, 0); cylinder = new osg::Cylinder(up/2.0f, cylinderRadius, size); cylinder->setRotation(osg::Quat(M_PI_2, osg::Vec3d(1, 0, 0))); drawable = new osg::ShapeDrawable(cylinder.get(), hints.get()); drawable->setColor(Colors::m_AxisUpColor); geode->addDrawable(drawable.get()); cone = new osg::Cone(up, coneRadius, coneHeight); cone->setRotation(osg::Quat(-M_PI_2, osg::Vec3d(1, 0, 0))); drawable = new osg::ShapeDrawable(cone.get(), hints.get()); drawable->setColor(Colors::m_AxisUpColor); geode->addDrawable(drawable.get()); osg::ref_ptr<GLTextString> upText = new GLTextString(upLabel, size * 0.3); upText->GetText()->setAutoRotateToScreen(true); upText->GetText()->setPosition(up + osg::Vec3(0, 8, 0)); geode->addDrawable(upText->GetText()); // Node osg::ref_ptr<osg::Sphere> sphere = new osg::Sphere(osg::Vec3(0, 0, 0), size * 0.1); drawable = new osg::ShapeDrawable(sphere.get(), hints.get()); drawable->setColor(Colors::m_AxisNodeColor); geode->addDrawable(drawable.get()); addChild(geode.get()); } Thrall, Bryan wrote: Tamer El Nashar wrote on Monday, March 31, 2008 1:56 PM: |
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

