I have different kinds of resources. There are OpenGL resources that some of them are too "small" and don't really need a cache system (correct me if I'm wrong), like buffer objects (opengl also pretty much manages them by itself), but others definitely need a cache system, like shader programs and textures. I also have Image objects, mesh geometry and what not.
1. Obviously each resource is loaded separately and works differently, so I'm not sure if I have to create a generic cache class for all of them. I'm talking about something like this:
Cache<Sound*> _soundCache;Cache<Mesh*> _meshCache;Cache<Texture2D*> _textureCache;
Also some people say I should have a "ResourceLoader" class that manages loading from disk. The thing is that some resources like meshes and images are loaded from disk with a different library. For PNG images for example I use libpng, which manages loading .png images by itself. How am I supposed to encapsulate this inside a ResourceLoader class?2. My second and more important question should be pretty simple but I find it very hard to answer.
Say I have this final GameEngine class. Where do I to put all the resource caches? Do they need to be private data members in GameEngine?
If the answer is yes, then obviously a Mesh resource will need a pointer to the Texture cache, because it loads textures. That means I have to pass pointers through classes all day long.
What options do I have here? What's the most viable approach?