Crazy Eddie's GUI System  0.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/Direct3D9/Texture.h
1 /***********************************************************************
2  filename: CEGUIDirect3D9Texture.h
3  created: Mon Feb 9 2009
4  author: Paul D Turner
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 _CEGUIDirect3D9Texture_h_
29 #define _CEGUIDirect3D9Texture_h_
30 
31 #include "../../Base.h"
32 #include "../../Renderer.h"
33 #include "../../Texture.h"
34 #include "CEGUI/RendererModules/Direct3D9/Renderer.h"
35 
36 #if defined(_MSC_VER)
37 # pragma warning(push)
38 # pragma warning(disable : 4251)
39 #endif
40 
41 // Start of CEGUI namespace section
42 namespace CEGUI
43 {
45 class DIRECT3D9_GUIRENDERER_API Direct3D9Texture : public Texture
46 {
47 public:
53  void setDirect3D9Texture(LPDIRECT3DTEXTURE9 tex);
54 
62  LPDIRECT3DTEXTURE9 getDirect3D9Texture() const;
63 
71  void setOriginalDataSize(const Sizef& sz);
72 
74  void preD3DReset();
75 
77  void postD3DReset();
78 
79  // implement abstract members from base class.
80  const String& getName() const;
81  const Sizef& getSize() const;
82  const Sizef& getOriginalDataSize() const;
83  const Vector2f& getTexelScaling() const;
84  void loadFromFile(const String& filename, const String& resourceGroup);
85  void loadFromMemory(const void* buffer, const Sizef& buffer_size,
86  PixelFormat pixel_format);
87  void blitFromMemory(const void* sourceData, const Rectf& area);
88  void blitToMemory(void* targetData);
89  bool isPixelFormatSupported(const PixelFormat fmt) const;
90 
91 protected:
92  // Friends (to allow construction and destruction)
95  const String&,
96  const String&);
98  const Sizef&);
100  LPDIRECT3DTEXTURE9 tex);
102  friend void Direct3D9Renderer::destroyTexture(const String&);
103 
105  Direct3D9Texture(Direct3D9Renderer& owner, const String& name);
107  Direct3D9Texture(Direct3D9Renderer& owner, const String& name,
108  const String& filename, const String& resourceGroup);
110  Direct3D9Texture(Direct3D9Renderer& owner, const String& name,
111  const Sizef& sz);
113  Direct3D9Texture(Direct3D9Renderer& owner, const String& name,
114  LPDIRECT3DTEXTURE9 tex);
116  virtual ~Direct3D9Texture();
117 
119  void createDirect3D9Texture(const Sizef sz, D3DFORMAT format);
121  void cleanupDirect3D9Texture();
123  IDirect3DSurface9* getTextureSurface() const;
125  void updateCachedScaleValues();
127  void updateTextureSize();
128 
132  LPDIRECT3DTEXTURE9 d_texture;
140  D3DSURFACE_DESC d_savedSurfaceDesc;
144  const String d_name;
145 };
146 
147 } // End of CEGUI namespace section
148 
149 #if defined(_MSC_VER)
150 # pragma warning(pop)
151 #endif
152 
153 #endif // end of guard _CEGUIDirect3D9Texture_h_