5#ifndef NIRT_C_INDEX_BUFFER_HPP_INCLUDED
6#define NIRT_C_INDEX_BUFFER_HPP_INCLUDED
8#include <nirtcpp/core/engine/IIndexBuffer.hpp>
21 virtual ~IIndexList(){};
23 virtual u32 stride()
const =0;
24 virtual u32 size()
const =0;
25 virtual void push_back(
u32 value) =0;
26 virtual u32 operator [](
u32 index)
const =0;
27 virtual u32 getLast() =0;
28 virtual void setValue(
u32 index,
u32 value) =0;
29 virtual void set_used(
u32 usedNow) =0;
30 virtual void reallocate(
u32 new_size,
bool canShrink=
true) =0;
31 virtual u32 allocated_size()
const =0;
32 virtual void* pointer() =0;
33 virtual const void* const_pointer()
const =0;
34 virtual video::E_INDEX_TYPE getType()
const =0;
38 class CSpecificIndexList :
public IIndexList
43 virtual u32 stride()
const override {
return sizeof(T);}
45 virtual u32 size()
const override {
return Indices.size();}
47 virtual void push_back(
u32 value)
override
49 Indices.push_back((T)value);
52 virtual u32 operator [](
u32 index)
const override
54 return (
u32)(Indices[index]);
57 virtual u32 getLast()
override {
return (
u32)Indices.getLast();}
59 virtual void setValue(
u32 index,
u32 value)
override
61 Indices[index]=(T)value;
64 virtual void set_used(
u32 usedNow)
override
66 Indices.set_used(usedNow);
69 virtual void reallocate(
u32 new_size,
bool canShrink)
override
71 Indices.reallocate(new_size, canShrink);
74 virtual u32 allocated_size()
const override
76 return Indices.allocated_size();
79 virtual void* pointer()
override {
return Indices.pointer(); }
80 virtual const void* const_pointer()
const override {
return Indices.const_pointer(); }
82 virtual video::E_INDEX_TYPE getType()
const override
84 if (
sizeof(T)==
sizeof(
u16))
85 return video::EIT_16BIT;
87 return video::EIT_32BIT;
101 setType(IndexBufferCopy.getType());
102 reallocate(IndexBufferCopy.
size());
104 for (
u32 n=0;n<IndexBufferCopy.
size();++n)
113 virtual void setType(video::E_INDEX_TYPE indexType)
override
115 if ( Indices && Indices->getType() == indexType )
118 IIndexList *NewIndices=0;
122 case video::EIT_16BIT:
124 NewIndices=
new CSpecificIndexList<u16>;
127 case video::EIT_32BIT:
129 NewIndices=
new CSpecificIndexList<u32>;
136 NewIndices->reallocate( Indices->size() );
138 for(
u32 n=0;n<Indices->size();++n)
139 NewIndices->push_back((*Indices)[n]);
147 virtual void*
getData()
override {
return Indices->pointer();}
148 virtual const void*
getData()
const override {
return Indices->const_pointer(); }
150 virtual video::E_INDEX_TYPE getType()
const override {
return Indices->getType();}
152 virtual u32 stride()
const override {
return Indices->stride();}
156 return Indices->size();
161 Indices->push_back(value);
166 return (*Indices)[index];
169 virtual u32 getLast()
override
171 return Indices->getLast();
176 Indices->setValue(index, value);
179 virtual void set_used(
u32 usedNow)
override
181 Indices->set_used(usedNow);
184 virtual void reallocate(
u32 new_size,
bool canShrink=
true)
override
186 Indices->reallocate(new_size, canShrink);
189 virtual u32 allocated_size()
const override
191 return Indices->allocated_size();
203 MappingHint=NewMappingHint;
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
Definition CIndexBuffer.hpp:16
virtual u32 size() const override
Number of elements.
Definition CIndexBuffer.hpp:154
virtual u32 stride() const override
Number of bytes per element.
Definition CIndexBuffer.hpp:152
virtual const void * getData() const override
Const pointer to first element.
Definition CIndexBuffer.hpp:148
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint) override
set the hardware mapping hint, for driver
Definition CIndexBuffer.hpp:201
virtual u32 operator[](u32 index) const override
Access element value at given index.
Definition CIndexBuffer.hpp:164
virtual void * getData() override
Pointer to first element.
Definition CIndexBuffer.hpp:147
virtual void push_back(u32 value) override
Add value to end. Note that for 16 bit index types values shouldn't be larger than u16.
Definition CIndexBuffer.hpp:159
virtual void setValue(u32 index, u32 value) override
Set value at index. Note that for 16 bit index types values shouldn't be larger than u16.
Definition CIndexBuffer.hpp:174
virtual E_HARDWARE_MAPPING getHardwareMappingHint() const override
get the current hardware mapping hint
Definition CIndexBuffer.hpp:195
virtual void setType(video::E_INDEX_TYPE indexType) override
Change between 16 and 32 bit indices.
Definition CIndexBuffer.hpp:113
virtual void setDirty() override
flags the mesh as changed, reloads hardware buffers
Definition CIndexBuffer.hpp:207
virtual u32 getChangedID() const override
Get the currently used ID for identification of changes.
Definition CIndexBuffer.hpp:214
Definition IIndexBuffer.hpp:20
virtual u32 size() const =0
Number of elements.
E_HARDWARE_MAPPING
Definition EHardwareBufferFlags.hpp:14
@ EHM_NEVER
Don't store on the hardware.
Definition EHardwareBufferFlags.hpp:16
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
unsigned short u16
16 bit unsigned variable.
Definition irrTypes.hpp:46
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64