Skip to main content
2 of 4
added 62 characters in body
McLovin
  • 461
  • 1
  • 5
  • 14

Resource management questions

Say I have this Cache<typename Resource> class template, which is a resource cache that contains an std::map<std::string, Resource>, mapping strings to resources.

I can many different kinds of resources: sounds, textures, geometry etc. So I need to have something like a container of all of these caches:

struct ResourceManager { Cache<Sound*> _soundCache; Cache<Mesh*> _meshCache; Cache<Texture2D> _textureCache; }; 

A Mesh object might need to query Texture objects from the texture cache, so working with these caches is possible in two ways: Either pass a pointer to _textureCache to every Mesh object, perhaps via its constructor (this approach is pretty clumsy), or define a ResourceManager object globally, so every class can use its caches all the time.

Has this issue ever been brought up for discussion? How should I deal with it?

What do most engines do? Where do they store these caches?

McLovin
  • 461
  • 1
  • 5
  • 14