1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
8 #include "IIndexBuffer.h"
10 // Define to receive warnings when violating the hw mapping hints
11 //#define INDEXBUFFER_HINT_DEBUG
13 #ifdef INDEXBUFFER_HINT_DEBUG
14 #include "../src/os.h"
21 //! Template implementation of the IIndexBuffer interface
23 class CIndexBuffer final
: public IIndexBuffer
26 //! Default constructor for empty buffer
30 setDebugName("CIndexBuffer");
34 video::E_INDEX_TYPE
getType() const override
36 static_assert(sizeof(T
) == 2 || sizeof(T
) == 4, "invalid index type");
37 return sizeof(T
) == 2 ? video::EIT_16BIT
: video::EIT_32BIT
;
40 const void *getData() const override
45 void *getData() override
50 u32
getCount() const override
52 return static_cast<u32
>(Data
.size());
55 E_HARDWARE_MAPPING
getHardwareMappingHint() const override
60 void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint
) override
62 MappingHint
= NewMappingHint
;
65 void setDirty() override
68 #ifdef INDEXBUFFER_HINT_DEBUG
69 if (MappingHint
== EHM_STATIC
&& HWBuffer
) {
71 snprintf_irr(buf
, sizeof(buf
), "CIndexBuffer @ %p modified, but it has a static hint", this);
72 os::Printer::log(buf
, ELL_WARNING
);
77 u32
getChangedID() const override
{ return ChangedID
; }
79 void setHWBuffer(void *ptr
) const override
84 void *getHWBuffer() const override
91 //! hardware mapping hint
92 E_HARDWARE_MAPPING MappingHint
= EHM_NEVER
;
93 mutable void *HWBuffer
= nullptr;
95 //! Indices of this buffer
99 //! Standard 16-bit buffer
100 typedef CIndexBuffer
<u16
> SIndexBuffer
;
102 } // end namespace scene
103 } // end namespace irr