Hi J-S,

Yes, thank you, that did the trick, now it works. And to answer my question 
above, it has to be glEnableClientState, otherwise its not working.

I have one more issue now. Sergey, I am getting a Access Violation Exception 
directly after calling viewer.run inside osg::Vec3f line 84, if I use the the 
default restart index of USHRT_MAX. 
To debug this, I added a method to set the index, and got wired results. I 
created an 18 Elements TriStrip, code is bellow. When I set the restart index 
between 0 and 18 (18 is not a typo ), everything is fine. When I set it to 19 
and higher I get this in the console:

Code:

CullVisitor::apply(Geode&) detected NaN,
   depth=-1.IND, center=(-2 0 -7.942e+037),
   matrix={
      1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN
      1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN
      1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN
      1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN
}




If I set the index between 1000 and 2000 it works right ( ! ), and if I set it 
to 5000 and above I get the Access Violation Exception again.
Do you have any idea what's going on ? Is this related to not creating an 
StateAttribute ?

TestCode, uses the class posted by hybr:


Code:

#include "DrawElementsUShortRestart.h"

#include <osg/Geode>
#include <osg/Geometry>
#include <osg/PolygonMode>


osg::ref_ptr< osg::Node > createDrawElements() {

   osg::Geometry * geom = new osg::Geometry() ;

   osg::Vec3Array * vrts = new osg::Vec3Array() ;
   geom -> setVertexArray( vrts ) ;

   unsigned int numVrts = 18 ;

   // Create Vertex Positions for TriStripe
   for( unsigned int i = 0 ; i < numVrts / 2 ; ++i ) {
      vrts -> push_back( osg::Vec3( i , 1.f , 0.f ) ) ;
      vrts -> push_back( osg::Vec3( i ,-1.f , 0.f ) ) ;
   }

   // Create a PrimitiveRestart DrawElements
   DrawElementsUShortRestart * drawElems = new DrawElementsUShortRestart() ;

   // This is set to false by default in the constructors initializer list
   drawElems -> enableRestart( true ) ;

   // Added this method to the DrawElementsUShortRestart Class
   drawElems -> setRestartIndex( 1000 ) ; // Try also 20 and USHRT_MAX

   for( unsigned int i = 0 ; i < numVrts ; ++i ) {
      if ( i == 9 )
         drawElems -> push_back( 1000 ) ; // Try also 20 and USHRT_MAX

      drawElems -> push_back( i ) ;
   }

   geom -> addPrimitiveSet( drawElems ) ;
   geom -> getOrCreateStateSet() -> setMode( GL_LIGHTING , 
osg::StateAttribute::OFF ) ;
   geom -> getOrCreateStateSet() -> setAttributeAndModes(
      new osg::PolygonMode( osg::PolygonMode::FRONT_AND_BACK, 
osg::PolygonMode::LINE ) ) ;

   osg::ref_ptr< osg::Geode > geode = new osg::Geode() ;
   geode -> addDrawable( geom ) ;

   return geode.release() ;

}




Thank you!

Cheers, ParticlePeter

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41911#41911





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to