in my Engine I have a ResourceManager class, that loads resources (textures, shaders, materials etc.) from hard drive and caches them. I.e:
ShaderPtr p1 = manager->loadShader("Color.psh");
...
ShaderPtr p2 = manager->loadShader("Color.psh");
When shader Color.psh is loaded from the first time, it is loaded from hard drive, a ShaderPtr is stored in a map and returned. Now when Color.psh is requested for the second time, the Shader is just returned from the cache map instead of loading it again.This works fine, but now I have a problem with textures. I have to pass the size of the texture to the load function, because internally I use D3DXCreateTextureFromFileEx() to load the texture and If I do not explicitely specify the real size of the texture, DirectX will use the next power of 2 size - something I do not want.
So my loading looks like this:
TexturePtr t1 = manager->loadTexture("Grass.png", 500, 200); // A
...
TexturePtr t2 = manager->loadTexture("Grass.png", 300, 300); // B
In line A the manager really loads Grass.png from the disk and creates a texture of size 500x200. Now in line B the manager detects that Grass.png is already loaded and just returns a reference to the already created texture of size 500x200. Thus t2 now stores a texture object with size of 500x200, even though I wanted the texture to be loaded with a size of 300x300! (In other words: Another instance with another size).Do you guys have an idea how I could solve this problem? How I could keep a caching system but also support resources with different values.
Thanks!






