Crazy Eddie's GUI System  0.8.7
RendererModules/Direct3D10/Texture.h
1 /***********************************************************************
2  created: Sat Mar 7 2009
3  author: Paul D Turner (parts based on code by Rajko Stojadinovic)
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 _CEGUIDirect3D10Texture_h_
28 #define _CEGUIDirect3D10Texture_h_
29 
30 #include "../../Texture.h"
31 #include "CEGUI/RendererModules/Direct3D10/Renderer.h"
32 #include "../../Size.h"
33 #include "../../Vector.h"
34 
35 #if defined(_MSC_VER)
36 # pragma warning(push)
37 # pragma warning(disable : 4251)
38 #endif
39 
40 // d3d forward refs
41 struct ID3D10Device;
42 struct ID3D10Texture2D;
43 struct ID3D10ShaderResourceView;
44 
45 // Start of CEGUI namespace section
46 namespace CEGUI
47 {
49 class D3D10_GUIRENDERER_API Direct3D10Texture : public Texture
50 {
51 public:
57  void setDirect3DTexture(ID3D10Texture2D* tex);
58 
66  ID3D10Texture2D* getDirect3DTexture() const;
67 
75  ID3D10ShaderResourceView* getDirect3DShaderResourceView() const;
76 
84  void setOriginalDataSize(const Sizef& sz);
85 
86  // implement abstract members from base class.
87  const String& getName() const;
88  const Sizef& getSize() const;
89  const Sizef& getOriginalDataSize() const;
90  const Vector2f& getTexelScaling() const;
91  void loadFromFile(const String& filename, const String& resourceGroup);
92  void loadFromMemory(const void* buffer, const Sizef& buffer_size,
93  PixelFormat pixel_format);
94  void blitFromMemory(const void* sourceData, const Rectf& area);
95  void blitToMemory(void* targetData);
96  bool isPixelFormatSupported(const PixelFormat fmt) const;
97 
98 protected:
99  // Friends to allow Renderer to peform construction and destruction
102  const String&,
103  const String&);
105  const Sizef&);
106  //friend Texture& Direct3D10Renderer::createTexture(ID3D10Texture2D* tex);
108  friend void Direct3D10Renderer::destroyTexture(const String&);
109 
111  Direct3D10Texture(ID3D10Device& device, const String&);
113  Direct3D10Texture(ID3D10Device& device, const String&,
114  const String& filename, const String& resourceGroup);
116  Direct3D10Texture(ID3D10Device& device, const String&, const Sizef& sz);
118  Direct3D10Texture(ID3D10Device& device, const String&, ID3D10Texture2D* tex);
121 
130 
132  ID3D10Device& d_device;
134  ID3D10Texture2D* d_texture;
136  ID3D10ShaderResourceView* d_resourceView;
144  const String d_name;
145 };
146 
147 
148 } // End of CEGUI namespace section
149 
150 #if defined(_MSC_VER)
151 # pragma warning(pop)
152 #endif
153 
154 #endif // end of guard _CEGUIDirect3D10Texture_h_
CEGUI::Direct3D10Texture::setOriginalDataSize
void setOriginalDataSize(const Sizef &sz)
Sets what the texture should consider as the original data size.
CEGUI::Direct3D10Texture::initialiseShaderResourceView
void initialiseShaderResourceView()
creates shader resource view for the current D3D texture
CEGUI::Direct3D10Renderer::createTexture
Texture & createTexture(const String &name)
Create a 'null' Texture object.
CEGUI::Direct3D10Texture::updateTextureSize
void updateTextureSize()
set d_size to actual texture size (d_dataSize is used if query fails)
CEGUI::Direct3D10Texture::cleanupDirect3D10Texture
void cleanupDirect3D10Texture()
clean up the internal texture.
CEGUI::Direct3D10Texture::d_size
Sizef d_size
Size of the texture.
Definition: RendererModules/Direct3D10/Texture.h:138
CEGUI::Direct3D10Texture::Direct3D10Texture
Direct3D10Texture(ID3D10Device &device, const String &, const String &filename, const String &resourceGroup)
Construct texture from an image file.
CEGUI::Direct3D10Texture::Direct3D10Texture
Direct3D10Texture(ID3D10Device &device, const String &, ID3D10Texture2D *tex)
Construct texture that wraps an existing D3D10 texture.
CEGUI::Direct3D10Texture::d_texelScaling
Vector2f d_texelScaling
cached pixel to texel mapping scale values.
Definition: RendererModules/Direct3D10/Texture.h:142
CEGUI::Direct3D10Texture::d_dataSize
Sizef d_dataSize
original pixel of size data loaded into texture
Definition: RendererModules/Direct3D10/Texture.h:140
CEGUI::Direct3D10Texture::updateCachedScaleValues
void updateCachedScaleValues()
updates cached scale value used to map pixels to texture co-ords.
CEGUI::Direct3D10Texture::Direct3D10Texture
Direct3D10Texture(ID3D10Device &device, const String &)
Basic constructor.
CEGUI::Direct3D10Texture::isPixelFormatSupported
bool isPixelFormatSupported(const PixelFormat fmt) const
Return whether the specified pixel format is supported by the system for the CEGUI::Texture implement...
CEGUI::Direct3D10Texture::d_resourceView
ID3D10ShaderResourceView * d_resourceView
Shader resource view for the texture.
Definition: RendererModules/Direct3D10/Texture.h:136
CEGUI::Direct3D10Renderer::destroyTexture
void destroyTexture(Texture &texture)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::Direct3D10Texture
Texture implementation for the Direct3D10Renderer.
Definition: RendererModules/Direct3D10/Texture.h:50
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::Direct3D10Texture::d_name
const String d_name
The name used when the texture was created.
Definition: RendererModules/Direct3D10/Texture.h:144
CEGUI::Vector2< float >
CEGUI::Direct3D10Texture::getSize
const Sizef & getSize() const
Returns the current pixel size of the texture.
CEGUI::Direct3D10Texture::Direct3D10Texture
Direct3D10Texture(ID3D10Device &device, const String &, const Sizef &sz)
Construct texture with a given size.
CEGUI::Direct3D10Texture::d_device
ID3D10Device & d_device
D3D device used to do the business.
Definition: RendererModules/Direct3D10/Texture.h:132
CEGUI::Direct3D10Texture::getName
const String & getName() const
Returns the name given to the texture when it was created.
CEGUI::Texture
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:54
CEGUI::Direct3D10Texture::getDirect3DShaderResourceView
ID3D10ShaderResourceView * getDirect3DShaderResourceView() const
Return the internal D3D10 shader resource view for the texture.
CEGUI::Direct3D10Texture::~Direct3D10Texture
virtual ~Direct3D10Texture()
Destructor.
CEGUI::Direct3D10Texture::getOriginalDataSize
const Sizef & getOriginalDataSize() const
Returns the original pixel size of the data loaded into the texture.
CEGUI::Direct3D10Texture::d_texture
ID3D10Texture2D * d_texture
The D3D 10 texture we're wrapping.
Definition: RendererModules/Direct3D10/Texture.h:134
CEGUI::Direct3D10Texture::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::Direct3D10Texture::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::Direct3D10Texture::getDirect3DTexture
ID3D10Texture2D * getDirect3DTexture() const
Return the internal D3D10 texture used by this Texture object.
CEGUI::Size< float >
CEGUI::Direct3D10Texture::setDirect3DTexture
void setDirect3DTexture(ID3D10Texture2D *tex)
set the D3D10 texture that this Texture is based on to the specified texture.
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::Direct3D10Texture::blitFromMemory
void blitFromMemory(const void *sourceData, const Rectf &area)
Performs an area memory blit to the texture.
CEGUI::Texture::PixelFormat
PixelFormat
Enumerated type containing the supported pixel formats that can be passed to loadFromMemory.
Definition: Texture.h:62
CEGUI::Direct3D10Texture::blitToMemory
void blitToMemory(void *targetData)
Performs a complete blit from the texture surface to memory.
CEGUI::Rect< float >
CEGUI::Direct3D10Texture::getTexelScaling
const Vector2f & getTexelScaling() const
Returns pixel to texel scale values that should be used for converting pixel values to texture co-ord...