5 #include "RenderableBase.h"
11 #include "BatchedIconAppearance.h"
12 #include "BatchedIconRangeBuilder.h"
14 #include "AllVertexTypes.h"
27 bool IsStencilMaskPass;
28 bool NeedsShaderSetup;
37 Rendering::LayerIds::Values layerId,
43 int vertexStrideBytes,
53 virtual bool ShouldRender()
const
55 return GetVertexCount() > 0;
58 virtual void Finalize();
60 virtual void Upload() = 0;
62 virtual void Reset() = 0;
64 bool IsStencilMaskPass()
const
66 return m_pDrawState->IsStencilMaskPass;
69 bool NeedsShaderSetup()
const
71 return m_pDrawState->NeedsShaderSetup;
77 virtual int GetVertexCount()
const = 0;
79 virtual const void* GetVertexData(
int quadOffset,
int quadCount)
const = 0;
82 void EndRange(
int currentIndexCount)
const;
84 int GetCurrentQuadCount()
const;
88 typedef std::deque<BatchedIconRange> TAppearanceRanges;
89 TAppearanceRanges* m_pAppearanceRanges;
98 template <
typename TVertex>
102 typedef TVertex VertexType;
104 typedef std::vector<VertexType> VertexListType;
113 :
BatchedIconRenderable(pMaterial, pVertexBinding, sortKey, static_cast<int>(
sizeof(VertexType)), quadIndexBuffer)
114 , m_pPrimary(pPrimary)
115 , m_vertexBuffer(vertexBuffer)
116 , m_pVertexList((pPrimary == NULL) ? Eegeo_NEW(VertexListType)() : NULL)
117 , m_vertexBufferElementOffset(0)
123 Eegeo_DELETE m_pVertexList;
130 m_vertexBufferElementOffset = m_vertexBuffer.GetElementOffset();
131 m_vertexBuffer.Upload(*m_pVertexList);
135 m_vertexBufferElementOffset = -1;
141 const int quadOffset = GetVertexBufferElementOffset() / 4;
143 m_vertexBuffer.Bind();
145 BatchedIconRenderable::Draw(glState, quadOffset);
147 m_vertexBuffer.Unbind();
151 m_pVertexList->clear();
159 m_pVertexList->clear();
163 VertexListType& GetVertexList()
const
168 : m_pPrimary->GetVertexList();
171 bool IsPrimary()
const
173 return m_pPrimary == NULL;
176 bool IsReplica()
const
183 int GetVertexBufferElementOffset()
const
185 const int vertexBufferElementOffset = IsPrimary()
186 ? m_vertexBufferElementOffset
187 : m_pPrimary->GetVertexBufferElementOffset();
189 return vertexBufferElementOffset;
192 virtual int GetVertexCount()
const
194 return static_cast<int>(GetVertexList().size());
197 virtual const void* GetVertexData(
int quadOffset,
int quadCount)
const
199 const VertexListType& vertexList = GetVertexList();
200 Eegeo_ASSERT((quadOffset+quadCount)*4 <= vertexList.size());
202 const VertexType* pVertexData = &(vertexList[quadOffset*4]);
204 return static_cast<const void*
>(pVertexData);
209 VertexListType* m_pVertexList;
210 int m_vertexBufferElementOffset;
224 :
ThisType::ThisType(pMaterial, pVertexBinding, sortKey, pPrimary, quadIndexBuffer, screenTextVertexBuffer)
241 :
ThisType::ThisType(pMaterial, pVertexBinding, sortKey, pPrimary, quadIndexBuffer, worldTextVertexBuffer)