1
Graphics / ImageManager
« on: May 09, 2010, 01:52:07 am »
Ok, thank's! I saw in the wiki that there are allready neat implementations for resource managers 
For example: http://www.sfml-dev.org/wiki/en/sources/resource_manager
Thank you.
But anyways - would this solve the copy problem?
Are there any copy situations left?

For example: http://www.sfml-dev.org/wiki/en/sources/resource_manager
Thank you.
But anyways - would this solve the copy problem?
Are there any copy situations left?
Code: [Select]
class Image_manager
{
private:
map<string, sf::Image> image_map;
public:
const sf::Image& GetImage(string image_path) // The filename is used as a key
{
// Is this image is not loaded - load it
if(image_map.find(image_path) == image_map.end())
{
pair<string, sf::Image> path_image_pair;
path_image_pair.first = image_path;
if(!path_image_pair.second.LoadFromFile(image_path))
{
exit(EXIT_FAILURE);
}
image_map.insert( path_image_pair );
}
return image_map[image_path];
}
};