TextureAtlas.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //================ Copyright (c) 2017, PG, All rights reserved. =================//
  2. //
  3. // Purpose: container for dynamically merging multiple images into one
  4. //
  5. // $NoKeywords: $imgtxat
  6. //===============================================================================//
  7. #ifndef TEXTUREATLAS_H
  8. #define TEXTUREATLAS_H
  9. #include "Resource.h"
  10. class Image;
  11. class TextureAtlas : public Resource {
  12. public:
  13. TextureAtlas(int width = 512, int height = 512);
  14. virtual ~TextureAtlas() { destroy(); }
  15. Vector2 put(int width, int height, Color *pixels) { return put(width, height, false, false, pixels); }
  16. Vector2 put(int width, int height, bool flipHorizontal, bool flipVertical, Color *pixels);
  17. void setPadding(int padding) { m_iPadding = padding; }
  18. inline int getWidth() const { return m_iWidth; }
  19. inline int getHeight() const { return m_iHeight; }
  20. inline Image *getAtlasImage() const { return m_atlasImage; }
  21. private:
  22. virtual void init();
  23. virtual void initAsync();
  24. virtual void destroy();
  25. int m_iPadding;
  26. int m_iWidth;
  27. int m_iHeight;
  28. Image *m_atlasImage;
  29. int m_iCurX;
  30. int m_iCurY;
  31. int m_iMaxHeight;
  32. };
  33. #endif