Crazy Eddie's GUI System  0.8.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/Direct3D9/Renderer.h
1 /***********************************************************************
2  filename: CEGUIDirect3D9Renderer.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 _CEGUIDirect3D9Renderer_h_
29 #define _CEGUIDirect3D9Renderer_h_
30 
31 #include "../../Base.h"
32 #include "../../Renderer.h"
33 #include "../../Size.h"
34 #include "../../Vector.h"
35 
36 #include <d3d9.h>
37 #include <vector>
38 #include <map>
39 
40 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
41 # ifdef CEGUIDIRECT3D9RENDERER_EXPORTS
42 # define DIRECT3D9_GUIRENDERER_API __declspec(dllexport)
43 # else
44 # define DIRECT3D9_GUIRENDERER_API __declspec(dllimport)
45 # endif
46 #else
47 # define DIRECT3D9_GUIRENDERER_API
48 #endif
49 
50 #if defined(_MSC_VER)
51 # pragma warning(push)
52 # pragma warning(disable : 4251)
53 #endif
54 
55 // Start of CEGUI namespace section
56 namespace CEGUI
57 {
58 class Direct3D9Texture;
59 class Direct3D9GeometryBuffer;
60 
65 class DIRECT3D9_GUIRENDERER_API Direct3D9Renderer : public Renderer
66 {
67 public:
88  static Direct3D9Renderer& bootstrapSystem(LPDIRECT3DDEVICE9 device,
89  const int abi = CEGUI_VERSION_ABI);
90 
106  static void destroySystem();
107 
112  static Direct3D9Renderer& create(LPDIRECT3DDEVICE9 device,
113  const int abi = CEGUI_VERSION_ABI);
114 
122  static void destroy(Direct3D9Renderer& renderer);
123 
125  void preD3DReset();
126 
128  void postD3DReset();
129 
131  LPDIRECT3DDEVICE9 getDevice() const;
132 
134  Texture& createTexture(const String& name, LPDIRECT3DTEXTURE9 tex);
135 
137  bool supportsNonSquareTexture();
138 
140  bool supportsNPOTTextures();
141 
143  Sizef getAdjustedSize(const Sizef& sz);
144 
146  void setupRenderingBlendMode(const BlendMode mode,
147  const bool force = false);
148 
149  // implement Renderer interface
150  RenderTarget& getDefaultRenderTarget();
151  GeometryBuffer& createGeometryBuffer();
152  void destroyGeometryBuffer(const GeometryBuffer& buffer);
153  void destroyAllGeometryBuffers();
154  TextureTarget* createTextureTarget();
155  void destroyTextureTarget(TextureTarget* target);
156  void destroyAllTextureTargets();
157  Texture& createTexture(const String& name);
158  Texture& createTexture(const String& name,
159  const String& filename,
160  const String& resourceGroup);
161  Texture& createTexture(const String& name, const Sizef& size);
162  void destroyTexture(Texture& texture);
163  void destroyTexture(const String& name);
164  void destroyAllTextures();
165  Texture& getTexture(const String& name) const;
166  bool isTextureDefined(const String& name) const;
167  void beginRendering();
168  void endRendering();
169  void setDisplaySize(const Sizef& sz);
170  const Sizef& getDisplaySize() const;
171  const Vector2f& getDisplayDPI() const;
172  uint getMaxTextureSize() const;
173  const String& getIdentifierString() const;
174 
175 private:
177  Direct3D9Renderer(LPDIRECT3DDEVICE9 device);
178 
180  virtual ~Direct3D9Renderer();
181 
183  void throwIfNameExists(const String& name) const;
185  static void logTextureCreation(const String& name);
187  static void logTextureDestruction(const String& name);
188 
190  Sizef getViewportSize();
192  float getSizeNextPOT(float sz) const;
193 
195  static String d_rendererID;
197  LPDIRECT3DDEVICE9 d_device;
199  Sizef d_displaySize;
201  Vector2f d_displayDPI;
203  RenderTarget* d_defaultTarget;
205  typedef std::vector<TextureTarget*> TextureTargetList;
207  TextureTargetList d_textureTargets;
209  typedef std::vector<Direct3D9GeometryBuffer*> GeometryBufferList;
211  GeometryBufferList d_geometryBuffers;
213  typedef std::map<String, Direct3D9Texture*, StringFastLessCompare
214  CEGUI_MAP_ALLOC(String, Direct3D9Texture*)> TextureMap;
216  TextureMap d_textures;
218  uint d_maxTextureSize;
220  bool d_supportNPOTTex;
222  bool d_supportNonSquareTex;
224  BlendMode d_activeBlendMode;
225  };
226 
227 } // End of CEGUI namespace section
228 
229 #if defined(_MSC_VER)
230 # pragma warning(pop)
231 #endif
232 
233 #endif // end of guard _CEGUIDirect3D9Renderer_h_