Resource Loading & Linking

Started by
2 comments, last by Prozak 19 years, 10 months ago
Hi, Im trying to design a system that seperates resource loading from resource linking. When I say resource, i mean the "atomic" pieces an engine uses, like meshes, sounds, textures, etc. A Resource Load function is responsible for loading those pieces, like a mesh, while a resource linking function would be responsible for piecing together the apropriate pieces, to generate a working "object". If I use mesh A plus texture B plus sound C, then I have successfuly organized into a hierarchical structure the atomic resources, and created an object. The problem arises from the fact that when I load up file A, some of its resources may be used by file B, so the linking must not be done cleverly... Im not looking for a solution to my specific problem, more, looking for how others have dealt with this... [Edited by - Prozak on June 15, 2004 8:05:52 AM]
Advertisement
anyone?
You could use a set of managers for the different resource types, like for example a sound manager and a texture manager. Whenever you load a resource, you add it to a list in the manager, and set a counter for that resource to one. Then, when you try to load the same resource again, just increase the counter instead, and reuse the original one.
When releasing the resources, decrease the reference count and only unload the resource if the counter hits zero.
~neoztar "Any lock can be picked with a big enough hammer"my website | opengl extensions | try here firstguru of the week | msdn library | c++ faq lite
No, im not talking about not reloading already in memory resources...

...im talking about linking resources loaded from diferent files.

Wild example:

You have your model's head from a Quake 3 model file, and the rest of the body from an Unreal model file, and textures in yyy format.

Now, you need an importer for:
- Quake 3 Models
- Unreal Models
- YYY Image File Format

And then, to construct your model, you need a "linker" function, that links the apropriate body parts into an hierarchical structure, and assigns the texture IDs....

So, my question is, how to achive independence between resource loading and resource linking...

This topic is closed to new replies.

Advertisement