Advertisement
Al99

TextureManager.h

Nov 11th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #ifndef __TextureManager__
  2. #define __TextureManager__
  3.  
  4. #include<SDL2/SDL.h>
  5. #include<SDL2/SDL_image.h>
  6. #include <iostream>
  7. #include <string>
  8. #include <map>
  9.  
  10. class TextureManager
  11. {
  12.     public:
  13.    
  14. static TextureManager* Instance()
  15. {  
  16.         if(s_pInstance == 0)
  17.         {
  18.             s_pInstance = new TextureManager();
  19.             return s_pInstance;
  20.         }
  21.        
  22.         return s_pInstance;
  23. }
  24.    
  25. bool load(std::string fileName, std::string id, SDL_Renderer* pRenderer);
  26.  
  27. //draw
  28. void draw(std::string id, int x, int y, int width, int height,
  29. SDL_Renderer* pRenderer, SDL_RendererFlip flip = SDL_FLIP_NONE);
  30.  
  31. //drawframe
  32. void drawFrame(std::string id, int x, int y, int width, int height,
  33. int currentRow, int currentFrame, SDL_Renderer* pRenderer,
  34. SDL_RendererFlip flip = SDL_FLIP_NONE);
  35.    
  36.     private:
  37.    
  38.     TextureManager() {}
  39.    
  40.     std::map<std::string, SDL_Texture*> m_textureMap;
  41.        
  42.     static TextureManager* s_pInstance;
  43.  
  44. };
  45.  
  46. typedef TextureManager TheTextureManager;
  47.  
  48. #endif /* defined (TextureManager */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement