int main( int argc, char **argv ) { osg::ArgumentParser arguments(&argc, argv); // Make a scene graph consisting of a single Geode, containing // a single Geometry, and a single PrimitiveSet. osg::ref_ptr< osg::Geode > geode = new osg::Geode; osg::ref_ptr< osg::Geometry > geom = new osg::Geometry; // Configure the Geometry for use with EXT_draw_arrays: // DL off and buffer objects on. geom->setUseDisplayList( false ); geom->setUseVertexBufferObjects( true ); // OSG has no clue where out vertex shader will place the geometric data, // so specify an initial bound to allow proper culling and near/far computation. osg::BoundingBox bb( -1., -.1, -1., 49., 1., 49. ); geom->setInitialBound( bb ); // Add geometric data and the PrimitiveSet. Specify numInstances as 32*32 or 1024. createDAIGeometry( *geom, 32*32 ); geode->addDrawable( geom.get() ); // Create a StateSet to render the instanced Geometry. osg::ref_ptr< osg::StateSet > ss = createStateSet(); geode->setStateSet( ss.get() ); // osgDB::writeNodeFile(*geode, "instanced.osgt"); osgViewer::Viewer viewer(arguments); viewer.setSceneData( geode.get() ); return viewer.run(); }
osg::Geometry* createGrassGeom() { osg::Geometry* geom = new osg::Geometry; geom->setUseDisplayList( false ); geom->setUseVertexBufferObjects( true ); createDAIGeometry( *geom, cc*cc ); //osg::BoundingBox bb( -50., -.50, -50., 100., 100., 100. ); osg::BoundingBox bb( -5., -.5, -5., 10., 10., 10. ); geom->setInitialBound( bb ); return geom; }