vladkomarr

texmgr

Jan 21st, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #ifndef TEXTURE_MANAGER_HPP
  2. #define TEXTURE_MANAGER_HPP
  3.  
  4. #include <SFML/Graphics.hpp>
  5. #include <string>
  6. #include <map>
  7.  
  8. class TextureManager {
  9. private:
  10.     static TextureManager* p_instance;
  11.  
  12.     TextureManager() { }
  13.     TextureManager( const TextureManager& );
  14.     TextureManager& operator=( TextureManager& );
  15.  
  16. public:
  17.     static TextureManager* get() {
  18.         if(!p_instance)
  19.             p_instance = new TextureManager();
  20.         return p_instance;
  21.     }
  22.  
  23.     /* Add a texture from a file */
  24.     void loadTexture(const std::string& name, const std::string &filename);
  25.  
  26.     /* Translate and id into reference */
  27.     sf::Texture& getRef(const std::string& texture);
  28.  
  29. private:
  30.     /* Array of textures */
  31.     std::map<std::string, sf::Texture> textures;
  32. };
  33.  
  34.  
  35. #endif // TEXTURE_MANAGER_HPP
Advertisement
Add Comment
Please, Sign In to add comment