Crazy Eddie's GUI System  0.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/Direct3D10/Texture.h
1 /***********************************************************************
2  filename: CEGUIDirect3D10Texture.h
3  created: Sat Mar 7 2009
4  author: Paul D Turner (parts based on code by Rajko Stojadinovic)
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIDirect3D10Texture_h_
29 #define _CEGUIDirect3D10Texture_h_
30 
31 #include "../../Texture.h"
32 #include "CEGUI/RendererModules/Direct3D10/Renderer.h"
33 #include "../../Size.h"
34 #include "../../Vector.h"
35 
36 #if defined(_MSC_VER)
37 # pragma warning(push)
38 # pragma warning(disable : 4251)
39 #endif
40 
41 // d3d forward refs
42 struct ID3D10Device;
43 struct ID3D10Texture2D;
44 struct ID3D10ShaderResourceView;
45 
46 // Start of CEGUI namespace section
47 namespace CEGUI
48 {
50 class D3D10_GUIRENDERER_API Direct3D10Texture : public Texture
51 {
52 public:
58  void setDirect3DTexture(ID3D10Texture2D* tex);
59 
67  ID3D10Texture2D* getDirect3DTexture() const;
68 
76  ID3D10ShaderResourceView* 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& Direct3D10Renderer::createTexture(ID3D10Texture2D* tex);
109  friend void Direct3D10Renderer::destroyTexture(const String&);
110 
112  Direct3D10Texture(ID3D10Device& device, const String&);
114  Direct3D10Texture(ID3D10Device& device, const String&,
115  const String& filename, const String& resourceGroup);
117  Direct3D10Texture(ID3D10Device& device, const String&, const Sizef& sz);
119  Direct3D10Texture(ID3D10Device& device, const String&, ID3D10Texture2D* tex);
121  virtual ~Direct3D10Texture();
122 
124  void cleanupDirect3D10Texture();
126  void updateCachedScaleValues();
128  void updateTextureSize();
130  void initialiseShaderResourceView();
131 
133  ID3D10Device& d_device;
135  ID3D10Texture2D* d_texture;
137  ID3D10ShaderResourceView* 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 _CEGUIDirect3D10Texture_h_