Crazy Eddies GUI System  0.7.2
CEGUIDirect3D11Texture.h
1 /***********************************************************************
2  filename: CEGUIDirect3D11Texture.h
3  created: Wed May 5 2010
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2010 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 "../../CEGUITexture.h"
31 #include "CEGUIDirect3D11Renderer.h"
32 #include "../../CEGUISize.h"
33 #include "../../CEGUIVector.h"
34 
35 // d3d forward refs
36 struct ID3D11Device;
37 struct ID3D11DeviceContext;
38 struct ID3D11Texture2D;
39 struct ID3D11ShaderResourceView;
40 
41 
42 
43 // Start of CEGUI namespace section
44 namespace CEGUI
45 {
47 class D3D11_GUIRENDERER_API Direct3D11Texture : public Texture
48 {
49 public:
55  void setDirect3DTexture(ID3D11Texture2D* tex);
56 
64  ID3D11Texture2D* getDirect3DTexture() const;
65 
73  ID3D11ShaderResourceView* getDirect3DShaderResourceView() const;
74 
82  void setOriginalDataSize(const Size& sz);
83 
84  // implement abstract members from base class.
85  const Size& getSize() const;
86  const Size& getOriginalDataSize() const;
87  const Vector2& getTexelScaling() const;
88  void loadFromFile(const String& filename, const String& resourceGroup);
89  void loadFromMemory(const void* buffer, const Size& buffer_size,
90  PixelFormat pixel_format);
91  void saveToMemory(void* buffer);
92 
93 protected:
94  // Friends to allow Renderer to peform construction and destruction
98  //friend Texture& Direct3D11Renderer::createTexture(ID3D10Texture2D* tex);
100 
102  Direct3D11Texture(IDevice11& device);
104  Direct3D11Texture(IDevice11& device, const String& filename,
105  const String& resourceGroup);
107  Direct3D11Texture(IDevice11& device, const Size& sz);
109  Direct3D11Texture(IDevice11& device, ID3D11Texture2D* tex);
111  virtual ~Direct3D11Texture();
112 
114  void cleanupDirect3D11Texture();
116  void updateCachedScaleValues();
118  void updateTextureSize();
120  void initialiseShaderResourceView();
121 
125  ID3D11Texture2D* d_texture;
127  ID3D11ShaderResourceView* d_resourceView;
134 };
135 
136 
137 } // End of CEGUI namespace section
138 
139 #endif // end of guard _CEGUIDirect3D11Texture_h_