Crazy Eddie's GUI System  0.8.7
RendererModules/Direct3D11/Renderer.h
1 /***********************************************************************
2  created: Wed May 5 2010
3 *************************************************************************/
4 /***************************************************************************
5  * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24  * OTHER DEALINGS IN THE SOFTWARE.
25  ***************************************************************************/
26 #ifndef _CEGUIDirect3D11Renderer_h_
27 #define _CEGUIDirect3D11Renderer_h_
28 
29 #include "../../Renderer.h"
30 #include "../../Size.h"
31 #include "../../Vector.h"
32 #include <vector>
33 #include <map>
34 
35 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
36 # ifdef CEGUIDIRECT3D11RENDERER_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:
109  static Direct3D11Renderer& bootstrapSystem(ID3D11Device* device,
110  ID3D11DeviceContext* context,
111  const int abi = CEGUI_VERSION_ABI);
112 
128  static void destroySystem();
129 
134  static Direct3D11Renderer& create(ID3D11Device* device,ID3D11DeviceContext* context,
135  const int abi = CEGUI_VERSION_ABI);
136 
144  static void destroy(Direct3D11Renderer& renderer);
145 
146 // //! return the ID3D10Device used by this renderer object.
147 // ID3D11Device& getDirect3DDevice() const;
148 //
149 // //! return the ID3D11Device context used by this renderer object.
150 // ID3D11DeviceContext& getDirect3DDeviceContext() const;
151 
152  //returns d3d11 container for further rendering and creating
153  IDevice11& getDirect3DDevice();
154 
170  bool isTexCoordSystemFlipped() const { return false; }
171 
173  void bindTechniquePass(const BlendMode mode, const bool clipped);
175  void setCurrentTextureShaderResource(ID3D11ShaderResourceView* srv);
177  void setProjectionMatrix(D3DXMATRIX& matrix);
179  void setWorldMatrix(D3DXMATRIX& matrix);
180 
181  // Implement interface from Renderer
189  Texture& createTexture(const String& name);
191  const String& filename,
192  const String& resourceGroup);
193  Texture& createTexture(const String& name, const Sizef& size);
194  void destroyTexture(Texture& texture);
195  void destroyTexture(const String& name);
197  Texture& getTexture(const String& name) const;
198  bool isTextureDefined(const String& name) const;
200  void endRendering();
201  void setDisplaySize(const Sizef& sz);
202  const Sizef& getDisplaySize() const;
203  const Vector2f& getDisplayDPI() const;
204  uint getMaxTextureSize() const;
205  const String& getIdentifierString() const;
206 
207 protected:
209  Direct3D11Renderer(ID3D11Device* device,ID3D11DeviceContext* context);
210 
213 
216 
218  void throwIfNameExists(const String& name) const;
220  static void logTextureCreation(const String& name);
222  static void logTextureDestruction(const String& name);
223 
227 
229 
237  typedef std::vector<TextureTarget*> TextureTargetList;
241  typedef std::vector<Direct3D11GeometryBuffer*> GeometryBufferList;
246  CEGUI_MAP_ALLOC(String, Direct3D11Texture*)> TextureMap;
250  ID3DX11Effect* d_effect;
252  ID3DX11EffectTechnique* d_normalClippedTechnique;
254  ID3DX11EffectTechnique* d_normalUnclippedTechnique;
256  ID3DX11EffectTechnique* d_premultipliedClippedTechnique;
258  ID3DX11EffectTechnique* d_premultipliedUnclippedTechnique;
260  ID3D11InputLayout* d_inputLayout;
262  ID3DX11EffectShaderResourceVariable* d_boundTextureVariable;
264  ID3DX11EffectMatrixVariable* d_worldMatrixVariable;
266  ID3DX11EffectMatrixVariable* d_projectionMatrixVariable;
267 };
268 
269 
270 } // End of CEGUI namespace section
271 
272 #if defined(_MSC_VER)
273 # pragma warning(pop)
274 #endif
275 
276 #endif // end of guard _CEGUIDirect3D11Renderer_h_
CEGUI::GeometryBuffer
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:44
IDevice11
Definition: RendererModules/Direct3D11/Renderer.h:67
CEGUI::Direct3D11Renderer::logTextureCreation
static void logTextureCreation(const String &name)
helper to safely log the creation of a named texture
CEGUI::Direct3D11Renderer::logTextureDestruction
static void logTextureDestruction(const String &name)
helper to safely log the destruction of a named texture
CEGUI::Direct3D11Renderer::createTextureTarget
TextureTarget * createTextureTarget()
Create a TextureTarget that can be used to cache imagery; this is a RenderTarget that does not lose i...
CEGUI::Direct3D11Renderer::isTextureDefined
bool isTextureDefined(const String &name) const
Return whether a texture with the given name exists.
CEGUI::Direct3D11Renderer::bootstrapSystem
static Direct3D11Renderer & bootstrapSystem(ID3D11Device *device, ID3D11DeviceContext *context, const int abi=CEGUI_VERSION_ABI)
Convenience function that creates the required objects to initialise the CEGUI system.
CEGUI::Direct3D11Renderer::d_inputLayout
ID3D11InputLayout * d_inputLayout
D3D11 input layout describing the vertex format we use.
Definition: RendererModules/Direct3D11/Renderer.h:260
CEGUI::Direct3D11Renderer::destroyTexture
void destroyTexture(const String &name)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::Direct3D11Renderer::d_boundTextureVariable
ID3DX11EffectShaderResourceVariable * d_boundTextureVariable
Variable to access current texture (actually shader resource view)
Definition: RendererModules/Direct3D11/Renderer.h:262
CEGUI::Direct3D11Renderer::destroyAllTextures
void destroyAllTextures()
Destroy all Texture objects created by this Renderer.
CEGUI::Direct3D11Renderer::setWorldMatrix
void setWorldMatrix(D3DXMATRIX &matrix)
low-level function to set the world matrix to be used.
CEGUI::Direct3D11Renderer::d_textureTargets
TextureTargetList d_textureTargets
Container used to track texture targets.
Definition: RendererModules/Direct3D11/Renderer.h:239
CEGUI::Direct3D11Renderer::~Direct3D11Renderer
~Direct3D11Renderer()
destructor.
CEGUI::StringFastLessCompare
Functor that can be used as comparator in a std::map with String keys. It's faster than using the def...
Definition: String.h:5580
CEGUI::Direct3D11Renderer::getViewportSize
Sizef getViewportSize()
return size of the D3D device viewport.
CEGUI::Direct3D11Renderer::createGeometryBuffer
GeometryBuffer & createGeometryBuffer()
Create a new GeometryBuffer and return a reference to it. You should remove the GeometryBuffer from a...
CEGUI::Direct3D11Renderer::getTexture
Texture & getTexture(const String &name) const
Return a Texture object that was previously created by calling the createTexture functions.
CEGUI::Direct3D11Renderer::d_rendererID
static String d_rendererID
String holding the renderer identification text.
Definition: RendererModules/Direct3D11/Renderer.h:225
CEGUI::Direct3D11Renderer::destroyTextureTarget
void destroyTextureTarget(TextureTarget *target)
Function that cleans up TextureTarget objects created with the createTextureTarget function.
CEGUI::Direct3D11Renderer::getDefaultRenderTarget
RenderTarget & getDefaultRenderTarget()
Returns the default RenderTarget object. The default render target is is typically one that targets t...
CEGUI::Direct3D11Renderer::destroyAllGeometryBuffers
void destroyAllGeometryBuffers()
Destroy all GeometryBuffer objects created by this Renderer.
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::Direct3D11Renderer::TextureMap
std::map< String, Direct3D11Texture *, StringFastLessCompare CEGUI_MAP_ALLOC(String, Direct3D11Texture *)> TextureMap
container type used to hold Textures we create.
Definition: RendererModules/Direct3D11/Renderer.h:246
CEGUI::Direct3D11Renderer::d_defaultTarget
RenderTarget * d_defaultTarget
The default RenderTarget.
Definition: RendererModules/Direct3D11/Renderer.h:235
IDevice11::d_context
ID3D11DeviceContext * d_context
The D3D device context we're using to render.
Definition: RendererModules/Direct3D11/Renderer.h:71
CEGUI::Direct3D11Renderer::d_normalClippedTechnique
ID3DX11EffectTechnique * d_normalClippedTechnique
Rendering technique that supplies scissor clipped BM_NORMAL type rendering.
Definition: RendererModules/Direct3D11/Renderer.h:252
CEGUI::Vector2< float >
CEGUI::Direct3D11Renderer::d_effect
ID3DX11Effect * d_effect
Effect (shader) used when rendering.
Definition: RendererModules/Direct3D11/Renderer.h:250
CEGUI::Direct3D11Renderer::isTexCoordSystemFlipped
bool isTexCoordSystemFlipped() const
Returns if the texture coordinate system is vertically flipped or not. The original of a texture coor...
Definition: RendererModules/Direct3D11/Renderer.h:170
CEGUI::Direct3D11Renderer::destroyTexture
void destroyTexture(Texture &texture)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::Direct3D11Renderer::d_displaySize
Sizef d_displaySize
What the renderer considers to be the current display size.
Definition: RendererModules/Direct3D11/Renderer.h:231
CEGUI::Direct3D11Renderer::createTexture
Texture & createTexture(const String &name, const Sizef &size)
Create a Texture object with the given pixel dimensions as specified by size.
IDevice11::d_device
ID3D11Device * d_device
The D3D device context we're using to create various resources with.
Definition: RendererModules/Direct3D11/Renderer.h:69
CEGUI::Direct3D11Renderer::setCurrentTextureShaderResource
void setCurrentTextureShaderResource(ID3D11ShaderResourceView *srv)
low-level function to set the texture shader resource view to be used.
CEGUI::Direct3D11Renderer::beginRendering
void beginRendering()
Perform any operations required to put the system into a state ready for rendering operations to begi...
CEGUI::Direct3D11Renderer::Direct3D11Renderer
Direct3D11Renderer(ID3D11Device *device, ID3D11DeviceContext *context)
constructor
CEGUI::Direct3D11Renderer::GeometryBufferList
std::vector< Direct3D11GeometryBuffer * > GeometryBufferList
container type used to hold GeometryBuffers we create.
Definition: RendererModules/Direct3D11/Renderer.h:241
CEGUI::Direct3D11Renderer::destroyAllTextureTargets
void destroyAllTextureTargets()
Destory all TextureTarget objects created by this Renderer.
CEGUI::Direct3D11Renderer::destroyGeometryBuffer
void destroyGeometryBuffer(const GeometryBuffer &buffer)
Destroy a GeometryBuffer that was returned when calling the createGeometryBuffer function....
CEGUI::Texture
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:54
CEGUI::Direct3D11Renderer::setDisplaySize
void setDisplaySize(const Sizef &sz)
Set the size of the display or host window in pixels for this Renderer object.
CEGUI::Direct3D11Renderer::d_worldMatrixVariable
ID3DX11EffectMatrixVariable * d_worldMatrixVariable
Variable to access world matrix used in geometry transformation.
Definition: RendererModules/Direct3D11/Renderer.h:264
CEGUI::Direct3D11Renderer
Renderer implementation using Direct3D 10.
Definition: RendererModules/Direct3D11/Renderer.h:83
CEGUI::Direct3D11Renderer::destroy
static void destroy(Direct3D11Renderer &renderer)
Destroy an Direct3D11Renderer object.
CEGUI::Direct3D11Renderer::getMaxTextureSize
uint getMaxTextureSize() const
Return the pixel size of the maximum supported texture.
CEGUI::BlendMode
BlendMode
Enumerated type that contains the valid options that specify the type of blending that is to be perfo...
Definition: Renderer.h:62
CEGUI::Direct3D11Renderer::bindTechniquePass
void bindTechniquePass(const BlendMode mode, const bool clipped)
low-level function that binds the technique pass ready for use
CEGUI::Direct3D11Renderer::d_normalUnclippedTechnique
ID3DX11EffectTechnique * d_normalUnclippedTechnique
Rendering technique that supplies BM_NORMAL type rendering.
Definition: RendererModules/Direct3D11/Renderer.h:254
CEGUI::Direct3D11Renderer::createTexture
Texture & createTexture(const String &name, const String &filename, const String &resourceGroup)
Create a Texture object using the given image file.
CEGUI::Direct3D11Renderer::destroySystem
static void destroySystem()
Convenience function to cleanup the CEGUI system and related objects that were created by calling the...
CEGUI::Direct3D11Renderer::setProjectionMatrix
void setProjectionMatrix(D3DXMATRIX &matrix)
low-level function to set the projection matrix to be used.
CEGUI::RenderTarget
Defines interface to some surface that can be rendered to. Concrete instances of objects that impleme...
Definition: RenderTarget.h:60
CEGUI::Direct3D11Renderer::d_displayDPI
Vector2f d_displayDPI
What the renderer considers to be the current display DPI resolution.
Definition: RendererModules/Direct3D11/Renderer.h:233
CEGUI::Direct3D11Renderer::createTexture
Texture & createTexture(const String &name)
Create a 'null' Texture object.
CEGUI::Size< float >
CEGUI::Direct3D11Renderer::d_device
IDevice11 d_device
The D3D device we're using to render with.
Definition: RendererModules/Direct3D11/Renderer.h:228
CEGUI::TextureTarget
Specialisation of RenderTarget interface that should be used as the base class for RenderTargets that...
Definition: TextureTarget.h:41
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::Direct3D11Renderer::d_premultipliedClippedTechnique
ID3DX11EffectTechnique * d_premultipliedClippedTechnique
Rendering technique that supplies scissor clipped BM_RTT_PREMULTIPLIED type rendering.
Definition: RendererModules/Direct3D11/Renderer.h:256
CEGUI::Direct3D11Renderer::getDisplaySize
const Sizef & getDisplaySize() const
Return the size of the display or host window in pixels.
CEGUI::Direct3D11Texture
Texture implementation for the Direct3D11Renderer.
Definition: RendererModules/Direct3D11/Texture.h:50
CEGUI::Direct3D11Renderer::getIdentifierString
const String & getIdentifierString() const
Return identification string for the renderer module.
CEGUI::Direct3D11Renderer::d_geometryBuffers
GeometryBufferList d_geometryBuffers
Container used to track geometry buffers.
Definition: RendererModules/Direct3D11/Renderer.h:243
CEGUI::Direct3D11Renderer::d_projectionMatrixVariable
ID3DX11EffectMatrixVariable * d_projectionMatrixVariable
Variable to access projection matrix used in geometry transformation.
Definition: RendererModules/Direct3D11/Renderer.h:266
CEGUI::Direct3D11Renderer::getDisplayDPI
const Vector2f & getDisplayDPI() const
Return the resolution of the display or host window in dots per inch.
CEGUI::Renderer
Abstract class defining the basic required interface for Renderer objects.
Definition: Renderer.h:84
CEGUI::Direct3D11Renderer::d_textures
TextureMap d_textures
Container used to track textures.
Definition: RendererModules/Direct3D11/Renderer.h:248
CEGUI::Direct3D11Renderer::endRendering
void endRendering()
Perform any operations required to finalise rendering.
CEGUI::Direct3D11Renderer::throwIfNameExists
void throwIfNameExists(const String &name) const
helper to throw exception if name is already used.
CEGUI::Direct3D11Renderer::d_premultipliedUnclippedTechnique
ID3DX11EffectTechnique * d_premultipliedUnclippedTechnique
Rendering technique that supplies BM_RTT_PREMULTIPLIED type rendering.
Definition: RendererModules/Direct3D11/Renderer.h:258
CEGUI::Direct3D11Renderer::TextureTargetList
std::vector< TextureTarget * > TextureTargetList
container type used to hold TextureTargets we create.
Definition: RendererModules/Direct3D11/Renderer.h:237
CEGUI::Direct3D11Renderer::create
static Direct3D11Renderer & create(ID3D11Device *device, ID3D11DeviceContext *context, const int abi=CEGUI_VERSION_ABI)
Create an Direct3D11Renderer object.