Let's assume for the sake of argument, that we have a resource engine in place, and that we use OpenGL. My question is how the engine/game classes should reference the resources.
Lightweight example : among others, we probably have a texture resource. If we now have a class that uses this resource, do we store:
- a resource id?
- a resource pointer?
- the resultant resource (e.g. the GLID of the Texture)
1 gives us the most flexibility, and neat features like being able to reload all textures on the fly (after context destruction), but costs us a lookup each time it is used, and might require a mutex lock.
Another example - a font resource, same questions -- do we hold an id, pointer or a direct font class?
Third example, a model resource has a reference to a texture it uses. Does it store id, pointer or direct link?
If the answers differ between uses, is there a sensible set of rules one can follow to decide what should be used in what case?
EDIT: we're talking about a general use, heavy duty (3d, streaming, resource groups, memory managing) resource manager here in a threaded environment.