Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #pragma once
  2. #include "Disposable.h"
  3. #include "Texture.h"
  4. #include <vector>
  5.  
  6. class TextureBank: public Disposable
  7. {
  8. public:
  9. TextureBank();
  10. ~TextureBank();
  11.  
  12. virtual void dispose();
  13.  
  14. void addTexture(int location, Texture *tex);
  15. Texture *getTexture(int location);
  16. private:
  17. std::vector<Texture*> textures;
  18. };
  19.  
  20. #include "TextureBank.h"
  21.  
  22.  
  23. TextureBank::TextureBank()
  24. {
  25. }
  26.  
  27. void TextureBank::dispose() {
  28. for each (Texture* tex in textures)
  29. {
  30. if (tex != nullptr) {
  31. tex->dispose();
  32. }
  33. }
  34. }
  35.  
  36. void TextureBank::addTexture(int location, Texture *tex) {
  37. if (location > textures.size() - 1) {
  38. textures.resize(location + 1, nullptr);
  39. }
  40. textures[location] = tex;
  41. }
  42.  
  43. Texture *TextureBank::getTexture(int location) {
  44. return textures[location];
  45. }
  46.  
  47. TextureBank::~TextureBank()
  48. {
  49. for each (Texture* tex in textures)
  50. {
  51. if (tex != nullptr) {
  52. delete tex;
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement