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