enabling image cache

64 views
Skip to first unread message

Trajce Nikolov NICK

unread,
Aug 1, 2020, 11:05:47 AM8/1/20
to osg-...@googlegroups.com, OpenSceneGraph Users
Hi Community,

I have two different files sharing an image. is there a way to cache (without extra coding) the shared resource? for example

osgviewer file1 file2 

and the image to be loaded once and reused later?

Thanks a bunch as always!

Cheers,
Nick

--
trajce nikolov nick

OpenSceneGraph Users

unread,
Aug 2, 2020, 4:34:27 AM8/2/20
to OpenSceneGraph Users
HI Nick,

The osgDB::ObjectCache can be used to share loaded data, so if the images are loaded from external files this will ensure the data gets shared.

There is also the utility for sharing state at runtime, but I don't recall it's name.

In each of these cases there is a limit to what it'll figure out as shared, none of them look at the internal data.

In the VulkanSceneGraph I have implemented the ability to place objects that you wish to share into a vsg::Objects container that you can place in an external file, then the model scenes then reference this with the a cache ensuring that the vsg::Object container is only loaded once and shared there after.  The scheme is able to connect all the object IDs together so everything is consistent.  This scheme only works with native VSG scene graphs as they obviously have to know about the scheme.

I mention the VSG approach as it should be possible to do something similar with the OSG, as the OSG has, in principle, most of the required IO features.

Robert.

Per Nordqvist

unread,
Aug 2, 2020, 12:02:02 PM8/2/20
to osg-...@googlegroups.com
Here is a snippet from osgcatch.cpp:

    // enable the image cache so we don't need to keep loading the particle files
    osgDB::ReaderWriter::Options* options = new osgDB::ReaderWriter::Options;
    options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_IMAGES);
    osgDB::Registry::instance()->setOptions(options);

But I haven't tried it myself.

Regards,
Per



--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/CAO-%2BzikVOcbto4u832jz-wC%2BqoU3NJi09drbhzSmuVDgf5cEMw%40mail.gmail.com.

OpenSceneGraph Users

unread,
Aug 5, 2020, 8:04:40 AM8/5/20
to OpenSceneGraph Users
thanks Per !

On Sun, Aug 2, 2020 at 6:10 PM OpenSceneGraph Users <osg-...@lists.openscenegraph.org> wrote:
Here is a snippet from osgcatch.cpp:

    // enable the image cache so we don't need to keep loading the particle files
    osgDB::ReaderWriter::Options* options = new osgDB::ReaderWriter::Options;
    options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_IMAGES);
    osgDB::Registry::instance()->setOptions(options);

But I haven't tried it myself.

Regards,
Per



On Sat, 1 Aug 2020 at 17:05, Trajce Nikolov NICK <trajce.ni...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/CAO-%2BzikVOcbto4u832jz-wC%2BqoU3NJi09drbhzSmuVDgf5cEMw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+...@googlegroups.com.


--
trajce nikolov nick

Trajce Nikolov NICK

unread,
Aug 5, 2020, 8:04:45 AM8/5/20
to osg-...@googlegroups.com
Thanks Robert!

--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+...@googlegroups.com.

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+...@googlegroups.com.


--
trajce nikolov nick
Reply all
Reply to author
Forward
0 new messages