Crazy Eddie's GUI System  0.8.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/Direct3D10/Renderer.h
1 /***********************************************************************
2  filename: CEGUIDirect3D10Renderer.h
3  created: Sat Mar 7 2009
4  author: Paul D Turner (parts based on code by Rajko Stojadinovic)
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 _CEGUIDirect3D10Renderer_h_
29 #define _CEGUIDirect3D10Renderer_h_
30 
31 #include "../../Renderer.h"
32 #include "../../Size.h"
33 #include "../../Vector.h"
34 #include <vector>
35 #include <map>
36 
37 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
38 # ifdef CEGUIDIRECT3D10RENDERER_EXPORTS
39 # define D3D10_GUIRENDERER_API __declspec(dllexport)
40 # else
41 # define D3D10_GUIRENDERER_API __declspec(dllimport)
42 # endif
43 #else
44 # define D3D10_GUIRENDERER_API
45 #endif
46 
47 #if defined(_MSC_VER)
48 # pragma warning(push)
49 # pragma warning(disable : 4251)
50 #endif
51 
52 // D3D forward refs
53 struct ID3D10Device;
54 struct ID3D10Effect;
55 struct ID3D10EffectTechnique;
56 struct ID3D10InputLayout;
57 struct ID3D10EffectShaderResourceVariable;
58 struct ID3D10EffectMatrixVariable;
59 struct ID3D10ShaderResourceView;
60 struct D3DXMATRIX;
61 
62 // Start of CEGUI namespace section
63 namespace CEGUI
64 {
65 class Direct3D10GeometryBuffer;
66 class Direct3D10Texture;
67 
69 class D3D10_GUIRENDERER_API Direct3D10Renderer : public Renderer
70 {
71 public:
92  static Direct3D10Renderer& bootstrapSystem(ID3D10Device* device,
93  const int abi = CEGUI_VERSION_ABI);
94 
110  static void destroySystem();
111 
116  static Direct3D10Renderer& create(ID3D10Device* device,
117  const int abi = CEGUI_VERSION_ABI);
118 
126  static void destroy(Direct3D10Renderer& renderer);
127 
129  ID3D10Device& getDirect3DDevice() const;
130 
132  void bindTechniquePass(const BlendMode mode, const bool clipped);
134  void setCurrentTextureShaderResource(ID3D10ShaderResourceView* srv);
136  void setProjectionMatrix(D3DXMATRIX& matrix);
138  void setWorldMatrix(D3DXMATRIX& matrix);
139 
140  // Implement interface from Renderer
141  RenderTarget& getDefaultRenderTarget();
142  GeometryBuffer& createGeometryBuffer();
143  void destroyGeometryBuffer(const GeometryBuffer& buffer);
144  void destroyAllGeometryBuffers();
145  TextureTarget* createTextureTarget();
146  void destroyTextureTarget(TextureTarget* target);
147  void destroyAllTextureTargets();
148  Texture& createTexture(const String& name);
149  Texture& createTexture(const String& name,
150  const String& filename,
151  const String& resourceGroup);
152  Texture& createTexture(const String& name, const Sizef& size);
153  void destroyTexture(Texture& texture);
154  void destroyTexture(const String& name);
155  void destroyAllTextures();
156  Texture& getTexture(const String& name) const;
157  bool isTextureDefined(const String& name) const;
158  void beginRendering();
159  void endRendering();
160  void setDisplaySize(const Sizef& sz);
161  const Sizef& getDisplaySize() const;
162  const Vector2f& getDisplayDPI() const;
163  uint getMaxTextureSize() const;
164  const String& getIdentifierString() const;
165 
166 protected:
168  Direct3D10Renderer(ID3D10Device* device);
169 
172 
174  Sizef getViewportSize();
175 
177  void throwIfNameExists(const String& name) const;
179  static void logTextureCreation(const String& name);
181  static void logTextureDestruction(const String& name);
182 
186  ID3D10Device* d_device;
194  typedef std::vector<TextureTarget*> TextureTargetList;
198  typedef std::vector<Direct3D10GeometryBuffer*> GeometryBufferList;
203  CEGUI_MAP_ALLOC(String, Direct3D10Texture*)> TextureMap;
207  ID3D10Effect* d_effect;
209  ID3D10EffectTechnique* d_normalClippedTechnique;
211  ID3D10EffectTechnique* d_normalUnclippedTechnique;
213  ID3D10EffectTechnique* d_premultipliedClippedTechnique;
215  ID3D10EffectTechnique* d_premultipliedUnclippedTechnique;
217  ID3D10InputLayout* d_inputLayout;
219  ID3D10EffectShaderResourceVariable* d_boundTextureVariable;
221  ID3D10EffectMatrixVariable* d_worldMatrixVariable;
223  ID3D10EffectMatrixVariable* d_projectionMatrixVariable;
224 };
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 _CEGUIDirect3D10Renderer_h_