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