Crazy Eddie's GUI System  0.8.7
RendererModules/Direct3D9/Texture.h
1 /***********************************************************************
2  created: Mon Feb 9 2009
3  author: Paul D Turner
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 _CEGUIDirect3D9Texture_h_
28 #define _CEGUIDirect3D9Texture_h_
29 
30 #include "../../Base.h"
31 #include "../../Renderer.h"
32 #include "../../Texture.h"
33 #include "CEGUI/RendererModules/Direct3D9/Renderer.h"
34 
35 #if defined(_MSC_VER)
36 # pragma warning(push)
37 # pragma warning(disable : 4251)
38 #endif
39 
40 // Start of CEGUI namespace section
41 namespace CEGUI
42 {
44 class DIRECT3D9_GUIRENDERER_API Direct3D9Texture : public Texture
45 {
46 public:
52  void setDirect3D9Texture(LPDIRECT3DTEXTURE9 tex);
53 
61  LPDIRECT3DTEXTURE9 getDirect3D9Texture() const;
62 
70  void setOriginalDataSize(const Sizef& sz);
71 
73  void preD3DReset();
74 
76  void postD3DReset();
77 
78  // implement abstract members from base class.
79  const String& getName() const;
80  const Sizef& getSize() const;
81  const Sizef& getOriginalDataSize() const;
82  const Vector2f& getTexelScaling() const;
83  void loadFromFile(const String& filename, const String& resourceGroup);
84  void loadFromMemory(const void* buffer, const Sizef& buffer_size,
85  PixelFormat pixel_format);
86  void blitFromMemory(const void* sourceData, const Rectf& area);
87  void blitToMemory(void* targetData);
88  bool isPixelFormatSupported(const PixelFormat fmt) const;
89 
90 protected:
91  // Friends (to allow construction and destruction)
94  const String&,
95  const String&);
97  const Sizef&);
99  LPDIRECT3DTEXTURE9 tex);
101  friend void Direct3D9Renderer::destroyTexture(const String&);
102 
107  const String& filename, const String& resourceGroup);
110  const Sizef& sz);
113  LPDIRECT3DTEXTURE9 tex);
115  virtual ~Direct3D9Texture();
116 
118  void createDirect3D9Texture(const Sizef sz, D3DFORMAT format);
122  IDirect3DSurface9* getTextureSurface() const;
127 
131  LPDIRECT3DTEXTURE9 d_texture;
139  D3DSURFACE_DESC d_savedSurfaceDesc;
143  const String d_name;
144 };
145 
146 } // End of CEGUI namespace section
147 
148 #if defined(_MSC_VER)
149 # pragma warning(pop)
150 #endif
151 
152 #endif // end of guard _CEGUIDirect3D9Texture_h_
CEGUI::Direct3D9Texture::~Direct3D9Texture
virtual ~Direct3D9Texture()
Destructor.
CEGUI::Direct3D9Renderer::createTexture
Texture & createTexture(const String &name, LPDIRECT3DTEXTURE9 tex)
create a CEGUI::texture from an existing D3D texture
CEGUI::Direct3D9Texture::d_size
Sizef d_size
Size of the texture.
Definition: RendererModules/Direct3D9/Texture.h:133
CEGUI::Direct3D9Texture::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
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::Direct3D9Texture::getDirect3D9Texture
LPDIRECT3DTEXTURE9 getDirect3D9Texture() const
Return the internal D3D9 texture used by this Texture object.
CEGUI::Direct3D9Texture::setOriginalDataSize
void setOriginalDataSize(const Sizef &sz)
Sets what the texture should consider as the original data size.
CEGUI::Direct3D9Texture::getOriginalDataSize
const Sizef & getOriginalDataSize() const
Returns the original pixel size of the data loaded into the texture.
CEGUI::Vector2< float >
CEGUI::Direct3D9Texture::blitFromMemory
void blitFromMemory(const void *sourceData, const Rectf &area)
Performs an area memory blit to the texture.
CEGUI::Direct3D9Texture::d_savedSurfaceDescValid
bool d_savedSurfaceDescValid
true when d_savedSurfaceDesc is valid and texture can be restored.
Definition: RendererModules/Direct3D9/Texture.h:141
CEGUI::Direct3D9Texture::Direct3D9Texture
Direct3D9Texture(Direct3D9Renderer &owner, const String &name, LPDIRECT3DTEXTURE9 tex)
Construct texture that wraps an existing D3D9 texture.
CEGUI::Direct3D9Texture::Direct3D9Texture
Direct3D9Texture(Direct3D9Renderer &owner, const String &name, const String &filename, const String &resourceGroup)
Construct texture from an image file.
CEGUI::Direct3D9Renderer::destroyTexture
void destroyTexture(Texture &texture)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::Texture
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:54
CEGUI::Direct3D9Texture::d_texture
LPDIRECT3DTEXTURE9 d_texture
The D3D9 texture we're wrapping.
Definition: RendererModules/Direct3D9/Texture.h:131
CEGUI::Direct3D9Texture
Texture implementation for the Direct3D9Renderer.
Definition: RendererModules/Direct3D9/Texture.h:45
CEGUI::Direct3D9Texture::d_texelScaling
Vector2f d_texelScaling
cached pixel to texel mapping scale values.
Definition: RendererModules/Direct3D9/Texture.h:137
CEGUI::Direct3D9Texture::getTexelScaling
const Vector2f & getTexelScaling() const
Returns pixel to texel scale values that should be used for converting pixel values to texture co-ord...
CEGUI::Direct3D9Texture::setDirect3D9Texture
void setDirect3D9Texture(LPDIRECT3DTEXTURE9 tex)
set the D3D9 texture that this Texture is based on to the specified texture.
CEGUI::Direct3D9Texture::cleanupDirect3D9Texture
void cleanupDirect3D9Texture()
clean up the internal texture.
CEGUI::Direct3D9Texture::Direct3D9Texture
Direct3D9Texture(Direct3D9Renderer &owner, const String &name, const Sizef &sz)
Construct texture with a given size.
CEGUI::Direct3D9Texture::createDirect3D9Texture
void createDirect3D9Texture(const Sizef sz, D3DFORMAT format)
create internal texture.
CEGUI::Direct3D9Texture::d_dataSize
Sizef d_dataSize
original pixel of size data loaded into texture
Definition: RendererModules/Direct3D9/Texture.h:135
CEGUI::Direct3D9Texture::d_savedSurfaceDesc
D3DSURFACE_DESC d_savedSurfaceDesc
holds info about the texture surface before we released it for reset.
Definition: RendererModules/Direct3D9/Texture.h:139
CEGUI::Direct3D9Texture::postD3DReset
void postD3DReset()
auto called via the Renderer after Reset on the Direct3DDevice9.
CEGUI::Size< float >
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::Direct3D9Texture::updateTextureSize
void updateTextureSize()
set d_size to actual texture size (d_dataSize is used if query fails)
CEGUI::Direct3D9Texture::d_owner
Direct3D9Renderer & d_owner
Direct3D9Renderer object that created and owns this texture.
Definition: RendererModules/Direct3D9/Texture.h:129
CEGUI::Direct3D9Texture::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::Texture::PixelFormat
PixelFormat
Enumerated type containing the supported pixel formats that can be passed to loadFromMemory.
Definition: Texture.h:62
CEGUI::Direct3D9Texture::blitToMemory
void blitToMemory(void *targetData)
Performs a complete blit from the texture surface to memory.
CEGUI::Direct3D9Texture::getSize
const Sizef & getSize() const
Returns the current pixel size of the texture.
CEGUI::Direct3D9Texture::getName
const String & getName() const
Returns the name given to the texture when it was created.
CEGUI::Rect< float >
CEGUI::Direct3D9Renderer
Renderer class to interface with Direct3D 9.
Definition: RendererModules/Direct3D9/Renderer.h:65
CEGUI::Direct3D9Texture::updateCachedScaleValues
void updateCachedScaleValues()
updates cached scale value used to map pixels to texture co-ords.
CEGUI::Direct3D9Texture::preD3DReset
void preD3DReset()
auto called via the Renderer prior to Reset on the Direct3DDevice9.
CEGUI::Direct3D9Texture::Direct3D9Texture
Direct3D9Texture(Direct3D9Renderer &owner, const String &name)
Basic constructor.
CEGUI::Direct3D9Texture::getTextureSurface
IDirect3DSurface9 * getTextureSurface() const
get the IDirect3DSurface9 interface for the underlying texture.
CEGUI::Direct3D9Texture::isPixelFormatSupported
bool isPixelFormatSupported(const PixelFormat fmt) const
Return whether the specified pixel format is supported by the system for the CEGUI::Texture implement...
CEGUI::Direct3D9Texture::d_name
const String d_name
Name the texture was created with.
Definition: RendererModules/Direct3D9/Texture.h:143