Hi Jim,

It could be that your databases have the UnrefImageAfterApply enabled
on them which is causing the loaded database to release imagery.  You
can run the Optimizer::TextureVisitor to change the value back, just
have a look at the option for it in the include/osgUtil/Optimizer
header.

Another snippet for you is that is you enable the new texture pool
then UnrefImageAfterApply is automatically disabled so no matter what
you set osg::Texture* never releases the imagery.

Robert.

On Fri, Jan 15, 2010 at 5:10 PM, Jim Brooks <[email protected]> wrote:
> Hi Robert,
>
> Yes, the program was first rendering, then dumping, the scene-graph.
>
> Neither pager->setUnrefImageDataAfterApplyPolicy()
> nor export OSG_OPTIMIZER=OFF helped.
>
> My program has procedurally-generated textures that are large,
> so OSG freeing them makes sense.
>
> The solution I found is to:
>
> 1. The app has to write procedural textures to files (.png),
>   so that they'll be referenced in the dumped .osg file.
>
>   image->setFileName( textureName );
>   osgDB::writeImageFile( *image, textureName );
>
> 2. Dump the scene-graph BEFORE rendering it.
>
>   If rendered first, textures will be lost regardless (why?).
>
>   This is why (the texture : file association is lost):
>
>   Texture2D {
>      name "terrain_texture"
>    < file "terrain_texture.png"
>      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>      [line will be omitted if rendered prior]
>
>
>> Are loading the scene, rendering and then writing out the scene graph?
>>
>>  If so then it's likely that your scene graph as the Texture
>> UnrefImageAfterApply enabled on them so that once the image data is
>> downloaded to OpenGL the images get discarded so there's no handle to
>> write them out to disk any more.
>>
>> By default this feature is off, but the osgUtil::Optimizer in it's
>> default settings will enable it, so if you run the Optimzer this is
>> probably the culprit.   The DatabasePager also set up to enable this
>> feature to help keep memory usage down.
>>
>> Robert.
>>
>> On Thu, Jan 14, 2010 at 3:46 PM, Jim Brooks wrote:
>> > I'm trying to "dump" the scene-graph.
>> >
>> > osgDB::writeNodeFile() writes geometry/colors ok,
>> > but (OSG 2.9.6) omits texture objects.
>> >
>> > Eg, when running osgviewer on the dumped .osg file,
>> > textures don't appear.
>> >
>> > Is this behavior of writeNodeFile() intentional?
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to