Crazy Eddie's GUI System  0.8.7
RendererModules/Irrlicht/Texture.h
1 /***********************************************************************
2  created: Tue Mar 3 2009
3  author: Paul D Turner (based on original code by Thomas Suter)
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIIrrlichtTexture_h_
28 #define _CEGUIIrrlichtTexture_h_
29 
30 #include "CEGUI/RendererModules/Irrlicht/RendererDef.h"
31 #include "../../Texture.h"
32 #include "CEGUI/RendererModules/Irrlicht/Renderer.h"
33 #include <string>
34 
35 namespace irr
36 {
37 namespace video
38 {
39 class ITexture;
40 }
41 }
42 
43 // Start of CEGUI namespace section
44 namespace CEGUI
45 {
46 class IrrlichtRenderer;
47 
49 class IRR_GUIRENDERER_API IrrlichtTexture : public Texture
50 {
51 public:
53  void setIrrlichtTexture(irr::video::ITexture* tex);
54 
56  irr::video::ITexture* getIrrlichtTexture() const;
57 
65  void setOriginalDataSize(const Sizef& sz);
66 
68  static std::string getUniqueName();
69 
70  // Implement texture interface.
71  const String& getName() const;
72  const Sizef& getSize() const;
73  const Sizef& getOriginalDataSize() const;
74  const Vector2f& getTexelScaling() const;
75  void loadFromFile(const String& filename, const String& resourceGroup);
76  void loadFromMemory(const void* buffer, const Sizef& buffer_size,
77  PixelFormat pixel_format);
78  void blitFromMemory(const void* sourceData, const Rectf& area);
79  void blitToMemory(void* targetData);
80  bool isPixelFormatSupported(const PixelFormat fmt) const;
81 
82 protected:
83  // friends in order that Renderer module can create / destroy textures
86  const String&);
87  friend Texture& IrrlichtRenderer::createTexture(const String&, const Sizef&);
89  friend void IrrlichtRenderer::destroyTexture(const String&);
90 
92  IrrlichtTexture(IrrlichtRenderer& owner, irr::video::IVideoDriver& driver,
93  const String& name);
95  IrrlichtTexture(IrrlichtRenderer& owner, irr::video::IVideoDriver& driver,
96  const String& name, const String& filename,
97  const String& resourceGroup);
99  IrrlichtTexture(IrrlichtRenderer& owner, irr::video::IVideoDriver& driver,
100  const String& name, const Sizef& size);
103 
105  void createIrrlichtTexture(const Sizef& sz);
106 
109 
112 
114  static uint32 d_textureNumber;
116  irr::video::IVideoDriver& d_driver;
118  irr::video::ITexture* d_texture;
128  const String d_name;
129 };
130 
131 } // End of CEGUI namespace section
132 
133 #endif // end of guard _CEGUIIrrlichtTexture_h_
CEGUI::IrrlichtTexture::d_size
Sizef d_size
Size of the texture.
Definition: RendererModules/Irrlicht/Texture.h:120
CEGUI::IrrlichtTexture::setOriginalDataSize
void setOriginalDataSize(const Sizef &sz)
Sets what the texture should consider as the original data size.
CEGUI::IrrlichtTexture::getTexelScaling
const Vector2f & getTexelScaling() const
Returns pixel to texel scale values that should be used for converting pixel values to texture co-ord...
CEGUI::IrrlichtTexture::d_name
const String d_name
name given when texture was created.
Definition: RendererModules/Irrlicht/Texture.h:128
CEGUI::IrrlichtTexture::createIrrlichtTexture
void createIrrlichtTexture(const Sizef &sz)
create the underlying Irrlicht texture with the given size
CEGUI::IrrlichtTexture::IrrlichtTexture
IrrlichtTexture(IrrlichtRenderer &owner, irr::video::IVideoDriver &driver, const String &name)
Construct a basic texture.
CEGUI::IrrlichtTexture::freeIrrlichtTexture
void freeIrrlichtTexture()
release the underlying irrlicht texture currently used.
CEGUI::IrrlichtTexture::IrrlichtTexture
IrrlichtTexture(IrrlichtRenderer &owner, irr::video::IVideoDriver &driver, const String &name, const String &filename, const String &resourceGroup)
Construct a texture from the specified file.
CEGUI::IrrlichtTexture::d_textureNumber
static uint32 d_textureNumber
Counter used to provide unique texture names.
Definition: RendererModules/Irrlicht/Texture.h:114
CEGUI::IrrlichtTexture::blitToMemory
void blitToMemory(void *targetData)
Performs a complete blit from the texture surface to memory.
CEGUI::IrrlichtTexture::setIrrlichtTexture
void setIrrlichtTexture(irr::video::ITexture *tex)
set the underlying Irrlicht texture represented by this Texture.
CEGUI::IrrlichtTexture::getName
const String & getName() const
Returns the name given to the texture when it was created.
CEGUI::IrrlichtTexture::d_driver
irr::video::IVideoDriver & d_driver
Irrlicht video driver we're to use.
Definition: RendererModules/Irrlicht/Texture.h:116
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::Vector2< float >
CEGUI::IrrlichtTexture::getOriginalDataSize
const Sizef & getOriginalDataSize() const
Returns the original pixel size of the data loaded into the texture.
CEGUI::IrrlichtTexture::IrrlichtTexture
IrrlichtTexture(IrrlichtRenderer &owner, irr::video::IVideoDriver &driver, const String &name, const Sizef &size)
Construct a texture with the given size.
CEGUI::IrrlichtTexture::blitFromMemory
void blitFromMemory(const void *sourceData, const Rectf &area)
Performs an area memory blit to the texture.
CEGUI::IrrlichtTexture::getSize
const Sizef & getSize() const
Returns the current pixel size of the texture.
CEGUI::IrrlichtTexture::loadFromMemory
void loadFromMemory(const void *buffer, const Sizef &buffer_size, PixelFormat pixel_format)
Loads (copies) an image in memory into the texture. The texture is resized as required to hold the im...
CEGUI::IrrlichtTexture::d_texture
irr::video::ITexture * d_texture
ptr to underlying irrlicht texture.
Definition: RendererModules/Irrlicht/Texture.h:118
CEGUI::IrrlichtTexture::d_dataSize
Sizef d_dataSize
original pixel of size data loaded into texture
Definition: RendererModules/Irrlicht/Texture.h:122
CEGUI::IrrlichtTexture::loadFromFile
void loadFromFile(const String &filename, const String &resourceGroup)
Loads the specified image file into the texture. The texture is resized as required to hold the image...
CEGUI::Texture
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:54
CEGUI::IrrlichtTexture::isPixelFormatSupported
bool isPixelFormatSupported(const PixelFormat fmt) const
Return whether the specified pixel format is supported by the system for the CEGUI::Texture implement...
CEGUI::IrrlichtTexture::~IrrlichtTexture
~IrrlichtTexture()
destructor.
CEGUI::IrrlichtTexture::d_texelScaling
Vector2f d_texelScaling
cached pixel to texel mapping scale values.
Definition: RendererModules/Irrlicht/Texture.h:124
CEGUI::IrrlichtTexture::getIrrlichtTexture
irr::video::ITexture * getIrrlichtTexture() const
return a pointer to the Irrlicht texture represented by this Texture.
CEGUI::IrrlichtTexture::updateCachedScaleValues
void updateCachedScaleValues()
updates cached scale value used to map pixels to texture co-ords.
CEGUI::IrrlichtTexture
Implementation of the CEGUI::Texture class for the Irrlicht engine.
Definition: RendererModules/Irrlicht/Texture.h:50
CEGUI::IrrlichtTexture::getUniqueName
static std::string getUniqueName()
return a std::string containing a unique name.
CEGUI::IrrlichtRenderer::createTexture
Texture & createTexture(const String &name)
Create a 'null' Texture object.
CEGUI::Size< float >
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::Texture::PixelFormat
PixelFormat
Enumerated type containing the supported pixel formats that can be passed to loadFromMemory.
Definition: Texture.h:62
CEGUI::Rect< float >
CEGUI::IrrlichtTexture::d_owner
IrrlichtRenderer & d_owner
reference to the IrrlichtRenderer that created this texture
Definition: RendererModules/Irrlicht/Texture.h:126
CEGUI::IrrlichtRenderer
CEGUI::Renderer implementation for the Irrlicht engine.
Definition: RendererModules/Irrlicht/Renderer.h:72
CEGUI::IrrlichtRenderer::destroyTexture
void destroyTexture(Texture &texture)
Destroy a Texture object that was previously created by calling the createTexture functions.