resource manager, what to use as a Key?

Started by
2 comments, last by Endurion 16 years, 1 month ago
What should I use as a key for a resource manager? Currently, I am using the filename as the map key. However how do resource manager handles resource like textures? The problem I have is a same texture(Texture-A), can be loaded with different parameters. e.g Step 1. ResMgr load Texture-A with mipmap. Step 2. ResMgr load Texture-A with colorkey. If I am to just use the filename as a Key for the resource manager, when I choose to load Texture-A the second time, it will signal that it was already loaded and return the texture. However the return texture is the wrongly created texture. How should I solve this? Should I make all possible parameters as a key instead?
Advertisement
When you load it with different parameters are you going to reload the file? Why not use an int. the resource manager could keep a static int and just one up it every time it needs a new key.
I currently use a simple string key for the resource label. It might get changed to an int or enum later if the checking proves too ponderous, but at the moment it's readable, flexible and simple.

The string maps to a definition which determines loading mechanism and acts as the storage key.
I chose the pragmatic approach:
I converted the relevant parameters to string and added them onto the filename.

Since this only happens on loadup time there's not any noticable slowdown.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement