Crazy Eddies GUI System  0.6.2
irrlichttexture.h
1 /***********************************************************************
2  filename: irrlichttexture.h
3  created: 20/7/2004
4  author: Thomas Suter
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef IRRLICHTTEXTURE_H_INCLUDED
29 #define IRRLICHTTEXTURE_H_INCLUDED
30 
31 #include "IrrlichtRendererDef.h"
32 
33 #include "CEGUIBase.h"
34 #include "CEGUIRenderer.h"
35 #include "CEGUITexture.h"
36 
37 #include <irrlicht.h>
38 
39 namespace CEGUI
40 {
41  class IRRLICHT_GUIRENDERER_API IrrlichtTexture : public Texture
42  {
43  public:
44 
45  // constructor
46  IrrlichtTexture(Renderer* r, irr::IrrlichtDevice* device);
47  // constructor with a predefined size.
48  IrrlichtTexture(Renderer* r, irr::IrrlichtDevice* dr, float size);
49 
50  // destructor
51  virtual ~IrrlichtTexture();
52 
53  // returns the irrlich texture
54  irr::video::ITexture* getTexture();
55 
56  // set the irrlicht texture
57  void setTexture(irr::video::ITexture* texture);
58 
59 
67  virtual ushort getWidth(void) const;
68 
77  virtual ushort getOriginalWidth(void) const;
78 
79  virtual float getXScale(void) const;
80 
88  virtual ushort getHeight(void) const;
89 
98  virtual ushort getOriginalHeight(void) const;
99 
100  virtual float getYScale(void) const;
101 
115  virtual void loadFromFile(const String& filename, const String& resourceGroup);
116 
117 
137  virtual void loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight, PixelFormat pixelFormat);
138 
139  private:
140 
141  // counter for unique texture names
142  static int iTextureNumber;
143 
144  // generate a unique name
145  static irr::core::stringc getUniqueName(void);
146 
147  // remove the texture from irrlicht textures
148  void freeTexture();
149 
150  // updates cached scale value used to map pixels to texture co-ords.
151  void updateCachedScaleValues();
152 
153  // the current texture for rendering
154  irr::video::ITexture* tex;
155 
156  // the irrlicht video driver
157  irr::video::IVideoDriver* driver;
158 
159  // the irrlicht device
160  irr::IrrlichtDevice* device;
161 
162  // cached value for x scale
163  float xScale;
164 
165  // cahced value foy y scale
166  float yScale;
167  };
168 }
169 #endif