1
General / Thor ResourceCache access
« on: August 30, 2014, 04:27:47 am »
I have a question about the proper way to use the resource management system found in the Thor library. The examples I have found have used ResourceCache and ResourceKey in the same scope- but what if I want to be able to access the resources stored in the ResourceCache in a different function?
For example, I have a class that has a private member mTextures, which is a thor::ResourceCache<sf::Texture>.
I have a function, loadResources, that is:
And then, in the buildScene function, I want to access the texture referenced by TextureBack, like so:
But the compiler doesn't know what TextureBack is, because it is in a different scope. What is the proper way to access the resource management system from other parts of the function, or from other functions, if I have passed a reference to the ResourceCache through?
Thank you for your help in advance (and also thanks to those who work so hard to make us such cool libraries!)
For example, I have a class that has a private member mTextures, which is a thor::ResourceCache<sf::Texture>.
I have a function, loadResources, that is:
void Round::loadResourses()
{
thor::ResourceKey<sf::Texture> TextureBack = thor::Resources::fromFile<sf::Texture>("Media/Textures/Back.png");
mTextures.acquire(TextureBack);
}
{
thor::ResourceKey<sf::Texture> TextureBack = thor::Resources::fromFile<sf::Texture>("Media/Textures/Back.png");
mTextures.acquire(TextureBack);
}
And then, in the buildScene function, I want to access the texture referenced by TextureBack, like so:
std::shared_ptr<sf::Texture> background = mTextures.search(TextureBack);
But the compiler doesn't know what TextureBack is, because it is in a different scope. What is the proper way to access the resource management system from other parts of the function, or from other functions, if I have passed a reference to the ResourceCache through?
Thank you for your help in advance (and also thanks to those who work so hard to make us such cool libraries!)