Crazy Eddies GUI System  0.7.1
CEGUIDirect3D9Renderer.h
1 /***********************************************************************
2  filename: CEGUIDirect3D9Renderer.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 _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:
71  static Direct3D9Renderer& create(LPDIRECT3DDEVICE9 device);
72 
80  static void destroy(Direct3D9Renderer& renderer);
81 
83  void preD3DReset();
84 
86  void postD3DReset();
87 
89  LPDIRECT3DDEVICE9 getDevice() const;
90 
92  Texture& createTexture(LPDIRECT3DTEXTURE9 tex);
93 
95  bool supportsNonSquareTexture();
96 
98  bool supportsNPOTTextures();
99 
101  Size getAdjustedSize(const Size& sz);
102 
103  // implement Renderer interface
104  RenderingRoot& getDefaultRenderingRoot();
105  GeometryBuffer& createGeometryBuffer();
106  void destroyGeometryBuffer(const GeometryBuffer& buffer);
107  void destroyAllGeometryBuffers();
108  TextureTarget* createTextureTarget();
109  void destroyTextureTarget(TextureTarget* target);
110  void destroyAllTextureTargets();
111  Texture& createTexture();
112  Texture& createTexture(const String& filename, const String& resourceGroup);
113  Texture& createTexture(const Size& size);
114  void destroyTexture(Texture& texture);
115  void destroyAllTextures();
116  void beginRendering();
117  void endRendering();
118  void setDisplaySize(const Size& sz);
119  const Size& getDisplaySize() const;
120  const Vector2& getDisplayDPI() const;
121  uint getMaxTextureSize() const;
122  const String& getIdentifierString() const;
123 
124 private:
126  Direct3D9Renderer(LPDIRECT3DDEVICE9 device);
127 
129  virtual ~Direct3D9Renderer();
130 
132  Size getViewportSize();
134  float getSizeNextPOT(float sz) const;
135 
137  static String d_rendererID;
139  LPDIRECT3DDEVICE9 d_device;
141  Size d_displaySize;
143  Vector2 d_displayDPI;
145  RenderingRoot* d_defaultRoot;
147  RenderTarget* d_defaultTarget;
149  typedef std::vector<TextureTarget*> TextureTargetList;
151  TextureTargetList d_textureTargets;
153  typedef std::vector<Direct3D9GeometryBuffer*> GeometryBufferList;
155  GeometryBufferList d_geometryBuffers;
157  typedef std::vector<Direct3D9Texture*> TextureList;
159  TextureList d_textures;
161  uint d_maxTextureSize;
163  bool d_supportNPOTTex;
165  bool d_supportNonSquareTex;
166  };
167 
168 } // End of CEGUI namespace section
169 
170 #if defined(_MSC_VER)
171 # pragma warning(pop)
172 #endif
173 
174 #endif // end of guard _CEGUIDirect3D9Renderer_h_