Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/Direct3D11/Renderer.h
1 /***********************************************************************
2  filename: CEGUIDirect3D11Renderer.h
3  created: Wed May 5 2010
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 _CEGUIDirect3D11Renderer_h_
28 #define _CEGUIDirect3D11Renderer_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 CEGUIDIRECT3D11RENDERER_EXPORTS
38 # define D3D11_GUIRENDERER_API __declspec(dllexport)
39 # else
40 # define D3D11_GUIRENDERER_API __declspec(dllimport)
41 # endif
42 #else
43 # define D3D11_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 ID3D11Device;
53 struct ID3D11DeviceContext;
54 struct ID3DX11Effect;//D3DXEffect11 in dependences
55 struct ID3DX11EffectTechnique;//D3DXEffect11 in dependences
56 struct ID3D11InputLayout;
57 struct ID3DX11EffectShaderResourceVariable;//D3DXEffect11 in dependences
58 struct ID3DX11EffectMatrixVariable;//D3DXEffect11 in dependences
59 struct ID3D11ShaderResourceView;//D3DXEffect11 in dependences
60 struct D3DXMATRIX;
61 
62 #include <d3d11.h>
63 #include <d3dx11.h>
64 #include <d3dx10.h>
65 
66 
67 struct IDevice11//little structure that keeps both device, in order to reduce copy & paste around module
68 {
70  ID3D11Device* d_device;
72  ID3D11DeviceContext* d_context;
73 };
74 
75 // Start of CEGUI namespace section
76 namespace CEGUI
77 {
78 class Direct3D11GeometryBuffer;
79 class Direct3D11Texture;
80 
81 
83 class D3D11_GUIRENDERER_API Direct3D11Renderer : public Renderer
84 {
85 public:
110  static Direct3D11Renderer& bootstrapSystem(ID3D11Device* device,
111  ID3D11DeviceContext* context,
112  const int abi = CEGUI_VERSION_ABI);
113 
129  static void destroySystem();
130 
135  static Direct3D11Renderer& create(ID3D11Device* device,ID3D11DeviceContext* context,
136  const int abi = CEGUI_VERSION_ABI);
137 
145  static void destroy(Direct3D11Renderer& renderer);
146 
147 // //! return the ID3D10Device used by this renderer object.
148 // ID3D11Device& getDirect3DDevice() const;
149 //
150 // //! return the ID3D11Device context used by this renderer object.
151 // ID3D11DeviceContext& getDirect3DDeviceContext() const;
152 
153  //returns d3d11 container for further rendering and creating
154  IDevice11& getDirect3DDevice();
155 
157  void bindTechniquePass(const BlendMode mode, const bool clipped);
159  void setCurrentTextureShaderResource(ID3D11ShaderResourceView* srv);
161  void setProjectionMatrix(D3DXMATRIX& matrix);
163  void setWorldMatrix(D3DXMATRIX& matrix);
164 
165  // Implement interface from Renderer
166  RenderTarget& getDefaultRenderTarget();
167  GeometryBuffer& createGeometryBuffer();
168  void destroyGeometryBuffer(const GeometryBuffer& buffer);
169  void destroyAllGeometryBuffers();
170  TextureTarget* createTextureTarget();
171  void destroyTextureTarget(TextureTarget* target);
172  void destroyAllTextureTargets();
173  Texture& createTexture(const String& name);
174  Texture& createTexture(const String& name,
175  const String& filename,
176  const String& resourceGroup);
177  Texture& createTexture(const String& name, const Sizef& size);
178  void destroyTexture(Texture& texture);
179  void destroyTexture(const String& name);
180  void destroyAllTextures();
181  Texture& getTexture(const String& name) const;
182  bool isTextureDefined(const String& name) const;
183  void beginRendering();
184  void endRendering();
185  void setDisplaySize(const Sizef& sz);
186  const Sizef& getDisplaySize() const;
187  const Vector2f& getDisplayDPI() const;
188  uint getMaxTextureSize() const;
189  const String& getIdentifierString() const;
190 
191 protected:
193  Direct3D11Renderer(ID3D11Device* device,ID3D11DeviceContext* context);
194 
197 
199  Sizef getViewportSize();
200 
202  void throwIfNameExists(const String& name) const;
204  static void logTextureCreation(const String& name);
206  static void logTextureDestruction(const String& name);
207 
211 
213 
221  typedef std::vector<TextureTarget*> TextureTargetList;
225  typedef std::vector<Direct3D11GeometryBuffer*> GeometryBufferList;
230  CEGUI_MAP_ALLOC(String, Direct3D11Texture*)> TextureMap;
234  ID3DX11Effect* d_effect;
236  ID3DX11EffectTechnique* d_normalClippedTechnique;
238  ID3DX11EffectTechnique* d_normalUnclippedTechnique;
240  ID3DX11EffectTechnique* d_premultipliedClippedTechnique;
242  ID3DX11EffectTechnique* d_premultipliedUnclippedTechnique;
244  ID3D11InputLayout* d_inputLayout;
246  ID3DX11EffectShaderResourceVariable* d_boundTextureVariable;
248  ID3DX11EffectMatrixVariable* d_worldMatrixVariable;
250  ID3DX11EffectMatrixVariable* d_projectionMatrixVariable;
251 };
252 
253 
254 } // End of CEGUI namespace section
255 
256 #if defined(_MSC_VER)
257 # pragma warning(pop)
258 #endif
259 
260 #endif // end of guard _CEGUIDirect3D11Renderer_h_