Search code examples
c++resourcesshareogre3dsfml

C++, Ogre3D, SFML, sharing resources?


Is it possible to somehow share the Ogre3D resources loaded in the Ogre::ResourceManager from resources.cfg with other parts of a programm? If possible with SFML that would be nice.

I know that CEGUI, for example, can do this automatically.


Solution

  • Ogre by nature abstracts resources away from their file paths. This is because a resource may not necessarily come from the filesystem (it could be streamed over the network, or unpacked from a compressed archive). So no, without breaking encapsulation it's not possible to get the filesystem path from an Ogre resource.

    You will need to extend whatever resource system SFML has (if any, I'm not familiar with how SFML works) and then pass the resource data itself into that library. I've found that most libraries have some way of providing data to them other than via filesystem paths. If SFML doesn't have that feature, I might suggest looking into something a little bit more... complete.

    You mentioned that CEGUI does this already. That's correct. The CEGUI/Ogre interop layer builds on top of Ogre's resource handling framework to do pretty much this. It requests resources from Ogre, loads them through Ogre, and then passes the data into CEGUI. CEGUI itself never touches the filesystem.