Crazy Eddie's GUI System  0.8.4
Texture.h
00001 /***********************************************************************
00002     created:    Tue Mar 3 2009
00003     author:     Paul D Turner (based on original code by Thomas Suter)
00004 *************************************************************************/
00005 /***************************************************************************
00006  *   Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
00007  *
00008  *   Permission is hereby granted, free of charge, to any person obtaining
00009  *   a copy of this software and associated documentation files (the
00010  *   "Software"), to deal in the Software without restriction, including
00011  *   without limitation the rights to use, copy, modify, merge, publish,
00012  *   distribute, sublicense, and/or sell copies of the Software, and to
00013  *   permit persons to whom the Software is furnished to do so, subject to
00014  *   the following conditions:
00015  *
00016  *   The above copyright notice and this permission notice shall be
00017  *   included in all copies or substantial portions of the Software.
00018  *
00019  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00020  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00021  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00022  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00023  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00024  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00025  *   OTHER DEALINGS IN THE SOFTWARE.
00026  ***************************************************************************/
00027 #ifndef _CEGUIIrrlichtTexture_h_
00028 #define _CEGUIIrrlichtTexture_h_
00029 
00030 #include "CEGUI/RendererModules/Irrlicht/RendererDef.h"
00031 #include "../../Texture.h"
00032 #include "CEGUI/RendererModules/Irrlicht/Renderer.h"
00033 #include <string>
00034 
00035 namespace irr
00036 {
00037 namespace video
00038 {
00039 class ITexture;
00040 }
00041 }
00042 
00043 // Start of CEGUI namespace section
00044 namespace CEGUI
00045 {
00046 class IrrlichtRenderer;
00047 
00049 class IRR_GUIRENDERER_API IrrlichtTexture : public Texture
00050 {
00051 public:
00053     void setIrrlichtTexture(irr::video::ITexture* tex);
00054 
00056     irr::video::ITexture* getIrrlichtTexture() const;
00057 
00065     void setOriginalDataSize(const Sizef& sz);
00066 
00068     static std::string getUniqueName();
00069 
00070     // Implement texture interface.
00071     const String& getName() const;
00072     const Sizef& getSize() const;
00073     const Sizef& getOriginalDataSize() const;
00074     const Vector2f& getTexelScaling() const;
00075     void loadFromFile(const String& filename, const String& resourceGroup);
00076     void loadFromMemory(const void* buffer, const Sizef& buffer_size,
00077                         PixelFormat pixel_format);
00078     void blitFromMemory(const void* sourceData, const Rectf& area);
00079     void blitToMemory(void* targetData);
00080     bool isPixelFormatSupported(const PixelFormat fmt) const;
00081 
00082 protected:
00083     // friends in order that Renderer module can create / destroy textures
00084     friend Texture& IrrlichtRenderer::createTexture(const String&);
00085     friend Texture& IrrlichtRenderer::createTexture(const String&, const String&,
00086                                                     const String&);
00087     friend Texture& IrrlichtRenderer::createTexture(const String&, const Sizef&);
00088     friend void IrrlichtRenderer::destroyTexture(Texture&);
00089     friend void IrrlichtRenderer::destroyTexture(const String&);
00090 
00092     IrrlichtTexture(IrrlichtRenderer& owner, irr::video::IVideoDriver& driver,
00093                     const String& name);
00095     IrrlichtTexture(IrrlichtRenderer& owner, irr::video::IVideoDriver& driver,
00096                     const String& name, const String& filename,
00097                     const String& resourceGroup);
00099     IrrlichtTexture(IrrlichtRenderer& owner, irr::video::IVideoDriver& driver,
00100                     const String& name, const Sizef& size);
00102     ~IrrlichtTexture();
00103 
00105     void createIrrlichtTexture(const Sizef& sz);
00106 
00108     void freeIrrlichtTexture();
00109 
00111     void updateCachedScaleValues();
00112 
00114     static uint32 d_textureNumber;
00116     irr::video::IVideoDriver& d_driver;
00118     irr::video::ITexture* d_texture;
00120     Sizef d_size;
00122     Sizef d_dataSize;
00124     Vector2f d_texelScaling;
00126     IrrlichtRenderer& d_owner;
00128     const String d_name;
00129 };
00130 
00131 } // End of  CEGUI namespace section
00132 
00133 #endif  // end of guard _CEGUIIrrlichtTexture_h_
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends