|
|
Over the past year I've developed a similar system in various incarnations. Its main purpose is to abstract resource loading and make it as flexible as possible. Its a somewhat complicated system and I don't have time to go over it now, but maybe I'll go into detail if this thread is still around in a couple days. Anyway, I would encourage you to go for it. Its a good idea to avoid locking yourself into specific file formats. You can even go to the point of abstracting archive formats, encryption, and compression, making them invisible to the rest of your program. I use a path to identify resources, separating each level by a slash, similar to a file-system. Archives and individual resources are treated the same, and both can return loaders for multiple contained resources depending on the file format. This way I can store resources recursively, enabling me to load, for example, a win32 bitmap from a zip file inside a unix tar archive. I avoid using the file extension to specify file format, instead examining the internal representation of the data to determine its format. Although this could potentially lead to incorrectly identified file formats, I handle errors very carefully, ensuring that the resource is not loaded unless everything is accurate. The benefit is that you can refer to a resource without knowing its extension (specific format), only based on its general resource type (image, mesh, etc).
Hopefully the above wasn't too disjointed. I'm sure there are other, possibly better, approaches. I'll try to write some more detailed information in a couple days.
|