All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WorldIconRenderer.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "IWorldIconRenderer.h"
6 #include "Types.h"
7 #include "Icons.h"
8 #include "BatchedIconRenderable.h"
9 #include "IconRendererStateComponent.h"
10 
11 namespace Eegeo
12 {
13  namespace Icons
14  {
16  {
17  public:
18  static WorldIconRenderer* Create(IconMaterialSetFactory& iconMaterialSetFactory,
19  IconMaterialSetCache& iconMaterialSetCache,
20  IBatchedWorldIconRenderableFactory& batchedWorldIconRenderableFactory,
21  BatchedWorldIconRenderable::VertexBufferType& worldIconVertexBuffer);
22 
24 
25  WorldIconRenderer(IconRendererStateComponent* pTextRendererStateComponent,
26  BatchedWorldIconRenderableCache* pBatchedWorldIconRenderableCache);
28 
29  void SetIconSet(const IconSet* pIconSet)
30  {
31  m_pIconRendererStateComponent->SetIconSet(pIconSet);
32  }
33 
34  void SetDefaultState();
35 
36  void SetIconColor(const v4& iconColor)
37  {
38  m_pIconRendererStateComponent->SetIconColor(iconColor);
39  }
40 
41  void SetIconScale(float iconScale)
42  {
43  m_pIconRendererStateComponent->SetScale(iconScale);
44  }
45 
46  void SetTransform(const v2& translate, const v2& rotate, const v2& scale)
47  {
48  m_pIconRendererStateComponent->SetTransform(translate, rotate, scale);
49  }
50 
51  void SetDepthTest(bool depthTest)
52  {
53  m_pIconRendererStateComponent->SetDepthTest(depthTest);
54  }
55 
56  void SetStencilTest(bool stencilTest)
57  {
58  m_pIconRendererStateComponent->SetStencilTest(stencilTest);
59  }
60 
61  void SetStencilFunc(GLenum stencilFunc, int stencilRef, u32 stencilMask)
62  {
63  m_pIconRendererStateComponent->SetStencilFunc(stencilFunc, stencilRef, stencilMask);
64  }
65 
66  void SetStencilMaskedStyle(bool enable, GLenum stencilFunc, const v4& iconColor)
67  {
68  m_pIconRendererStateComponent->SetStencilMaskedStyle(enable, stencilFunc, iconColor);
69  }
70 
71  void SetRenderLayer(Rendering::LayerIds::Values layer, int subLayer)
72  {
73  m_pIconRendererStateComponent->SetRenderLayer(layer, subLayer);
74  }
75 
76  void SetAlpha(float alpha)
77  {
78  m_pIconRendererStateComponent->SetAlpha(alpha);
79  }
80 
81  void SetModelToWorldTransform(const m44& transform)
82  {
83  m_modelToWorldTransform = transform;
84  }
85 
86  void DrawIcon(const IconDefinition& shapedIcon);
87 
88  void DrawIcons(const std::vector<const IconDefinition*>& shapedIcons);
89 
90  void Finalize();
91 
92  void Upload();
93 
94  void EnqueueRenderables(const Rendering::RenderContext& renderContext, Rendering::RenderQueue& renderQueue);
95 
96  private:
97  void SetupRenderables();
98 
99  void DrawIconWorldSpace(const IconDefinition& icon, const v2& shapedIconPos);
100 
101  IconRendererStateComponent* m_pIconRendererStateComponent;
102 
103  BatchedWorldIconRenderableCache* m_pBatchedWorldIconRenderableCache;
104 
105  m44 m_modelToWorldTransform;
106  };
107  }
108 }