00001 /*********************************************************************** 00002 filename: irrlichttexture.h 00003 created: 20/7/2004 00004 author: Thomas Suter 00005 *************************************************************************/ 00006 /*************************************************************************** 00007 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining 00010 * a copy of this software and associated documentation files (the 00011 * "Software"), to deal in the Software without restriction, including 00012 * without limitation the rights to use, copy, modify, merge, publish, 00013 * distribute, sublicense, and/or sell copies of the Software, and to 00014 * permit persons to whom the Software is furnished to do so, subject to 00015 * the following conditions: 00016 * 00017 * The above copyright notice and this permission notice shall be 00018 * included in all copies or substantial portions of the Software. 00019 * 00020 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00021 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00022 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00023 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00024 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00025 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00026 * OTHER DEALINGS IN THE SOFTWARE. 00027 ***************************************************************************/ 00028 #ifndef IRRLICHTTEXTURE_H_INCLUDED 00029 #define IRRLICHTTEXTURE_H_INCLUDED 00030 00031 #include "IrrlichtRendererDef.h" 00032 00033 #include "CEGUIBase.h" 00034 #include "CEGUIRenderer.h" 00035 #include "CEGUITexture.h" 00036 00037 #include <irrlicht.h> 00038 00039 namespace CEGUI 00040 { 00041 class IRRLICHT_GUIRENDERER_API IrrlichtTexture : public Texture 00042 { 00043 public: 00044 00045 // constructor 00046 IrrlichtTexture(Renderer* r, irr::IrrlichtDevice* device); 00047 // constructor with a predefined size. 00048 IrrlichtTexture(Renderer* r, irr::IrrlichtDevice* dr, float size); 00049 00050 // destructor 00051 virtual ~IrrlichtTexture(); 00052 00053 // returns the irrlich texture 00054 irr::video::ITexture* getTexture(); 00055 00056 // set the irrlicht texture 00057 void setTexture(irr::video::ITexture* texture); 00058 00059 00067 virtual ushort getWidth(void) const; 00068 00077 virtual ushort getOriginalWidth(void) const; 00078 00079 virtual float getXScale(void) const; 00080 00088 virtual ushort getHeight(void) const; 00089 00098 virtual ushort getOriginalHeight(void) const; 00099 00100 virtual float getYScale(void) const; 00101 00115 virtual void loadFromFile(const String& filename, const String& resourceGroup); 00116 00117 00137 virtual void loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight, PixelFormat pixelFormat); 00138 00139 private: 00140 00141 // counter for unique texture names 00142 static int iTextureNumber; 00143 00144 // generate a unique name 00145 static irr::core::stringc getUniqueName(void); 00146 00147 // remove the texture from irrlicht textures 00148 void freeTexture(); 00149 00150 // updates cached scale value used to map pixels to texture co-ords. 00151 void updateCachedScaleValues(); 00152 00153 // the current texture for rendering 00154 irr::video::ITexture* tex; 00155 00156 // the irrlicht video driver 00157 irr::video::IVideoDriver* driver; 00158 00159 // the irrlicht device 00160 irr::IrrlichtDevice* device; 00161 00162 // cached value for x scale 00163 float xScale; 00164 00165 // cahced value foy y scale 00166 float yScale; 00167 }; 00168 } 00169 #endif