6 #include "BatchedIconAppearance.h"
7 #include "BatchedIconRenderable.h"
9 #include "IBatchedIconRenderableFactory.h"
17 template <
typename TBatchedIconRenderable,
typename TBatchedIconRenderableFactory>
22 typedef TBatchedIconRenderableFactory BatchedIconRenderableFactoryType;
27 typedef std::map<Rendering::SortKey, BatchedIconRenderableType*> TSortKeyToIconRenderable;
31 typedef typename TSortKeyToIconRenderable::const_iterator IconRenderableIterator;
34 TBatchedIconRenderableFactory& batchedIconRenderableFactory,
36 : m_batchedIconRenderableFactory(batchedIconRenderableFactory)
37 , m_vertexBuffer(vertexBuffer)
42 for (
typename TSortKeyToIconRenderable::const_iterator iter = m_sortKeyToIconRenderable.begin(); iter != m_sortKeyToIconRenderable.end(); ++iter)
45 Eegeo_DELETE pIconRenderable;
49 void SetupCurrentIconSet(
const std::vector<Rendering::Materials::IMaterial*>& materialSet, Rendering::LayerIds::Values layerId,
int subLayer)
51 m_iconRenderables.clear();
52 m_iconRenderables.reserve(materialSet.size());
54 for (std::vector<Rendering::Materials::IMaterial*>::const_iterator materialIter = materialSet.begin(); materialIter != materialSet.end(); ++materialIter)
59 m_iconRenderables.push_back(pBatchedTextRenderable);
63 void ClearCurrentIconSet()
65 m_iconRenderables.clear();
68 typename BatchedIconRenderableType::VertexListType& GetVertexList(
int texturePage)
const
70 return m_iconRenderables[texturePage]->GetVertexList();
75 UpdateAppearanceOnRenderables(batchedAppearance, m_iconRenderables);
79 IconRenderableIterator RenderablesBegin()
const {
return m_sortKeyToIconRenderable.begin(); }
80 IconRenderableIterator RenderablesEnd()
const {
return m_sortKeyToIconRenderable.end(); }
84 m_vertexBuffer.Reset();
86 int totalVertexCount = 0;
87 for (IconRenderableIterator iter = RenderablesBegin(); iter != RenderablesEnd(); ++iter)
90 renderable.Finalize();
92 if (renderable.IsPrimary())
94 totalVertexCount += renderable.GetVertexList().size();
98 m_vertexBuffer.Reserve(totalVertexCount);
103 m_vertexBuffer.Bind();
105 for (IconRenderableIterator iter = RenderablesBegin(); iter != RenderablesEnd(); ++iter)
111 m_vertexBuffer.Unbind();
117 void UpdateAppearanceOnRenderables(
const BatchedIconAppearance& batchedAppearance,
typename std::vector<TBatchedIconRenderable*>& renderables)
119 for (
typename std::vector<TBatchedIconRenderable*>::const_iterator iter = renderables.begin(); iter != renderables.end(); ++iter)
122 pRenderable->SetAppearance(batchedAppearance);
129 const Rendering::SortKey& sortKey = BatchedIconRenderable::MakeSortKey(material, layerId, subLayer);
131 typename TSortKeyToIconRenderable::const_iterator iter = m_sortKeyToIconRenderable.find(sortKey);
133 if (iter == m_sortKeyToIconRenderable.end())
135 m_sortKeyToIconRenderable.insert(std::make_pair(sortKey, m_batchedIconRenderableFactory.Create(material, sortKey, pPrimaryRenderable)));
136 iter = m_sortKeyToIconRenderable.find(sortKey);
140 Eegeo_ASSERT(pBatchedIconRenderable->GetLayer() == layerId);
141 Eegeo_ASSERT(pBatchedIconRenderable->GetUserDefined() == subLayer);
142 return pBatchedIconRenderable;
146 TBatchedIconRenderableFactory& m_batchedIconRenderableFactory;
149 std::vector<TBatchedIconRenderable*> m_iconRenderables;
151 TSortKeyToIconRenderable m_sortKeyToIconRenderable;