1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __C_GUI_SPRITE_BANK_H_INCLUDED__
\r
6 #define __C_GUI_SPRITE_BANK_H_INCLUDED__
\r
8 #include "IrrCompileConfig.h"
\r
9 #include "IGUISpriteBank.h"
\r
23 class IGUIEnvironment;
\r
25 //! Sprite bank interface.
\r
26 class CGUISpriteBank : public IGUISpriteBank
\r
30 CGUISpriteBank(IGUIEnvironment* env);
\r
31 virtual ~CGUISpriteBank();
\r
33 core::array< core::rect<s32> >& getPositions() override;
\r
34 core::array< SGUISprite >& getSprites() override;
\r
36 u32 getTextureCount() const override;
\r
37 video::ITexture* getTexture(u32 index) const override;
\r
38 void addTexture(video::ITexture* texture) override;
\r
39 void setTexture(u32 index, video::ITexture* texture) override;
\r
41 //! Add the texture and use it for a single non-animated sprite.
\r
42 s32 addTextureAsSprite(video::ITexture* texture) override;
\r
44 //! clears sprites, rectangles and textures
\r
45 void clear() override;
\r
47 //! Draws a sprite in 2d with position and color
\r
48 virtual void draw2DSprite(u32 index, const core::position2di& pos, const core::rect<s32>* clip=0,
\r
49 const video::SColor& color= video::SColor(255,255,255,255),
\r
50 u32 starttime=0, u32 currenttime=0, bool loop=true, bool center=false) override;
\r
52 //! Draws a sprite in 2d with destination rectangle and colors
\r
53 virtual void draw2DSprite(u32 index, const core::rect<s32>& destRect,
\r
54 const core::rect<s32>* clip=0,
\r
55 const video::SColor * const colors=0,
\r
57 bool loop=true) override;
\r
59 //! Draws a sprite batch in 2d using an array of positions and a color
\r
60 virtual void draw2DSpriteBatch(const core::array<u32>& indices, const core::array<core::position2di>& pos,
\r
61 const core::rect<s32>* clip=0,
\r
62 const video::SColor& color= video::SColor(255,255,255,255),
\r
63 u32 starttime=0, u32 currenttime=0,
\r
64 bool loop=true, bool center=false) override;
\r
68 inline u32 getFrameNr(u32 index, u32 time, bool loop) const
\r
71 if (Sprites[index].frameTime && Sprites[index].Frames.size() )
\r
73 u32 f = (time / Sprites[index].frameTime);
\r
75 frame = f % Sprites[index].Frames.size();
\r
77 frame = (f >= Sprites[index].Frames.size()) ? Sprites[index].Frames.size()-1 : f;
\r
84 core::array<core::position2di> positions;
\r
85 core::array<core::recti> sourceRects;
\r
89 core::array<SGUISprite> Sprites;
\r
90 core::array< core::rect<s32> > Rectangles;
\r
91 core::array<video::ITexture*> Textures;
\r
92 IGUIEnvironment* Environment;
\r
93 video::IVideoDriver* Driver;
\r
97 } // end namespace gui
\r
98 } // end namespace irr
\r
100 #endif // __C_GUI_SPRITE_BANK_H_INCLUDED__
\r