diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CGUIImageList.cpp')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CGUIImageList.cpp | 186 |
1 files changed, 93 insertions, 93 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CGUIImageList.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CGUIImageList.cpp index e02030d..1ef2c5a 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CGUIImageList.cpp +++ b/libraries/irrlicht-1.8/source/Irrlicht/CGUIImageList.cpp | |||
@@ -1,93 +1,93 @@ | |||
1 | // This file is part of the "Irrlicht Engine". | 1 | // This file is part of the "Irrlicht Engine". |
2 | // written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de | 2 | // written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de |
3 | // modified by Thomas Alten | 3 | // modified by Thomas Alten |
4 | 4 | ||
5 | #include "CGUIImageList.h" | 5 | #include "CGUIImageList.h" |
6 | 6 | ||
7 | 7 | ||
8 | namespace irr | 8 | namespace irr |
9 | { | 9 | { |
10 | namespace gui | 10 | namespace gui |
11 | { | 11 | { |
12 | 12 | ||
13 | //! constructor | 13 | //! constructor |
14 | CGUIImageList::CGUIImageList( video::IVideoDriver* driver ) | 14 | CGUIImageList::CGUIImageList( video::IVideoDriver* driver ) |
15 | : Driver( driver ), | 15 | : Driver( driver ), |
16 | Texture( 0 ), | 16 | Texture( 0 ), |
17 | ImageCount( 0 ), | 17 | ImageCount( 0 ), |
18 | ImageSize( 0, 0 ), | 18 | ImageSize( 0, 0 ), |
19 | ImagesPerRow( 0 ), | 19 | ImagesPerRow( 0 ), |
20 | UseAlphaChannel( false ) | 20 | UseAlphaChannel( false ) |
21 | { | 21 | { |
22 | #ifdef _DEBUG | 22 | #ifdef _DEBUG |
23 | setDebugName( "CGUIImageList" ); | 23 | setDebugName( "CGUIImageList" ); |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | if( Driver ) | 26 | if( Driver ) |
27 | { | 27 | { |
28 | Driver->grab(); | 28 | Driver->grab(); |
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | 32 | ||
33 | 33 | ||
34 | //! destructor | 34 | //! destructor |
35 | CGUIImageList::~CGUIImageList() | 35 | CGUIImageList::~CGUIImageList() |
36 | { | 36 | { |
37 | if( Driver ) | 37 | if( Driver ) |
38 | { | 38 | { |
39 | Driver->drop(); | 39 | Driver->drop(); |
40 | } | 40 | } |
41 | 41 | ||
42 | if( Texture ) | 42 | if( Texture ) |
43 | { | 43 | { |
44 | Texture->drop(); | 44 | Texture->drop(); |
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 | ||
48 | 48 | ||
49 | //! Creates the image list from texture. | 49 | //! Creates the image list from texture. |
50 | bool CGUIImageList::createImageList(video::ITexture* texture, | 50 | bool CGUIImageList::createImageList(video::ITexture* texture, |
51 | core::dimension2d<s32> imageSize, | 51 | core::dimension2d<s32> imageSize, |
52 | bool useAlphaChannel) | 52 | bool useAlphaChannel) |
53 | { | 53 | { |
54 | if( !texture ) | 54 | if( !texture ) |
55 | { | 55 | { |
56 | return false; | 56 | return false; |
57 | } | 57 | } |
58 | 58 | ||
59 | Texture = texture; | 59 | Texture = texture; |
60 | Texture->grab(); | 60 | Texture->grab(); |
61 | 61 | ||
62 | ImageSize = imageSize; | 62 | ImageSize = imageSize; |
63 | 63 | ||
64 | ImagesPerRow = Texture->getSize().Width / ImageSize.Width; | 64 | ImagesPerRow = Texture->getSize().Width / ImageSize.Width; |
65 | ImageCount = ImagesPerRow * Texture->getSize().Height / ImageSize.Height; | 65 | ImageCount = ImagesPerRow * Texture->getSize().Height / ImageSize.Height; |
66 | 66 | ||
67 | UseAlphaChannel = useAlphaChannel; | 67 | UseAlphaChannel = useAlphaChannel; |
68 | 68 | ||
69 | return true; | 69 | return true; |
70 | } | 70 | } |
71 | 71 | ||
72 | //! Draws an image and clips it to the specified rectangle if wanted | 72 | //! Draws an image and clips it to the specified rectangle if wanted |
73 | void CGUIImageList::draw( s32 index, const core::position2d<s32>& destPos, | 73 | void CGUIImageList::draw( s32 index, const core::position2d<s32>& destPos, |
74 | const core::rect<s32>* clip /*= 0*/ ) | 74 | const core::rect<s32>* clip /*= 0*/ ) |
75 | { | 75 | { |
76 | core::rect<s32> sourceRect; | 76 | core::rect<s32> sourceRect; |
77 | 77 | ||
78 | if( !Driver || index < 0 || index >= ImageCount ) | 78 | if( !Driver || index < 0 || index >= ImageCount ) |
79 | { | 79 | { |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | 82 | ||
83 | sourceRect.UpperLeftCorner.X = ( index % ImagesPerRow ) * ImageSize.Width; | 83 | sourceRect.UpperLeftCorner.X = ( index % ImagesPerRow ) * ImageSize.Width; |
84 | sourceRect.UpperLeftCorner.Y = ( index / ImagesPerRow ) * ImageSize.Height; | 84 | sourceRect.UpperLeftCorner.Y = ( index / ImagesPerRow ) * ImageSize.Height; |
85 | sourceRect.LowerRightCorner.X = sourceRect.UpperLeftCorner.X + ImageSize.Width; | 85 | sourceRect.LowerRightCorner.X = sourceRect.UpperLeftCorner.X + ImageSize.Width; |
86 | sourceRect.LowerRightCorner.Y = sourceRect.UpperLeftCorner.Y + ImageSize.Height; | 86 | sourceRect.LowerRightCorner.Y = sourceRect.UpperLeftCorner.Y + ImageSize.Height; |
87 | 87 | ||
88 | Driver->draw2DImage( Texture, destPos, sourceRect, clip, | 88 | Driver->draw2DImage( Texture, destPos, sourceRect, clip, |
89 | video::SColor( 255, 255, 255, 255 ), UseAlphaChannel ); | 89 | video::SColor( 255, 255, 255, 255 ), UseAlphaChannel ); |
90 | } | 90 | } |
91 | 91 | ||
92 | } // end namespace gui | 92 | } // end namespace gui |
93 | } // end namespace irr | 93 | } // end namespace irr |