diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IGUISpriteBank.h Irrlicht_starsonata/include/IGUISpriteBank.h --- irrlicht-svn-ss/trunk/include/IGUISpriteBank.h 2007-07-26 02:11:22.000000000 +0200 +++ Irrlicht_starsonata/include/IGUISpriteBank.h 2008-04-11 11:40:44.000000000 +0200 @@ -40,6 +40,14 @@ public: //! Destructor virtual ~IGUISpriteBank() {}; + //! clears sprites, rectangles and textures + virtual void clear() = 0; + + //! Use the whole texture as one non-animated sprite + //! The texture and the corresponding rectangle and sprite will all be added to the end of each array. + //! returns the index of the sprite or -1 on failure + virtual s32 addTextureAsSprite(video::ITexture* texture) = 0; + //! Returns the list of rectangles held by the sprite bank virtual core::array< core::rect >& getPositions() = 0; diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CGUISpriteBank.cpp Irrlicht_starsonata/source/Irrlicht/CGUISpriteBank.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CGUISpriteBank.cpp 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CGUISpriteBank.cpp 2008-05-07 01:41:04.000000000 +0200 @@ -32,6 +32,42 @@ CGUISpriteBank::~CGUISpriteBank() Driver->drop(); } +//! clear everything +void CGUISpriteBank::clear() +{ + // drop textures + for (u32 i=0; idrop(); + Textures.clear(); + Sprites.clear(); + Rectangles.clear(); +} + +s32 CGUISpriteBank::addTextureAsSprite(video::ITexture* texture) +{ + if ( !texture ) + return -1; + + addTexture(texture); + u32 textureIndex = getTextureCount() - 1; + + u32 rectangleIndex = Rectangles.size(); + Rectangles.push_back( core::rect(0,0, texture->getOriginalSize().Width, texture->getOriginalSize().Height) ); + + SGUISprite sprite; + sprite.frameTime = 0; + + SGUISpriteFrame frame; + frame.textureNumber = textureIndex; + frame.rectNumber = rectangleIndex; + sprite.Frames.push_back( frame ); + + Sprites.push_back( sprite ); + + return Sprites.size() - 1; +} + core::array< core::rect >& CGUISpriteBank::getPositions() { return Rectangles; diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CGUISpriteBank.h Irrlicht_starsonata/source/Irrlicht/CGUISpriteBank.h --- irrlicht-svn-ss/trunk/source/Irrlicht/CGUISpriteBank.h 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CGUISpriteBank.h 2008-04-11 11:40:28.000000000 +0200 @@ -26,6 +26,14 @@ public: CGUISpriteBank(IGUIEnvironment* env); virtual ~CGUISpriteBank(); + //! clears sprites, rectangles and textures + virtual void clear(); + + //! Use the whole texture as one non-animated sprite + //! The texture and the corresponding rectangle and sprite will all be added to the end of each array. + //! returns the index of the sprite or -1 on failure + virtual s32 addTextureAsSprite(video::ITexture* texture); + virtual core::array< core::rect >& getPositions(); virtual core::array< SGUISprite >& getSprites();