[osg-users] Most efficient way to use osg::DrawElementsUInt?

Jesper D. Thomsen jdt at anybodytech.com
Thu Mar 26 04:42:51 PDT 2009

Hi, and thank you.

I naturally tried to use reserve() (but thanks for suggesting it) and this of course helped somewhat, but it still seems to be the primary bottleneck. I've changed most of the rest of the per-frame geometry generation code to use static arrays rather than std::vector and this caused a major speedup (factor 10 or more) of my own part of the code, but I'm still stuck with the push_backs on osg::DrawElementsUInt.
Maybe there's just no faster way to do it, or maybe I'm just using OSG in a somewhat un-intended way.

Jesper D. Thomsen

From: osg-users-bounces at lists.openscenegraph.org [osg-users-bounces at lists.openscenegraph.org] On Behalf Of Peter Hrenka [p.hrenka at science-computing.de]
Sent: Thursday, March 26, 2009 12:00 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Most efficient way to use osg::DrawElementsUInt?

Hi Jesper,

Jesper D. Thomsen schrieb:
> Hi all, I'm developing an application where I have to create up to 1000
> osg:geometry objects per frame during certain interaction modes.
> I'm using osg::DrawElementsUInt push_back() to define the geometry
> primitive sets, and this push_back() seems to be the primary bottleneck
> for my applications graphical performance. Is there a more efficient way
> to define the primitive sets than to fill a osg::DrawElementsUInt by
> push_back and add it to the geometry?
> This is currently bringing me down to about 1 second per frame, which is
> kind of a roadblock.

You can use reserve() to pre-allocate the needed memory.
After that push_back() will not perform any reallocations/copies
until the limit is reached.

> regards,
> Jesper D. Thomsen


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

osg-users mailing list
osg-users at lists.openscenegraph.org

More information about the osg-users mailing list