Crazy Eddies GUI System  0.7.1
CEGUIDirect3D9Texture.h
1 /***********************************************************************
2  filename: CEGUIDirect3D9Texture.h
3  created: Mon Feb 9 2009
4  author: Paul D Turner
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2009 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 "../../CEGUIBase.h"
32 #include "../../CEGUIRenderer.h"
33 #include "../../CEGUITexture.h"
34 #include "CEGUIDirect3D9Renderer.h"
35 
36 // Start of CEGUI namespace section
37 namespace CEGUI
38 {
40 class DIRECT3D9_GUIRENDERER_API Direct3D9Texture : public Texture
41 {
42 public:
48  void setDirect3D9Texture(LPDIRECT3DTEXTURE9 tex);
49 
57  LPDIRECT3DTEXTURE9 getDirect3D9Texture() const;
58 
66  void setOriginalDataSize(const Size& sz);
67 
69  void preD3DReset();
70 
72  void postD3DReset();
73 
74  // implement abstract members from base class.
75  const Size& getSize() const;
76  const Size& getOriginalDataSize() const;
77  const Vector2& getTexelScaling() const;
78  void loadFromFile(const String& filename, const String& resourceGroup);
79  void loadFromMemory(const void* buffer, const Size& buffer_size,
80  PixelFormat pixel_format);
81  void saveToMemory(void* buffer);
82 
83 protected:
84  // Friends (to allow construction and destruction)
86  friend Texture& Direct3D9Renderer::createTexture(const String&, const String&);
88  friend Texture& Direct3D9Renderer::createTexture(LPDIRECT3DTEXTURE9 tex);
90 
94  Direct3D9Texture(Direct3D9Renderer& owner, const String& filename,
95  const String& resourceGroup);
97  Direct3D9Texture(Direct3D9Renderer& owner, const Size& sz);
99  Direct3D9Texture(Direct3D9Renderer& owner, LPDIRECT3DTEXTURE9 tex);
101  virtual ~Direct3D9Texture();
102 
104  void cleanupDirect3D9Texture();
106  void updateCachedScaleValues();
108  void updateTextureSize();
109 
113  LPDIRECT3DTEXTURE9 d_texture;
121  D3DSURFACE_DESC d_savedSurfaceDesc;
124 };
125 
126 } // End of CEGUI namespace section
127 
128 
129 #endif // end of guard _CEGUIDirect3D9Texture_h_