Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/Direct3D9/Renderer.h
1 /***********************************************************************
2  created: Mon Feb 9 2009
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2011 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 _CEGUIDirect3D9Renderer_h_
28 #define _CEGUIDirect3D9Renderer_h_
29 
30 #include "../../Base.h"
31 #include "../../Renderer.h"
32 #include "../../Size.h"
33 #include "../../Vector.h"
34 
35 #include <d3d9.h>
36 #include <vector>
37 #include <map>
38 
39 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
40 # ifdef CEGUIDIRECT3D9RENDERER_EXPORTS
41 # define DIRECT3D9_GUIRENDERER_API __declspec(dllexport)
42 # else
43 # define DIRECT3D9_GUIRENDERER_API __declspec(dllimport)
44 # endif
45 #else
46 # define DIRECT3D9_GUIRENDERER_API
47 #endif
48 
49 #if defined(_MSC_VER)
50 # pragma warning(push)
51 # pragma warning(disable : 4251)
52 #endif
53 
54 // Start of CEGUI namespace section
55 namespace CEGUI
56 {
57 class Direct3D9Texture;
58 class Direct3D9GeometryBuffer;
59 
64 class DIRECT3D9_GUIRENDERER_API Direct3D9Renderer : public Renderer
65 {
66 public:
87  static Direct3D9Renderer& bootstrapSystem(LPDIRECT3DDEVICE9 device,
88  const int abi = CEGUI_VERSION_ABI);
89 
105  static void destroySystem();
106 
111  static Direct3D9Renderer& create(LPDIRECT3DDEVICE9 device,
112  const int abi = CEGUI_VERSION_ABI);
113 
121  static void destroy(Direct3D9Renderer& renderer);
122 
124  void preD3DReset();
125 
127  void postD3DReset();
128 
130  LPDIRECT3DDEVICE9 getDevice() const;
131 
133  Texture& createTexture(const String& name, LPDIRECT3DTEXTURE9 tex);
134 
136  bool supportsNonSquareTexture();
137 
139  bool supportsNPOTTextures();
140 
142  Sizef getAdjustedSize(const Sizef& sz);
143 
145  void setupRenderingBlendMode(const BlendMode mode,
146  const bool force = false);
147 
148  // implement Renderer interface
149  RenderTarget& getDefaultRenderTarget();
150  GeometryBuffer& createGeometryBuffer();
151  void destroyGeometryBuffer(const GeometryBuffer& buffer);
152  void destroyAllGeometryBuffers();
153  TextureTarget* createTextureTarget();
154  void destroyTextureTarget(TextureTarget* target);
155  void destroyAllTextureTargets();
156  Texture& createTexture(const String& name);
157  Texture& createTexture(const String& name,
158  const String& filename,
159  const String& resourceGroup);
160  Texture& createTexture(const String& name, const Sizef& size);
161  void destroyTexture(Texture& texture);
162  void destroyTexture(const String& name);
163  void destroyAllTextures();
164  Texture& getTexture(const String& name) const;
165  bool isTextureDefined(const String& name) const;
166  void beginRendering();
167  void endRendering();
168  void setDisplaySize(const Sizef& sz);
169  const Sizef& getDisplaySize() const;
170  const Vector2f& getDisplayDPI() const;
171  uint getMaxTextureSize() const;
172  const String& getIdentifierString() const;
173 
174 private:
176  Direct3D9Renderer(LPDIRECT3DDEVICE9 device);
177 
179  virtual ~Direct3D9Renderer();
180 
182  void throwIfNameExists(const String& name) const;
184  static void logTextureCreation(const String& name);
186  static void logTextureDestruction(const String& name);
187 
189  Sizef getViewportSize();
191  float getSizeNextPOT(float sz) const;
192 
194  static String d_rendererID;
196  LPDIRECT3DDEVICE9 d_device;
198  Sizef d_displaySize;
200  Vector2f d_displayDPI;
202  RenderTarget* d_defaultTarget;
204  typedef std::vector<TextureTarget*> TextureTargetList;
206  TextureTargetList d_textureTargets;
208  typedef std::vector<Direct3D9GeometryBuffer*> GeometryBufferList;
210  GeometryBufferList d_geometryBuffers;
212  typedef std::map<String, Direct3D9Texture*, StringFastLessCompare
213  CEGUI_MAP_ALLOC(String, Direct3D9Texture*)> TextureMap;
215  TextureMap d_textures;
217  uint d_maxTextureSize;
219  bool d_supportNPOTTex;
221  bool d_supportNonSquareTex;
223  BlendMode d_activeBlendMode;
224  };
225 
226 } // End of CEGUI namespace section
227 
228 #if defined(_MSC_VER)
229 # pragma warning(pop)
230 #endif
231 
232 #endif // end of guard _CEGUIDirect3D9Renderer_h_