Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/Direct3D11/Texture.h
1 /***********************************************************************
2  filename: CEGUIDirect3D11Texture.h
3  created: Wed May 5 2010
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 _CEGUIDirect3D11Texture_h_
28 #define _CEGUIDirect3D11Texture_h_
29 
30 #include "../../Texture.h"
31 #include "CEGUI/RendererModules/Direct3D11/Renderer.h"
32 #include "../../Size.h"
33 #include "../../Vector.h"
34 
35 // d3d forward refs
36 struct ID3D11Device;
37 struct ID3D11DeviceContext;
38 struct ID3D11Texture2D;
39 struct ID3D11ShaderResourceView;
40 
41 #if defined(_MSC_VER)
42 # pragma warning(push)
43 # pragma warning(disable : 4251)
44 #endif
45 
46 // Start of CEGUI namespace section
47 namespace CEGUI
48 {
50 class D3D11_GUIRENDERER_API Direct3D11Texture : public Texture
51 {
52 public:
58  void setDirect3DTexture(ID3D11Texture2D* tex);
59 
67  ID3D11Texture2D* getDirect3DTexture() const;
68 
76  ID3D11ShaderResourceView* getDirect3DShaderResourceView() const;
77 
85  void setOriginalDataSize(const Sizef& sz);
86 
87  // implement abstract members from base class.
88  const String& getName() const;
89  const Sizef& getSize() const;
90  const Sizef& getOriginalDataSize() const;
91  const Vector2f& getTexelScaling() const;
92  void loadFromFile(const String& filename, const String& resourceGroup);
93  void loadFromMemory(const void* buffer, const Sizef& buffer_size,
94  PixelFormat pixel_format);
95  void blitFromMemory(const void* sourceData, const Rectf& area);
96  void blitToMemory(void* targetData);
97  bool isPixelFormatSupported(const PixelFormat fmt) const;
98 
99 protected:
100  // Friends to allow Renderer to peform construction and destruction
103  const String&,
104  const String&);
106  const Sizef&);
107  //friend Texture& Direct3D11Renderer::createTexture(ID3D10Texture2D* tex);
109  friend void Direct3D11Renderer::destroyTexture(const String&);
110 
112  Direct3D11Texture(IDevice11& device, const String& name);
114  Direct3D11Texture(IDevice11& device, const String& name, const String& filename,
115  const String& resourceGroup);
117  Direct3D11Texture(IDevice11& device, const String& name, const Sizef& sz);
119  Direct3D11Texture(IDevice11& device, const String& name, ID3D11Texture2D* tex);
121  virtual ~Direct3D11Texture();
122 
124  void cleanupDirect3D11Texture();
126  void updateCachedScaleValues();
128  void updateTextureSize();
130  void initialiseShaderResourceView();
131 
135  ID3D11Texture2D* d_texture;
137  ID3D11ShaderResourceView* d_resourceView;
145  const String d_name;
146 };
147 
148 
149 } // End of CEGUI namespace section
150 
151 #if defined(_MSC_VER)
152 # pragma warning(pop)
153 #endif
154 
155 #endif // end of guard _CEGUIDirect3D11Texture_h_