Crazy Eddies GUI System  0.6.2
d3d9texture.h
1 /***********************************************************************
2  filename: d3d9texture.h
3  created: 17/7/2004
4  author: Paul D Turner with D3D 9 Updates by Magnus Österlind
5 
6  purpose: Defines concrete texture class for D3D9.0
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _d3d9texture_h_
31 #define _d3d9texture_h_
32 
33 #include "CEGUIBase.h"
34 #include "CEGUIRenderer.h"
35 #include "CEGUITexture.h"
36 #include "d3d9renderer.h"
37 #include <d3d9.h>
38 #include <list>
39 
40 // Start of CEGUI namespace section
41 namespace CEGUI
42 {
43 
48 class DIRECTX9_GUIRENDERER_API DirectX9Texture : public Texture
49 {
50 private:
51  /*************************************************************************
52  Friends (to allow construction and destruction)
53  *************************************************************************/
55  friend Texture* DirectX9Renderer::createTexture(const String& filename, const String& resourceGroup);
56  friend Texture* DirectX9Renderer::createTexture(float size);
57  friend void DirectX9Renderer::destroyTexture(Texture* texture);
58 
59 
60  /*************************************************************************
61  Construction & Destruction (by Renderer object only)
62  *************************************************************************/
63  DirectX9Texture(Renderer* owner);
64  virtual ~DirectX9Texture(void);
65 
66 public:
74  virtual ushort getWidth(void) const {return d_width;}
75 
76 
84  virtual ushort getHeight(void) const {return d_height;}
85 
86  virtual ushort getOriginalWidth(void) const { return d_orgWidth; }
87  virtual ushort getOriginalHeight(void) const { return d_orgHeight; }
88 
102  virtual void loadFromFile(const String& filename, const String& resourceGroup);
103 
104 
124  virtual void loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight, PixelFormat pixelFormat);
125 
126 
134  LPDIRECT3DTEXTURE9 getD3DTexture(void) const {return d_d3dtexture;}
135 
136 
137  //
148  void setD3DTextureSize(uint size);
149 
150 
162  virtual void preD3DReset(void);
163 
164 
176  virtual void postD3DReset(void);
177 
178 
179 private:
180  /*************************************************************************
181  Implementation Functions
182  *************************************************************************/
183  // safely free direc3d texture (can be called multiple times with no ill effect)
184  void freeD3DTexture(void);
185  // obtain and fill-in the real texture dimensions.
186  // d_orgWidth and d_orgHeight should be set before calling this, since
187  // they are used as fall-back values if the query fails.
188  void obtainActualTextureSize(void);
189 
190 
191  /*************************************************************************
192  Implementation Data
193  *************************************************************************/
194  LPDIRECT3DTEXTURE9 d_d3dtexture;
195  String d_filename;
196  String d_resourceGroup;
197  bool d_isMemoryTexture;
198 
199  ushort d_width;
200  ushort d_height;
201  ushort d_orgWidth;
202  ushort d_orgHeight;
203 };
204 
205 } // End of CEGUI namespace section
206 
207 
208 #endif // end of guard _d3d9texture_h_