Maybe you're looking for different things in a resource manager than me =P
My goal with this was to be able to load all resources at the very beginning, then not have to worry about their cleanup/scope/filepath later. |
Loading all resources at the beginning isn't necessarily a good thing. Especially not for larger projects. If you have a lot of resources, loading all of them would cause a long load time at the beginning program and would use tons of memory.
I've found that it's better to load resources as you need them, rather than all at once. At long as the resource isn't loaded during something time-critical (I usually like to load mine "between screens"). If done that way, loading is fast enough to appear instantaneous to the user as long as you don't have to load a bunch all at once.
As for specifying a separate "key" for which to access the resource (like your "Chimes" / "Spaceship"), this seems like extra work to me. Why not just use the path+filename as the key and save yourself a step?
I really am curious to see how you could implement that sort of GetImage function, since if the function failed to find the image, I don't know how you could have it load and return the correct image. |
It's not hard if you use the path+filename as the key:
GetImage("mypath/myfile.png");
If you don't want to deal with full paths, then make it a constant that's defined elsewhere:
Get(Resource::Chimes);
where Resource::Chimes == "src/mus/chimes.wav"