IGUISpriteBank.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef __I_GUI_SPRITE_BANK_H_INCLUDED__
  5. #define __I_GUI_SPRITE_BANK_H_INCLUDED__
  6. #include "IReferenceCounted.h"
  7. #include "irrArray.h"
  8. #include "SColor.h"
  9. #include "rect.h"
  10. namespace irr
  11. {
  12. namespace video
  13. {
  14. class ITexture;
  15. } // end namespace video
  16. namespace gui
  17. {
  18. //! A single sprite frame.
  19. struct SGUISpriteFrame
  20. {
  21. u32 textureNumber;
  22. u32 rectNumber;
  23. };
  24. //! A sprite composed of several frames.
  25. struct SGUISprite
  26. {
  27. SGUISprite() : Frames(), frameTime(0) {}
  28. core::array<SGUISpriteFrame> Frames;
  29. u32 frameTime;
  30. };
  31. //! Sprite bank interface.
  32. /** See http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=25742&highlight=spritebank
  33. * for more information how to use the spritebank.
  34. */
  35. class IGUISpriteBank : public virtual IReferenceCounted
  36. {
  37. public:
  38. //! Returns the list of rectangles held by the sprite bank
  39. virtual core::array< core::rect<s32> >& getPositions() = 0;
  40. //! Returns the array of animated sprites within the sprite bank
  41. virtual core::array< SGUISprite >& getSprites() = 0;
  42. //! Returns the number of textures held by the sprite bank
  43. virtual u32 getTextureCount() const = 0;
  44. //! Gets the texture with the specified index
  45. virtual video::ITexture* getTexture(u32 index) const = 0;
  46. //! Adds a texture to the sprite bank
  47. virtual void addTexture(video::ITexture* texture) = 0;
  48. //! Changes one of the textures in the sprite bank
  49. virtual void setTexture(u32 index, video::ITexture* texture) = 0;
  50. //! Add the texture and use it for a single non-animated sprite.
  51. //! The texture and the corresponding rectangle and sprite will all be added to the end of each array.
  52. //! returns the index of the sprite or -1 on failure
  53. virtual s32 addTextureAsSprite(video::ITexture* texture) = 0;
  54. //! clears sprites, rectangles and textures
  55. virtual void clear() = 0;
  56. //! Draws a sprite in 2d with position and color
  57. virtual void draw2DSprite(u32 index, const core::position2di& pos,
  58. const core::rect<s32>* clip=0,
  59. const video::SColor& color= video::SColor(255,255,255,255),
  60. u32 starttime=0, u32 currenttime=0,
  61. bool loop=true, bool center=false) = 0;
  62. //! Draws a sprite batch in 2d using an array of positions and a color
  63. virtual void draw2DSpriteBatch(const core::array<u32>& indices, const core::array<core::position2di>& pos,
  64. const core::rect<s32>* clip=0,
  65. const video::SColor& color= video::SColor(255,255,255,255),
  66. u32 starttime=0, u32 currenttime=0,
  67. bool loop=true, bool center=false) = 0;
  68. };
  69. } // end namespace gui
  70. } // end namespace irr
  71. #endif // __I_GUI_SPRITE_BANK_H_INCLUDED__