Crazy Eddies GUI System  0.7.9
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
CEGUIDirect3D9Renderer.h
1 /***********************************************************************
2  filename: CEGUIDirect3D9Renderer.h
3  created: Mon Feb 9 2009
4  author: Paul D Turner
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2010 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 "../../CEGUIBase.h"
32 #include "../../CEGUIRenderer.h"
33 #include "../../CEGUISize.h"
34 #include "../../CEGUIVector.h"
35 
36 #include <d3d9.h>
37 #include <vector>
38 
39 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
40 # ifdef DIRECT3D9_GUIRENDERER_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:
84  static Direct3D9Renderer& bootstrapSystem(LPDIRECT3DDEVICE9 device);
85 
101  static void destroySystem();
102 
107  static Direct3D9Renderer& create(LPDIRECT3DDEVICE9 device);
108 
116  static void destroy(Direct3D9Renderer& renderer);
117 
119  void preD3DReset();
120 
122  void postD3DReset();
123 
125  LPDIRECT3DDEVICE9 getDevice() const;
126 
128  Texture& createTexture(LPDIRECT3DTEXTURE9 tex);
129 
131  bool supportsNonSquareTexture();
132 
134  bool supportsNPOTTextures();
135 
137  Size getAdjustedSize(const Size& sz);
138 
140  void setupRenderingBlendMode(const BlendMode mode,
141  const bool force = false);
142 
143  // implement Renderer interface
144  RenderingRoot& getDefaultRenderingRoot();
145  GeometryBuffer& createGeometryBuffer();
146  void destroyGeometryBuffer(const GeometryBuffer& buffer);
147  void destroyAllGeometryBuffers();
148  TextureTarget* createTextureTarget();
149  void destroyTextureTarget(TextureTarget* target);
150  void destroyAllTextureTargets();
151  Texture& createTexture();
152  Texture& createTexture(const String& filename, const String& resourceGroup);
153  Texture& createTexture(const Size& size);
154  void destroyTexture(Texture& texture);
155  void destroyAllTextures();
156  void beginRendering();
157  void endRendering();
158  void setDisplaySize(const Size& sz);
159  const Size& getDisplaySize() const;
160  const Vector2& getDisplayDPI() const;
161  uint getMaxTextureSize() const;
162  const String& getIdentifierString() const;
163 
164 private:
166  Direct3D9Renderer(LPDIRECT3DDEVICE9 device);
167 
169  virtual ~Direct3D9Renderer();
170 
172  Size getViewportSize();
174  float getSizeNextPOT(float sz) const;
175 
177  static String d_rendererID;
179  LPDIRECT3DDEVICE9 d_device;
181  Size d_displaySize;
183  Vector2 d_displayDPI;
185  RenderingRoot* d_defaultRoot;
187  RenderTarget* d_defaultTarget;
189  typedef std::vector<TextureTarget*> TextureTargetList;
191  TextureTargetList d_textureTargets;
193  typedef std::vector<Direct3D9GeometryBuffer*> GeometryBufferList;
195  GeometryBufferList d_geometryBuffers;
197  typedef std::vector<Direct3D9Texture*> TextureList;
199  TextureList d_textures;
201  uint d_maxTextureSize;
203  bool d_supportNPOTTex;
205  bool d_supportNonSquareTex;
207  BlendMode d_activeBlendMode;
208  };
209 
210 } // End of CEGUI namespace section
211 
212 #if defined(_MSC_VER)
213 # pragma warning(pop)
214 #endif
215 
216 #endif // end of guard _CEGUIDirect3D9Renderer_h_