Hi J-S,

UnRefImageDataAfterApply is off by default.  But the Optimizer by
default with switch it on.  You can just call the Optimizer with the
settings you require rather than patch it afterwards back to what it
was originally...

As for an alternative, well there is one, you can't have your cake and
eat, you either get rid of the Image and lower memory consumption and
loose the ability to apply to later contexts, or you keep the Imagery
around in case you need it.

If you wanted to really dig into this topic I guess you could replace
the osg::Image by a "ProxyImage" class that allows the imagery to be
reloaded if its needed later.  Such a class doesn't exist right now,
and it wouldn't be entirely straight forward to implement.

Robert.

On Thu, Nov 20, 2008 at 3:53 AM, Jean-Sébastien Guay
<[EMAIL PROTECTED]> wrote:
> Hi all,
>
> As noted in other threads, I'm currently working on an app that adds views
> at runtime. As expected, this causes the views created after the viewer has
> started running to have no textures on the models, because of the
> osg::Texture::_unrefImageDataAfterApply default setting of true.
>
> Now, one solution would be to turn this off globally, for example by doing
>
>    osgUtil::Optimizer::TextureVisitor tv(
>        true, false, false, false, false, 1.0, 0);
>    loadedModel->accept(tv);
>
> for every loaded model file. However, that will waste memory most of the
> time, since new views will only be added occasionally.
>
> A more efficient solution might be to reload the textures when a new view is
> ready to be rendered for the first time. However, as I understand it, an
> osg::Texture does not retain any information as to where its image data came
> from, so I don't see how I would do this.
>
> Has anyone thought of this, or tried to implement it? Is there already a
> mechanism for that in OSG which I'm just not aware of?
>
> Also, I've noticed the osg::Texture::_clientStorageHint, what does that do?
>
> Finally, on the subject of the osgUtil::Optimizer::TextureVisitor, it could
> have an option to change the _resizeNonPowerOfTwoHint, now that most recent
> video cards implement quite fast support for NPOT textures and some users
> might want to make use of it on existing models without modifying the models
> directly. I'll try to submit this soon.
>
> Thanks in advance,
>
> J-S
> --
> ______________________________________________________
> Jean-Sebastien Guay    [EMAIL PROTECTED]
>                               http://www.cm-labs.com/
>                        http://whitestar02.webhop.org/
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to