[osg-users] Fast VectorArray inizialization.

Peter Hrenka p.hrenka at science-computing.de
Fri Apr 1 02:27:26 PDT 2011


Hi Giulio,


Am 01.04.2011 10:57, schrieb Giulio De Vecchi:
> Hi all,
> I have some code like this:
> 
> float coordinates[]
> ...
> ... an external source fill the previous array ...
> ...
> osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array();
> for (int i = 0; i < 3 * numPoints; i += 3)
> {
> 	float x = coordinates[i];
> 	float y = coordinates[i+1];
> 	float z = coordinates[i+2];
> 	vertices->push_back(osg::Vec3(x, y, z));
> }
> modelGeometry->setVertexArray(vertices);
> 
> I'd rather do something like this:
> 
> modelGeometry->setVertexArray_FromCArray(coordinates);
> 
> Is it possible? How?

Yes, have a look at the example osgsharedarray.

Of course you have to make sure the the array
is not freed until the last draw is finished.

> ---
> 
> Best regards,
> Giulio

Cheers,

Peter
-- 
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, 
Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Michel Lepert
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 





More information about the osg-users mailing list