When you first set up your line strip, you only put one vertex in it, so I wouldn't expect anything to be drawn until you add an additional vertex.
You have set your color binding to be BIND_PER_VERTEX and you have one color in the color array. Initially (when you only have one vertex) this is OK. But as soon as you add more vertices, you do not also add more colors, so this could potentially cause a crash if OSG or OpenGL tries to index off the end of you color array. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com +1 303 859 9466 -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Sergey Sent: Saturday, April 18, 2009 8:47 AM To: [email protected] Subject: Re: [osg-users] Dinamic Line Drawing may be it depends on driver , but setUseDisplayList(false); works very strange!!! if I set it to false I get one direct line without color information and all new vertices is drawn in (0,0,0). Here my code and 2 screens differs only in one : in second screen line linesGeom->setUseDisplayList(false); is commented Any Idea? CODE ----------------------------------------- class TglLine { public: int ID; TglLine(float X,float Y,float Z, QColor color); ~TglLine(void); osg::Geode* Geode; void addNode(float X,float Y,float Z, QColor color); private: osg::ref_ptr<osg::DrawArrays> drawArrayLines ; osg::ref_ptr<osg::Vec3Array> vertexData ; osg::ref_ptr<osg::Vec4Array> colors ; osg::ref_ptr<osg::Geometry> linesGeom ; }; //CONSTRUCTOR TglLine::TglLine(float X,float Y,float Z, QColor color) { //ALLOCATE MEMORY drawArrayLines = new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP); vertexData = new osg::Vec3Array; linesGeom = new osg::Geometry(); Geode =new osg::Geode; colors = new osg::Vec4Array; vertexData->push_back(osg::Vec3(X,Y,Z)); drawArrayLines->setFirst(0); drawArrayLines->setCount(vertexData->size()); linesGeom->addPrimitiveSet(drawArrayLines.get()); linesGeom->setVertexArray(vertexData.get()); linesGeom->setColorArray(colors); linesGeom->setColorBinding(osg::Geometry::BIND_PER_VERTEX); // linesGeom->setUseDisplayList(false); Geode->addDrawable(linesGeom.get()); } // ADD NODE void TglLine::addNode(float X,float Y,float Z, QColor color){ vertexData->push_back(osg::Vec3(X,Y,Z)); colors->push_back(osg::Vec4(color.red(),color.green(),color.blue(), color.alphaF())); drawArrayLines->setFirst(0); int i =vertexData->size(); drawArrayLines->setCount(i); linesGeom->dirtyBound(); } //HERE my call TglLine *test_line=new TglLine::TglLine(0,0,0,QColor(255,255,255,255)); root->addChild(test_line->Geode); QColor col= QColor(255,0,255,100); test_line->addNode(0,0,5000, col); test_line->addNode(10000, 10000, 10000, col); test_line->addNode(-10000, -10000, -10000, col); test_line->addNode(-10000, 300, -10000, col); ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=10366#10366 _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

