6 #include "VertexLayoutElement.h"
7 #include "VertexSemantics.h"
15 namespace VertexLayouts
19 bool VertexLayoutElementComparator(VertexLayoutElement a, VertexLayoutElement b)
21 return a.GetSemanticId() < b.GetSemanticId();
32 : m_vertexSize(vertexSize)
33 , m_semanticFlags(VertexSemanticFlags::None)
37 int GetVertexSize()
const
44 Eegeo_ASSERT(!ContainsSemantic(element.GetSemanticId()),
"Attempt to add the same semantic to VertexAttribs twice.");
46 m_elements.push_back(element);
47 m_semanticFlags = VertexSemanticFlags::SetFlagForSemantic(m_semanticFlags, element.GetSemanticId());
49 std::sort(m_elements.begin(), m_elements.end(), VertexLayoutElementComparator);
52 int GetNumOfElements()
const
54 return static_cast<int>(m_elements.size());
57 VertexSemanticFlags::FlagValues GetSemanticFlags()
const
59 return m_semanticFlags;
64 Eegeo_ASSERT(elementIndex < m_elements.size(),
"Requested element index is out of range.");
65 return m_elements.at(elementIndex);
68 bool ContainsSemantic(
const VertexSemanticId::IdValues semantic)
const
70 return VertexSemanticFlags::FlagsContainSemantic(m_semanticFlags, semantic);
73 const VertexLayoutElement& GetElementBySemantic(
const VertexSemanticId::IdValues semantic)
const
75 for (std::vector<VertexLayoutElement>::const_iterator iter = m_elements.begin();
76 iter != m_elements.end();
80 if (element.GetSemanticId() == semantic)
86 Eegeo_ASSERT(
false,
"No element found for semantic");
87 return *m_elements.end();
92 VertexSemanticFlags::FlagValues m_semanticFlags;
95 std::vector<VertexLayoutElement> m_elements;