Drolet, Frederic wrote on 2010-03-12: > Let's say I want to change the color of my road segment (when selected > for instance). We're currently doing this modification that way: > > osg::Vec4Array* lCouleur = (osg::Vec4Array*)(mGeometrie- >> getColorArray()); > *(lCouleur->begin()) = pCouleur; mGeometrie->dirtyDisplayList(); > >> From what you're saying, I guess we should create a different stateset > for every color instead of a stateset for every segment? Maybe I should > ask first if the color is indeed part of the stateset anyway! If not, > we could reduce the stateset count even more!
The color array is independent from the StateSet. It appears you are only using the StateSet to turn lighting off; if that is true, you could just create a single StateSet that turns lighting off and put it near the top of your scene graph. The color arrays and modifying them should not affect performance as much as the OpenGL state changes that come from many StateSets. > -----Original Message----- From: > osg-users-boun...@lists.openscenegraph.org [mailto:osg-users- > boun...@lists.openscenegraph.org] On Behalf Of Thrall, Bryan Sent: > Friday, March 12, 2010 10:39 AM To: OpenSceneGraph Users Subject: Re: > [osg-users] Multi-view Performance Issue with Statesets > > Drolet, Frederic wrote on 2010-03-12: >> osg::ref_ptr<osg::StateSet> lStateSet = mGeometrie- >>> getOrCreateStateSet(); >> >> lStateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF); > > OpenGL performance is very sensitive to state changes, so it is a good > idea to minimize them as much as possible. OSG groups Drawables with > the same state as part of this (the exception is transparent drawables > that require a certain ordering to render correctly, so they can't be > grouped), but it just compares the StateSet pointers rather than a > (much more expensive) comparison of what OpenGL state the StateSet > pointers represent. > > Therefore, if you have a bunch of StateSets that are identical, like > you seem to have, it is a really good idea to just use the same > StateSet object everywhere you need it, rather than create a new > instance every time. > > HTH, -- Bryan Thrall FlightSafety International bryan.thr...@flightsafety.com _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org