Hi Sekunder,

I've been digging around in the osgDB code and I'm pretty sure that the osgDB 
cache only stores the osg::Image file in memory rather than the osg::Texture. I 
noted that glBindTexture is only called within osg::Texture so that is where 
the texture is loaded onto the card. At the moment all I've set the cache to 
store are images, as model caching isn't needed. But I don't think the osgDB 
parses cached models for duplicate osg::Textures only duplicate osg::Images.

Perhaps Robert could confirm?



Kim.



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sukender
Sent: 20 November 2008 08:54
To: OpenSceneGraph Users
Subject: Re: [osg-users] Texture Management BUMP

Hi Kim,

Well, if you "load" a model with its textures, the function will simply return 
to you a pointer to an already existing model and/or texture (if cache is 
enabled). Then if all models of your scene share the same texture and/or vertex 
arrays, I guess (I'm not 100% sure though) this will do what you expect: 
texture and/or vertex array are only sent to video memory once.

Also be sure to create COPIES of the vertex arrays, matrix transforms (and 
other things) if you plan to modify them. Else you would modify the cached 
shared ressource (this happened to me! I saw all my models being transformed 
the same way at the same time...).

Anyway, caching is a good thing for performance and RAM usage if your models or 
textures are duplicated in the scene.

Sukender
PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/


Le Thu, 20 Nov 2008 08:36:31 +0100, Kim C Bale <[EMAIL PROTECTED]> a écrit:

> I've been pondering this Database pager. It only caches the image files into 
> memory to prevent loading during runtime doesn't it? Those are then used to 
> build textures on the card memory.
> 
> Is there anything to deal with loading textures onto the graphics card, 
> dishing out texture IDs rather than reloading the texture onto card memory?
> 
> Kim.
>
> ________________________________
>
> From: [EMAIL PROTECTED] on behalf of Sukender
> Sent: Wed 19/11/2008 15:53
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] Texture Management
>
>
>
> Hi Kim,
>
> You may just use the osgDB::Registry cache. That's automatic :)
> For instance, set the cache by writing:
>         osgDB::ReaderWriter::Options* rwoptions = new 
> osgDB::ReaderWriter::Options;
>         
> rwoptions->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_ALL);
>         osgDB::Registry::instance()->setOptions(rwoptions);
>
> This will cache everything loaded with readNodeFile() or readImageFile().
> For my use, I preload things in the cache by calling:
>         osgDB::Registry::instance()->addEntryToObjectCache(path, 
> osgDB::readNodeFile(path));
>
> And I set the cache to never unload:
>         osgDB::DatabasePager * pPager = viewer.getDatabasePager();
>         assert(pPager);
>         osgDB::Registry::instance()->setDatabasePager(pPager);
>         pPager->setExpiryDelay(DBL_MAX);
>         pPager->setExpiryFrames(INT_MAX);
>
> Also, you could clear the cache by calling:
>         osgDB::Registry::instance()->clearObjectCache();
>
> Hope it will help.
>
> Sukender
> PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/
>
>
> Le Wed, 19 Nov 2008 16:28:25 +0100, Kim C Bale <[EMAIL PROTECTED]> a écrit:
>
>> I have a number of different models in OSG format that all use the same
>> texture.
>>
>>
>>
>> What I want to avoid is having duplicate textures loaded onto the
>> graphics card when I load these separate models. In previous programs I
>> have achieved this using a Texture Manager that manages all texture
>> loading i.e. loading the texture once when required and then dishing out
>> the texture ID on subsequent requests. A fairly standard practice.
>>
>>
>>
>> Is there something similar already built into the OSG? The
>> TextureAtlasBuilder in osgUtil sounds looks like it might do something
>> similar but I'm not 100% sure, there is very little documentation on it.
>>
>>
>>
>> Thanks all.
>>
>>
>> Kim.
>
> _______________________________________________
> 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
*****************************************************************************************
To view the terms under which this email is distributed, please go to 
http://www.hull.ac.uk/legal/email_disclaimer.html
*****************************************************************************************
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to