Crazy Eddie's GUI System  0.8.7
RendererModules/Direct3D11/Texture.h
1 /***********************************************************************
2  created: Wed May 5 2010
3 *************************************************************************/
4 /***************************************************************************
5  * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24  * OTHER DEALINGS IN THE SOFTWARE.
25  ***************************************************************************/
26 #ifndef _CEGUIDirect3D11Texture_h_
27 #define _CEGUIDirect3D11Texture_h_
28 
29 #include "../../Texture.h"
30 #include "CEGUI/RendererModules/Direct3D11/Renderer.h"
31 #include "../../Size.h"
32 #include "../../Vector.h"
33 
34 // d3d forward refs
35 struct ID3D11Device;
36 struct ID3D11DeviceContext;
37 struct ID3D11Texture2D;
38 struct ID3D11ShaderResourceView;
39 
40 #if defined(_MSC_VER)
41 # pragma warning(push)
42 # pragma warning(disable : 4251)
43 #endif
44 
45 // Start of CEGUI namespace section
46 namespace CEGUI
47 {
49 class D3D11_GUIRENDERER_API Direct3D11Texture : public Texture
50 {
51 public:
57  void setDirect3DTexture(ID3D11Texture2D* tex);
58 
66  ID3D11Texture2D* getDirect3DTexture() const;
67 
75  ID3D11ShaderResourceView* 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& Direct3D11Renderer::createTexture(ID3D10Texture2D* tex);
108  friend void Direct3D11Renderer::destroyTexture(const String&);
109 
111  Direct3D11Texture(IDevice11& device, const String& name);
113  Direct3D11Texture(IDevice11& device, const String& name, const String& filename,
114  const String& resourceGroup);
116  Direct3D11Texture(IDevice11& device, const String& name, const Sizef& sz);
118  Direct3D11Texture(IDevice11& device, const String& name, ID3D11Texture2D* tex);
120  virtual ~Direct3D11Texture();
121 
123  void cleanupDirect3D11Texture();
125  void updateCachedScaleValues();
127  void updateTextureSize();
129  void initialiseShaderResourceView();
130 
134  ID3D11Texture2D* d_texture;
136  ID3D11ShaderResourceView* 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 _CEGUIDirect3D11Texture_h_
void destroyTexture(Texture &texture)
Destroy a Texture object that was previously created by calling the createTexture functions...
PixelFormat
Enumerated type containing the supported pixel formats that can be passed to loadFromMemory.
Definition: Texture.h:61
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
Vector2f d_texelScaling
cached pixel to texel mapping scale values.
Definition: RendererModules/Direct3D11/Texture.h:142
IDevice11 & d_device
D3D device used to do the business.
Definition: RendererModules/Direct3D11/Texture.h:132
Texture & createTexture(const String &name)
Create a 'null' Texture object.
Sizef d_size
Size of the texture.
Definition: RendererModules/Direct3D11/Texture.h:138
Definition: RendererModules/Direct3D11/Renderer.h:66
ID3D11Texture2D * d_texture
The D3D 10 texture we're wrapping.
Definition: RendererModules/Direct3D11/Texture.h:134
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:52
Sizef d_dataSize
original pixel of size data loaded into texture
Definition: RendererModules/Direct3D11/Texture.h:140
const String d_name
The name we were created with.
Definition: RendererModules/Direct3D11/Texture.h:144
ID3D11ShaderResourceView * d_resourceView
Shader resource view for the texture.
Definition: RendererModules/Direct3D11/Texture.h:136
Texture implementation for the Direct3D11Renderer.
Definition: RendererModules/Direct3D11/Texture.h:49
String class used within the GUI system.
Definition: String.h:62