Crazy Eddie's GUI System  0.8.7
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 
142  bool isTexCoordSystemFlipped() const { return false; }
143 
145  ID3D10Device& getDirect3DDevice() const;
146 
148  void bindTechniquePass(const BlendMode mode, const bool clipped);
150  void setCurrentTextureShaderResource(ID3D10ShaderResourceView* srv);
152  void setProjectionMatrix(D3DXMATRIX& matrix);
154  void setWorldMatrix(D3DXMATRIX& matrix);
155 
156  // Implement interface from Renderer
164  Texture& createTexture(const String& name);
166  const String& filename,
167  const String& resourceGroup);
168  Texture& createTexture(const String& name, const Sizef& size);
169  void destroyTexture(Texture& texture);
170  void destroyTexture(const String& name);
172  Texture& getTexture(const String& name) const;
173  bool isTextureDefined(const String& name) const;
175  void endRendering();
176  void setDisplaySize(const Sizef& sz);
177  const Sizef& getDisplaySize() const;
178  const Vector2f& getDisplayDPI() const;
179  uint getMaxTextureSize() const;
180  const String& getIdentifierString() const;
181 
182 protected:
184  Direct3D10Renderer(ID3D10Device* device);
185 
188 
191 
193  void throwIfNameExists(const String& name) const;
195  static void logTextureCreation(const String& name);
197  static void logTextureDestruction(const String& name);
198 
202  ID3D10Device* d_device;
210  typedef std::vector<TextureTarget*> TextureTargetList;
214  typedef std::vector<Direct3D10GeometryBuffer*> GeometryBufferList;
219  CEGUI_MAP_ALLOC(String, Direct3D10Texture*)> TextureMap;
223  ID3D10Effect* d_effect;
225  ID3D10EffectTechnique* d_normalClippedTechnique;
227  ID3D10EffectTechnique* d_normalUnclippedTechnique;
229  ID3D10EffectTechnique* d_premultipliedClippedTechnique;
231  ID3D10EffectTechnique* d_premultipliedUnclippedTechnique;
233  ID3D10InputLayout* d_inputLayout;
235  ID3D10EffectShaderResourceVariable* d_boundTextureVariable;
237  ID3D10EffectMatrixVariable* d_worldMatrixVariable;
239  ID3D10EffectMatrixVariable* d_projectionMatrixVariable;
240 };
241 
242 
243 } // End of CEGUI namespace section
244 
245 #if defined(_MSC_VER)
246 # pragma warning(pop)
247 #endif
248 
249 #endif // end of guard _CEGUIDirect3D10Renderer_h_
Renderer implementation using Direct3D 10.
Definition: RendererModules/Direct3D10/Renderer.h:69
ID3D10EffectTechnique * d_normalUnclippedTechnique
Rendering technique that supplies BM_NORMAL type rendering.
Definition: RendererModules/Direct3D10/Renderer.h:227
void throwIfNameExists(const String &name) const
helper to throw exception if name is already used.
ID3D10Effect * d_effect
Effect (shader) used when rendering.
Definition: RendererModules/Direct3D10/Renderer.h:223
Vector2f d_displayDPI
What the renderer considers to be the current display DPI resolution.
Definition: RendererModules/Direct3D10/Renderer.h:206
uint getMaxTextureSize() const
Return the pixel size of the maximum supported texture.
void destroyAllGeometryBuffers()
Destroy all GeometryBuffer objects created by this Renderer.
RenderTarget & getDefaultRenderTarget()
Returns the default RenderTarget object. The default render target is is typically one that targets t...
void destroyTexture(Texture &texture)
Destroy a Texture object that was previously created by calling the createTexture functions.
~Direct3D10Renderer()
destructor.
static void logTextureCreation(const String &name)
helper to safely log the creation of a named texture
void setProjectionMatrix(D3DXMATRIX &matrix)
low-level function to set the projection matrix to be used.
GeometryBufferList d_geometryBuffers
Container used to track geometry buffers.
Definition: RendererModules/Direct3D10/Renderer.h:216
const String & getIdentifierString() const
Return identification string for the renderer module.
static void logTextureDestruction(const String &name)
helper to safely log the destruction of a named texture
ID3D10EffectTechnique * d_normalClippedTechnique
Rendering technique that supplies scissor clipped BM_NORMAL type rendering.
Definition: RendererModules/Direct3D10/Renderer.h:225
void destroyTexture(const String &name)
Destroy a Texture object that was previously created by calling the createTexture functions.
void destroyGeometryBuffer(const GeometryBuffer &buffer)
Destroy a GeometryBuffer that was returned when calling the createGeometryBuffer function....
bool isTextureDefined(const String &name) const
Return whether a texture with the given name exists.
void destroyTextureTarget(TextureTarget *target)
Function that cleans up TextureTarget objects created with the createTextureTarget function.
ID3D10Device * d_device
The D3D device we're using to render with.
Definition: RendererModules/Direct3D10/Renderer.h:202
Texture & createTexture(const String &name, const String &filename, const String &resourceGroup)
Create a Texture object using the given image file.
void endRendering()
Perform any operations required to finalise rendering.
ID3D10EffectTechnique * d_premultipliedClippedTechnique
Rendering technique that supplies scissor clipped BM_RTT_PREMULTIPLIED type rendering.
Definition: RendererModules/Direct3D10/Renderer.h:229
void setDisplaySize(const Sizef &sz)
Set the size of the display or host window in pixels for this Renderer object.
static void destroySystem()
Convenience function to cleanup the CEGUI system and related objects that were created by calling the...
GeometryBuffer & createGeometryBuffer()
Create a new GeometryBuffer and return a reference to it. You should remove the GeometryBuffer from a...
static String d_rendererID
String holding the renderer identification text.
Definition: RendererModules/Direct3D10/Renderer.h:200
Sizef getViewportSize()
return size of the D3D device viewport.
void bindTechniquePass(const BlendMode mode, const bool clipped)
low-level function that binds the technique pass ready for use
std::vector< TextureTarget * > TextureTargetList
container type used to hold TextureTargets we create.
Definition: RendererModules/Direct3D10/Renderer.h:210
static Direct3D10Renderer & bootstrapSystem(ID3D10Device *device, const int abi=CEGUI_VERSION_ABI)
Convenience function that creates the required objects to initialise the CEGUI system.
const Sizef & getDisplaySize() const
Return the size of the display or host window in pixels.
ID3D10Device & getDirect3DDevice() const
return the ID3D10Device used by this renderer object.
Direct3D10Renderer(ID3D10Device *device)
constructor
bool isTexCoordSystemFlipped() const
Returns if the texture coordinate system is vertically flipped or not. The original of a texture coor...
Definition: RendererModules/Direct3D10/Renderer.h:142
std::map< String, Direct3D10Texture *, StringFastLessCompare CEGUI_MAP_ALLOC(String, Direct3D10Texture *)> TextureMap
container type used to hold Textures we create.
Definition: RendererModules/Direct3D10/Renderer.h:219
ID3D10EffectMatrixVariable * d_worldMatrixVariable
Variable to access world matrix used in geometry transformation.
Definition: RendererModules/Direct3D10/Renderer.h:237
const Vector2f & getDisplayDPI() const
Return the resolution of the display or host window in dots per inch.
Sizef d_displaySize
What the renderer considers to be the current display size.
Definition: RendererModules/Direct3D10/Renderer.h:204
Texture & createTexture(const String &name, const Sizef &size)
Create a Texture object with the given pixel dimensions as specified by size.
static Direct3D10Renderer & create(ID3D10Device *device, const int abi=CEGUI_VERSION_ABI)
Create an Direct3D10Renderer object.
void beginRendering()
Perform any operations required to put the system into a state ready for rendering operations to begi...
TextureTarget * createTextureTarget()
Create a TextureTarget that can be used to cache imagery; this is a RenderTarget that does not lose i...
TextureMap d_textures
Container used to track textures.
Definition: RendererModules/Direct3D10/Renderer.h:221
TextureTargetList d_textureTargets
Container used to track texture targets.
Definition: RendererModules/Direct3D10/Renderer.h:212
ID3D10EffectShaderResourceVariable * d_boundTextureVariable
Variable to access current texture (actually shader resource view)
Definition: RendererModules/Direct3D10/Renderer.h:235
ID3D10EffectTechnique * d_premultipliedUnclippedTechnique
Rendering technique that supplies BM_RTT_PREMULTIPLIED type rendering.
Definition: RendererModules/Direct3D10/Renderer.h:231
void setCurrentTextureShaderResource(ID3D10ShaderResourceView *srv)
low-level function to set the texture shader resource view to be used.
static void destroy(Direct3D10Renderer &renderer)
Destroy an Direct3D10Renderer object.
Texture & getTexture(const String &name) const
Return a Texture object that was previously created by calling the createTexture functions.
RenderTarget * d_defaultTarget
The default RenderTarget.
Definition: RendererModules/Direct3D10/Renderer.h:208
std::vector< Direct3D10GeometryBuffer * > GeometryBufferList
container type used to hold GeometryBuffers we create.
Definition: RendererModules/Direct3D10/Renderer.h:214
ID3D10EffectMatrixVariable * d_projectionMatrixVariable
Variable to access projection matrix used in geometry transformation.
Definition: RendererModules/Direct3D10/Renderer.h:239
Texture & createTexture(const String &name)
Create a 'null' Texture object.
void destroyAllTextureTargets()
Destory all TextureTarget objects created by this Renderer.
void setWorldMatrix(D3DXMATRIX &matrix)
low-level function to set the world matrix to be used.
void destroyAllTextures()
Destroy all Texture objects created by this Renderer.
ID3D10InputLayout * d_inputLayout
D3D10 input layout describing the vertex format we use.
Definition: RendererModules/Direct3D10/Renderer.h:233
Texture implementation for the Direct3D10Renderer.
Definition: RendererModules/Direct3D10/Texture.h:50
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:44
Defines interface to some surface that can be rendered to. Concrete instances of objects that impleme...
Definition: RenderTarget.h:60
Abstract class defining the basic required interface for Renderer objects.
Definition: Renderer.h:84
String class used within the GUI system.
Definition: String.h:64
Specialisation of RenderTarget interface that should be used as the base class for RenderTargets that...
Definition: TextureTarget.h:41
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:54
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
BlendMode
Enumerated type that contains the valid options that specify the type of blending that is to be perfo...
Definition: Renderer.h:62
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