Crazy Eddies GUI System  0.7.9
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
CEGUIDirect3D11GeometryBuffer.h
1 /***********************************************************************
2  filename: CEGUIDirect3D11GeometryBuffer.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 _CEGUIDirect3D11GeometryBuffer_h_
28 #define _CEGUIDirect3D11GeometryBuffer_h_
29 
30 #include "../../CEGUIGeometryBuffer.h"
31 #include "CEGUIDirect3D11Renderer.h"
32 #include "../../CEGUIRect.h"
33 
34 
35 
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
45 class Direct3D11Texture;
46 
48 class D3D11_GUIRENDERER_API Direct3D11GeometryBuffer : public GeometryBuffer
49 {
50 public:
53 
56 
58  const D3DXMATRIX* getMatrix() const;
59 
60  // Implement GeometryBuffer interface.
61  void draw() const;
62  void setTranslation(const Vector3& v);
63  void setRotation(const Vector3& r);
64  void setPivot(const Vector3& p);
65  void setClippingRegion(const Rect& region);
66  void appendVertex(const Vertex& vertex);
67  void appendGeometry(const Vertex* const vbuff, uint vertex_count);
68  void setActiveTexture(Texture* texture);
69  void reset();
70  Texture* getActiveTexture() const;
71  uint getVertexCount() const;
72  uint getBatchCount() const;
73  void setRenderEffect(RenderEffect* effect);
74  RenderEffect* getRenderEffect();
75 
76 protected:
78  void updateMatrix() const;
80  void syncHardwareBuffer() const;
82  void allocateVertexBuffer(const size_t count) const;
84  void cleanupVertexBuffer() const;
85 
87  struct D3DVertex
88  {
90  FLOAT x, y, z;
92  DWORD diffuse;
94  float tu, tv;
95  };
96 
97  // Direct3D11Renderer object that created and owns this GeometryBuffer.
98  Direct3D11Renderer& d_owner;
104  mutable ID3D11Buffer* d_vertexBuffer;
106  mutable UINT d_bufferSize;
108  mutable bool d_bufferSynched;
110  typedef std::pair<const ID3D11ShaderResourceView*, uint> BatchInfo;
112  typedef std::vector<BatchInfo> BatchList;
116  typedef std::vector<D3DVertex> VertexList;
130  mutable D3DXMATRIX d_matrix;
132  mutable bool d_matrixValid;
133 };
134 
135 
136 } // End of CEGUI namespace section
137 
138 #if defined(_MSC_VER)
139 # pragma warning(pop)
140 #endif
141 
142 #endif // end of guard _CEGUIDirect3D11GeometryBuffer_h_
D3DXMATRIX d_matrix
model matrix cache
Definition: CEGUIDirect3D11GeometryBuffer.h:130
Interface for objects that hook into RenderingWindow to affect the rendering process, thus allowing various effects to be achieved.
Definition: CEGUIRenderEffect.h:41
internal Vertex structure used for Direct3D based geometry.
Definition: CEGUIDirect3D11GeometryBuffer.h:87
VertexList d_vertices
container where added geometry is stored.
Definition: CEGUIDirect3D11GeometryBuffer.h:118
Class used as a three dimensional vector.
Definition: CEGUIVector.h:130
RenderEffect * d_effect
RenderEffect that will be used by the GeometryBuffer.
Definition: CEGUIDirect3D11GeometryBuffer.h:128
Direct3D11Texture * d_activeTexture
last texture that was set as active
Definition: CEGUIDirect3D11GeometryBuffer.h:102
structure that is used to hold details of a single vertex in 3D space.
Definition: CEGUIVertex.h:41
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: CEGUIGeometryBuffer.h:42
std::pair< const ID3D11ShaderResourceView *, uint > BatchInfo
type to track info for per-texture sub batches of geometry
Definition: CEGUIDirect3D11GeometryBuffer.h:110
FLOAT x
The transformed position for the vertex.
Definition: CEGUIDirect3D11GeometryBuffer.h:90
BatchList d_batches
list of texture batches added to the geometry buffer
Definition: CEGUIDirect3D11GeometryBuffer.h:114
DWORD diffuse
colour of the vertex.
Definition: CEGUIDirect3D11GeometryBuffer.h:92
Vector3 d_translation
translation vector
Definition: CEGUIDirect3D11GeometryBuffer.h:122
Definition: CEGUIDirect3D11Renderer.h:66
bool d_matrixValid
true when d_matrix is valid and up to date
Definition: CEGUIDirect3D11GeometryBuffer.h:132
Abstract base class specifying the required interface for Texture objects.
Definition: CEGUITexture.h:50
bool d_bufferSynched
whether the h/w buffer is in sync with the added geometry
Definition: CEGUIDirect3D11GeometryBuffer.h:108
Vector3 d_rotation
rotation vector
Definition: CEGUIDirect3D11GeometryBuffer.h:124
std::vector< D3DVertex > VertexList
type of container used to queue the geometry
Definition: CEGUIDirect3D11GeometryBuffer.h:116
Renderer implementation using Direct3D 10.
Definition: CEGUIDirect3D11Renderer.h:82
Implementation of CEGUI::GeometryBuffer for the Direct3D 10 API.
Definition: CEGUIDirect3D11GeometryBuffer.h:48
std::vector< BatchInfo > BatchList
type of container that tracks BatchInfos.
Definition: CEGUIDirect3D11GeometryBuffer.h:112
Rect d_clipRect
rectangular clip region
Definition: CEGUIDirect3D11GeometryBuffer.h:120
IDevice11 & d_device
The D3D Device.
Definition: CEGUIDirect3D11GeometryBuffer.h:100
Texture implementation for the Direct3D11Renderer.
Definition: CEGUIDirect3D11Texture.h:47
ID3D11Buffer * d_vertexBuffer
hardware buffer where vertices will be drawn from.
Definition: CEGUIDirect3D11GeometryBuffer.h:104
UINT d_bufferSize
Size of the currently allocated vertex buffer.
Definition: CEGUIDirect3D11GeometryBuffer.h:106
float tu
texture coordinates.
Definition: CEGUIDirect3D11GeometryBuffer.h:94
Vector3 d_pivot
pivot point for rotation
Definition: CEGUIDirect3D11GeometryBuffer.h:126
Class encapsulating operations on a Rectangle.
Definition: CEGUIRect.h:44