14 class CIndexBuffer :
public IIndexBuffer
17 CIndexBuffer(video::E_INDEX_TYPE type = video::EIT_16BIT) : Type(type), HardwareMappingHint(
EHM_NEVER), ChangedID(1), Indices(0)
22 if(Type == video::EIT_32BIT)
28 CIndexBuffer(
const CIndexBuffer &indexBuffer) : Type(video::EIT_16BIT), HardwareMappingHint(
EHM_NEVER), ChangedID(1), Indices(0)
30 Type = indexBuffer.Type;
32 HardwareMappingHint = indexBuffer.HardwareMappingHint;
34 if (Type == video::EIT_32BIT)
39 const u32 ibCount = indexBuffer.Indices->size();
41 Indices->reallocate(ibCount);
43 for (
u32 i = 0; i < ibCount; ++i)
44 addIndex(indexBuffer.getIndex(i));
47 virtual ~CIndexBuffer()
59 return (
u32)Indices->getLast();
62 virtual void set_used(
u32 used)
64 Indices->set_used(used);
67 virtual void reallocate(
u32 size)
69 Indices->reallocate(size);
72 virtual u32 allocated_size()
const
74 return Indices->allocated_size();
77 virtual s32 linear_reverse_search(
const u32& element)
const
79 return Indices->linear_reverse_search(element);
82 virtual video::E_INDEX_TYPE getType()
const
87 virtual void setType(video::E_INDEX_TYPE type)
98 case video::EIT_16BIT:
103 case video::EIT_32BIT:
112 IndicesList->reallocate(Indices->size());
114 for(
u32 i = 0; i < Indices->size(); ++i)
115 IndicesList->addIndex(Indices->getIndex(i));
120 Indices = IndicesList;
125 return HardwareMappingHint;
130 if (HardwareMappingHint != hardwareMappingHint)
133 HardwareMappingHint = hardwareMappingHint;
136 virtual void addIndex(
const u32& index)
138 Indices->addIndex(index);
141 virtual u32 getIndex(
u32 id)
const
143 return Indices->getIndex(
id);
146 virtual void* getIndices()
148 return Indices->pointer();
151 virtual u32 getIndexCount()
const
153 return Indices->size();
156 virtual u32 getIndexSize()
const
158 if(Type == video::EIT_32BIT)
164 virtual void setIndex(
u32 id,
u32 index)
166 Indices->setIndex(
id, index);
169 virtual void setDirty()
172 HardwareBuffer->requestUpdate();
177 virtual u32 getChangedID()
const
187 virtual void clear() = 0;
188 virtual void* pointer() = 0;
189 virtual u32 size()
const = 0;
190 virtual u32 getLast() = 0;
191 virtual void set_used(
u32 used) = 0;
192 virtual void reallocate(
u32 size) = 0;
193 virtual u32 allocated_size()
const = 0;
194 virtual s32 linear_reverse_search(
const u32& element)
const = 0;
195 virtual void addIndex(
const u32& index) = 0;
196 virtual u32 getIndex(
u32 id)
const = 0;
197 virtual void setIndex(
u32 id,
u32 index) = 0;
204 CIndexList() : Data(0)
208 CIndexList(
const CIndexList &indexList) : Data(0)
210 const u32 ilCount = indexList.Data.size();
212 Data.reallocate(ilCount);
214 for (
u32 i = 0; i < ilCount; ++i)
215 Data.push_back(indexList.Data[i]);
227 virtual void* pointer()
229 return Data.pointer();
232 virtual u32 size()
const
237 virtual u32 getLast()
239 return (
u32)Data.getLast();
242 virtual void set_used(
u32 used)
247 virtual void reallocate(
u32 size)
249 Data.reallocate(size);
252 virtual u32 allocated_size()
const
254 return Data.allocated_size();
257 virtual s32 linear_reverse_search(
const u32& element)
const
259 return Data.linear_reverse_search(element);
262 virtual void addIndex(
const u32& index)
264 Data.push_back(index);
267 virtual u32 getIndex(
u32 id)
const
269 if (
id < Data.size())
275 virtual void setIndex(
u32 id,
u32 index)
277 if (
id < Data.size())
285 video::E_INDEX_TYPE Type;