Crazy Eddie's GUI System  0.8.3
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/Direct3D10/GeometryBuffer.h
1 /***********************************************************************
2  filename: CEGUIDirect3D10GeometryBuffer.h
3  created: Sat Mar 7 2009
4  author: Paul D Turner (parts based on code by Rajko Stojadinovic)
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIDirect3D10GeometryBuffer_h_
29 #define _CEGUIDirect3D10GeometryBuffer_h_
30 
31 #include "../../GeometryBuffer.h"
32 #include "CEGUI/RendererModules/Direct3D10/Renderer.h"
33 #include "../../Rect.h"
34 #include "../../Quaternion.h"
35 
36 #include <d3dx10.h>
37 
38 #if defined(_MSC_VER)
39 # pragma warning(push)
40 # pragma warning(disable : 4251)
41 #endif
42 
43 // Start of CEGUI namespace section
44 namespace CEGUI
45 {
46 class Direct3D10Texture;
47 
49 class D3D10_GUIRENDERER_API Direct3D10GeometryBuffer : public GeometryBuffer
50 {
51 public:
54 
57 
59  const D3DXMATRIX* getMatrix() const;
60 
61  // Implement GeometryBuffer interface.
62  void draw() const;
63  void setTranslation(const Vector3f& v);
64  void setRotation(const Quaternion& r);
65  void setPivot(const Vector3f& p);
66  void setClippingRegion(const Rectf& region);
67  void appendVertex(const Vertex& vertex);
68  void appendGeometry(const Vertex* const vbuff, uint vertex_count);
69  void setActiveTexture(Texture* texture);
70  void reset();
71  Texture* getActiveTexture() const;
72  uint getVertexCount() const;
73  uint getBatchCount() const;
74  void setRenderEffect(RenderEffect* effect);
75  RenderEffect* getRenderEffect();
76  void setClippingActive(const bool active);
77  bool isClippingActive() const;
78 
79 protected:
81  void updateMatrix() const;
83  void syncHardwareBuffer() const;
85  void allocateVertexBuffer(const size_t count) const;
87  void cleanupVertexBuffer() const;
88 
90  struct D3DVertex
91  {
93  FLOAT x, y, z;
95  DWORD diffuse;
97  float tu, tv;
98  };
99 
101  struct BatchInfo
102  {
103  const ID3D10ShaderResourceView* texture;
104  uint vertexCount;
105  bool clip;
106  };
107 
108  // Direct3D10Renderer object that created and owns this GeometryBuffer.
109  Direct3D10Renderer& d_owner;
111  ID3D10Device& d_device;
115  mutable ID3D10Buffer* d_vertexBuffer;
117  mutable UINT d_bufferSize;
119  mutable bool d_bufferSynched;
121  typedef std::vector<BatchInfo> BatchList;
125  typedef std::vector<D3DVertex> VertexList;
141  mutable D3DXMATRIX d_matrix;
143  mutable bool d_matrixValid;
144 };
145 
146 
147 } // End of CEGUI namespace section
148 
149 #if defined(_MSC_VER)
150 # pragma warning(pop)
151 #endif
152 
153 #endif // end of guard _CEGUIDirect3D10GeometryBuffer_h_