Michael Reichel wrote:
> Hi,
> first of all: I am new to OSG!
> I like to programm a diplay for scientific purposes. I want to display lots 
> (lets say 500 - 10.000.000) Boxes. At each time cycle (100ms) ist can be 500 
> - 10.000.000 Boxes. 
> All examples I read so far contained a allocation of memeory for all of those 
> Boxes in the init. Problem: The amount of boxes varies a lot between two time 
> cycles and the boxes from two different time cycles are not connected (there 
> is no ID or somewhat that matches two boxes of two different time slots). 
> Thats why I do not want to change existing boxes in the osg. I rather want to 
> biuld a new graph each time.
> But: If I would do so - I had to allocate up to 10.000.000 Boxes each time. 
> That is not performant. Is there a way to allocate memory / instiate 
> 10.000.000 boxes at the beginning of the programm without to connect them to 
> the osg. And then - to connect just those Boxes that should be displayed? And 
> then to clean the osg without destroying the box instances?
> If anyone has an answer to such a problem - please state som code especially 
> of how to instantiate (new) the boxes and how to clean the osg.

  Asking for sample code for your specific case is a little much.

  OSG uses a reference counting allocation system. You can pre-allocate a large 
number of
objects using "new" and hold them in an array of ref_ptr's. When they are then 
added to
the scenegraph, and then later removed, they will remain allocated because they 
are still
referenced by the array of ref_ptrs. You can then destroy them at your whim by 
removing
them from the array.

> And one more question: In all your examples - how do you ensure that the 
> memory of the with new allocated drawables will be freed?

  The reference counting system ensures this for you. This old article:
http://andesengineering.com/OSG_ProducerArticles/RefPointers/RefPointers.html

  explains some of how it works.

  As Robert points out, just throwing 10 million objects into OSG is not 
guaranteed to
give you good performance. You may be attempting more than you're ready to 
handle by
yourself here.

> Cheers,
> Michael


-- 
Chris 'Xenon' Hanson, omo sanza lettere                  Xenon AlphaPixel.com
PixelSense Landsat processing now available! http://www.alphapixel.com/demos/
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to