Crazy Eddies GUI System  0.7.2
CEGUIDirect3D11Renderer.h
1 /***********************************************************************
2  filename: CEGUIDirect3D11Renderer.h
3  created: Wed May 5 2010
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2010 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 "../../CEGUIRenderer.h"
31 #include "../../CEGUISize.h"
32 #include "../../CEGUIVector.h"
33 #include <vector>
34 
35 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
36 # ifdef DIRECT3D11_GUIRENDERER_EXPORTS
37 # define D3D11_GUIRENDERER_API __declspec(dllexport)
38 # else
39 # define D3D11_GUIRENDERER_API __declspec(dllimport)
40 # endif
41 #else
42 # define D3D11_GUIRENDERER_API
43 #endif
44 
45 #if defined(_MSC_VER)
46 # pragma warning(push)
47 # pragma warning(disable : 4251)
48 #endif
49 
50 // D3D forward refs
51 struct ID3D11Device;
52 struct ID3D11DeviceContext;
53 struct ID3DX11Effect;//D3DXEffect11 in dependences
54 struct ID3DX11EffectTechnique;//D3DXEffect11 in dependences
55 struct ID3D11InputLayout;
56 struct ID3DX11EffectShaderResourceVariable;//D3DXEffect11 in dependences
57 struct ID3DX11EffectMatrixVariable;//D3DXEffect11 in dependences
58 struct ID3D11ShaderResourceView;//D3DXEffect11 in dependences
59 struct D3DXMATRIX;
60 
61 #include <d3d11.h>
62 #include <d3dx11.h>
63 #include <d3dx10.h>
64 
65 
66 struct IDevice11//little structure that keeps both device, in order to reduce copy & paste around module
67 {
69  ID3D11Device* d_device;
71  ID3D11DeviceContext* d_context;
72 };
73 
74 // Start of CEGUI namespace section
75 namespace CEGUI
76 {
77 class Direct3D11GeometryBuffer;
78 class Direct3D11Texture;
79 
80 
82 class D3D11_GUIRENDERER_API Direct3D11Renderer : public Renderer
83 {
84 public:
106  static Direct3D11Renderer& bootstrapSystem(ID3D11Device* device,
107  ID3D11DeviceContext* context);
108 
124  static void destroySystem();
125 
130  static Direct3D11Renderer& create(ID3D11Device* device,ID3D11DeviceContext* context);
131 
139  static void destroy(Direct3D11Renderer& renderer);
140 
141 // //! return the ID3D10Device used by this renderer object.
142 // ID3D11Device& getDirect3DDevice() const;
143 //
144 // //! return the ID3D11Device context used by this renderer object.
145 // ID3D11DeviceContext& getDirect3DDeviceContext() const;
146 
147  //returns d3d11 container for further rendering and creating
148  IDevice11& getDirect3DDevice();
149 
151  void bindTechniquePass(const BlendMode mode);
153  void setCurrentTextureShaderResource(ID3D11ShaderResourceView* srv);
155  void setProjectionMatrix(D3DXMATRIX& matrix);
157  void setWorldMatrix(D3DXMATRIX& matrix);
158 
159  // Implement interface from Renderer
160  RenderingRoot& getDefaultRenderingRoot();
161  GeometryBuffer& createGeometryBuffer();
162  void destroyGeometryBuffer(const GeometryBuffer& buffer);
163  void destroyAllGeometryBuffers();
164  TextureTarget* createTextureTarget();
165  void destroyTextureTarget(TextureTarget* target);
166  void destroyAllTextureTargets();
167  Texture& createTexture();
168  Texture& createTexture(const String& filename, const String& resourceGroup);
169  Texture& createTexture(const Size& size);
170  void destroyTexture(Texture& texture);
171  void destroyAllTextures();
172  void beginRendering();
173  void endRendering();
174  void setDisplaySize(const Size& sz);
175  const Size& getDisplaySize() const;
176  const Vector2& getDisplayDPI() const;
177  uint getMaxTextureSize() const;
178  const String& getIdentifierString() const;
179 
180 protected:
182  Direct3D11Renderer(ID3D11Device* device,ID3D11DeviceContext* context);
183 
186 
188  Size getViewportSize();
189 
193 
195 
205  typedef std::vector<TextureTarget*> TextureTargetList;
209  typedef std::vector<Direct3D11GeometryBuffer*> GeometryBufferList;
213  typedef std::vector<Direct3D11Texture*> TextureList;
217  ID3DX11Effect* d_effect;
219  ID3DX11EffectTechnique* d_normalTechnique;
221  ID3DX11EffectTechnique* d_premultipliedTechnique;
223  ID3D11InputLayout* d_inputLayout;
225  ID3DX11EffectShaderResourceVariable* d_boundTextureVariable;
227  ID3DX11EffectMatrixVariable* d_worldMatrixVariable;
229  ID3DX11EffectMatrixVariable* d_projectionMatrixVariable;
230 };
231 
232 
233 } // End of CEGUI namespace section
234 
235 #if defined(_MSC_VER)
236 # pragma warning(pop)
237 #endif
238 
239 #endif // end of guard _CEGUIDirect3D11Renderer_h_