Crazy Eddies GUI System  0.7.9
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
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_
Class used as a two dimensional vector (aka a Point)
Definition: CEGUIVector.h:45
ID3DX11EffectShaderResourceVariable * d_boundTextureVariable
Variable to access current texture (actually shader resource view)
Definition: CEGUIDirect3D11Renderer.h:225
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: CEGUIGeometryBuffer.h:42
Class that holds the size (width &amp; height) of something.
Definition: CEGUISize.h:43
ID3D11Device * d_device
The D3D device context we&#39;re using to create various resources with.
Definition: CEGUIDirect3D11Renderer.h:69
Specialisation of RenderTarget interface that should be used as the base class for RenderTargets that...
Definition: CEGUITextureTarget.h:41
ID3DX11EffectTechnique * d_premultipliedTechnique
Rendering technique that supplies BM_RTT_PREMULTIPLIED type rendering.
Definition: CEGUIDirect3D11Renderer.h:221
Size d_displaySize
What the renderer considers to be the current display size.
Definition: CEGUIDirect3D11Renderer.h:197
TextureList d_textures
Container used to track textures.
Definition: CEGUIDirect3D11Renderer.h:215
RenderTarget * d_defaultTarget
The default RenderTarget (used by d_defaultRoot)
Definition: CEGUIDirect3D11Renderer.h:201
ID3D11DeviceContext * d_context
The D3D device context we&#39;re using to render.
Definition: CEGUIDirect3D11Renderer.h:71
Definition: CEGUIDirect3D11Renderer.h:66
static String d_rendererID
String holding the renderer identification text.
Definition: CEGUIDirect3D11Renderer.h:191
Abstract base class specifying the required interface for Texture objects.
Definition: CEGUITexture.h:50
GeometryBufferList d_geometryBuffers
Container used to track geometry buffers.
Definition: CEGUIDirect3D11Renderer.h:211
Abstract class defining the basic required interface for Renderer objects.
Definition: CEGUIRenderer.h:80
BlendMode
Enumerated type that contains the valid options that specify the type of blending that is to be perfo...
Definition: CEGUIRenderer.h:59
Definition: CEGUIRenderingRoot.h:36
std::vector< Direct3D11GeometryBuffer * > GeometryBufferList
container type used to hold GeometryBuffers we create.
Definition: CEGUIDirect3D11Renderer.h:209
Defines interface to some surface that can be rendered to. Concrete instances of objects that impleme...
Definition: CEGUIRenderTarget.h:42
TextureTargetList d_textureTargets
Container used to track texture targets.
Definition: CEGUIDirect3D11Renderer.h:207
IDevice11 d_device
The D3D device we&#39;re using to render with.
Definition: CEGUIDirect3D11Renderer.h:194
Renderer implementation using Direct3D 10.
Definition: CEGUIDirect3D11Renderer.h:82
ID3D11InputLayout * d_inputLayout
D3D10 input layout describing the vertex format we use.
Definition: CEGUIDirect3D11Renderer.h:223
std::vector< Direct3D11Texture * > TextureList
container type used to hold Textures we create.
Definition: CEGUIDirect3D11Renderer.h:213
ID3DX11EffectMatrixVariable * d_worldMatrixVariable
Variable to access world matrix used in geometry transformation.
Definition: CEGUIDirect3D11Renderer.h:227
Vector2 d_displayDPI
What the renderer considers to be the current display DPI resolution.
Definition: CEGUIDirect3D11Renderer.h:199
std::vector< TextureTarget * > TextureTargetList
container type used to hold TextureTargets we create.
Definition: CEGUIDirect3D11Renderer.h:205
RenderingRoot * d_defaultRoot
The default rendering root object.
Definition: CEGUIDirect3D11Renderer.h:203
ID3DX11EffectTechnique * d_normalTechnique
Rendering technique that supplies BM_NORMAL type rendering.
Definition: CEGUIDirect3D11Renderer.h:219
ID3DX11EffectMatrixVariable * d_projectionMatrixVariable
Variable to access projection matrix used in geometry transformation.
Definition: CEGUIDirect3D11Renderer.h:229
ID3DX11Effect * d_effect
Effect (shader) used when rendering.
Definition: CEGUIDirect3D11Renderer.h:217
String class used within the GUI system.
Definition: CEGUIString.h:57