On 8/01/11 5:00 , Antoine Rennuit wrote:
> This afternoon I tried to write code that calls ShapeDrawable::setColor()
> twice in a
> row (the actual way things are written is that I have a default color for my
> ShapeDrawable that I overwrite if a test is true, hence the 2 calls in a row).
>
> These 2 calls in a row make my rendering loop become suddenly much longer.
> This only
> happens when the argument in the 2 calls are different (if the argument is
> the same the
> rendering speed keeps being fast).
Changing the color (ie new color != current color) will dirty (invalidate) the
display
list which causes it to be re-built on the next draw.
Do you mean you're calling 'setColor' per frame? That would be the only case I
can think
of that would slow things down, because you're invalidating the DL every frame.
A couple of things you could try:
- disable display lists for the geometry, by calling
'drawable->setUseDisplayList(false)'
- only call 'setColor' when the color has actually changed
- don't set the default color, so rather than
setColor(default);
if (foo)
{
setColor(other);
}
do
setColor(foo ? other : default);
Unless 'foo' changes every frame this should at least avoid dirtying the DL
when the
color doesn't change.
Hope this helps,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org