All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
DebugRenderer.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "VectorMath.h"
7 #include "Rendering.h"
8 #include "GLState.h"
9 #include "DynamicBuffer.h"
10 #include "Streaming.h"
11 #include "Geometry.h"
12 #include "Fonts.h"
13 #include "DebugRendering.h"
14 #include "Camera.h"
15 #include "Text.h"
16 #include "BatchedTextAppearance.h"
17 
18 #include <string>
19 #include <vector>
20 
21 namespace Eegeo
22 {
23  namespace DebugRendering
24  {
25  m44 MakeOrthoMatrix(const Rendering::RenderContext& renderContext);
26 
28  {
29  public:
30  DebugRenderer(Text::IScreenTextRenderer& screenTextRenderer,
31  const Fonts::FontInstance& fontInstance,
32  Rendering::Materials::IMaterial* pDebugMaterial,
33  const Rendering::VertexLayouts::VertexBinding& coloredVertexBinding,
34  Rendering::RenderableFilters& renderableFilters,
35  float lineWidth,
36  const Eegeo::Text::BatchedTextAppearance& defaultTextAppearance,
37  const int initialLineBufferSize,
38  const int initialGeomVertexBufferSize,
39  const int initialGeomIndexBufferSize);
40 
41  ~DebugRenderer();
42 
44  void SetLineWidth(float lineWidth);
45 
47  void SetDepthTestEnabled(bool depthTest);
48 
50  void DrawLine(const dv3& ecefPointA,
51  const dv3& ecefPointB,
52  const v4& color,
53  const float lifetimeInSeconds = 0.0f
54  );
55 
56 
58  void DrawPolyLine(const std::vector<dv3>& ecefPoints,
59  const v4& color,
60  const float lifetimeInSeconds = 0.0f
61  );
62 
64  void DrawAxes(const dv3& ecefCentre,
65  const v3& xAxis,
66  const v3& yAxis,
67  const v3& zAxis,
68  const float lifetimeInSeconds = 0.0f
69  );
70 
72  void DrawAxes(const dv3& ecefCentre,
73  const v3& xAxis,
74  const v3& yAxis,
75  const v3& zAxis,
76  const v4& xColor,
77  const v4& yColor,
78  const v4& zColor,
79  const float lifetimeInSeconds = 0.0f
80  );
81 
83  void DrawQuad(const dv3& ecefCentre,
84  const v3& xAxis,
85  const v3& yAxis,
86  const v3& zAxis,
87  const v4& color,
88  const float lifetimeInSeconds = 0.0f
89  );
90 
92  void DrawCube(const dv3& ecefCentre,
93  const v3& xAxis,
94  const v3& yAxis,
95  const v3& zAxis,
96  const v4& color,
97  const float lifetimeInSeconds = 0.0f
98  );
99 
101  void DrawSphere(const dv3& ecefCentre,
102  const float radius,
103  const v4& color,
104  const float lifetimeInSeconds = 0.0f
105  );
106 
108  void DrawWireFrustum(const dv3& ecefCenter,
109  const Geometry::Frustum& frustum,
110  const v4& color,
111  const float lifetimeInSeconds = 0.0f
112  );
113 
115  void DrawText(const dv3& ecefCenter,
116  const std::string& text,
117  const float size,
118  const float lifetimeInSeconds = 0.0f
119  );
120 
122  void DrawTextScreenSpace(const v2& leftOriginCenter,
123  const std::string& text,
124  const float size,
125  const float lifetimeInSeconds = 0.0f
126  );
127 
129  void DrawTransformedTextScreenSpace(const v2& transformOrigin,
130  const v2& localTranslate,
131  float rotate,
132  const std::string& text,
133  const float size,
134  const float lifetimeInSeconds = 0.0f
135  );
136 
138  void DrawLineScreenSpace(
139  const v2& screenPointA,
140  const v2& screenPointB,
141  const v4& color,
142  const float lifetimeInSeconds = 0.0f
143  );
144 
145  void Update(float dt, const Camera::RenderCamera& renderCamera);
146  void GenerateGeometry(const Camera::RenderCamera& renderCamera);
147 
148  private:
149  void Initialize();
150  void EnsureInitialized();
151 
152  Renderers::DebugLineRendererEcef* m_pLineRendererEcef;
153  Renderers::DebugLineRendererScreenSpace* m_pLineRendererScreenSpace;
154  Renderers::DebugPrimitiveRendererEcef* m_pPrimitiveRendererEcef;
155  Renderers::DebugTextRendererEcef* m_pTextRendererEcef;
156  Renderers::DebugTextRendererScreenSpace* m_pTextRendererScreenSpace;
157  bool m_initialized;
158 
159  Text::IScreenTextRenderer& m_screenTextRenderer;
160  const Fonts::FontInstance& m_fontInstance;
161  Rendering::Materials::IMaterial* m_pDebugMaterial;
162  const Rendering::VertexLayouts::VertexBinding& m_coloredVertexBinding;
163  Rendering::RenderableFilters& m_renderableFilters;
164  float m_lineWidth;
165  const Text::BatchedTextAppearance m_defaultTextAppearance;
166  const int m_initialLineBufferSize;
167  const int m_initialGeomVertexBufferSize;
168  const int m_initialGeomIndexBufferSize;
169  };
170  }
171 }