Use openssl's sha1 and sha256, optionally (#15472)
[minetest.git] / irr / include / CIndexBuffer.h
blob904b0ab9ae430245bde8a8ce0ddd5d88fe28a093
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
5 #pragma once
7 #include <vector>
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"
15 #endif
17 namespace irr
19 namespace scene
21 //! Template implementation of the IIndexBuffer interface
22 template <class T>
23 class CIndexBuffer final : public IIndexBuffer
25 public:
26 //! Default constructor for empty buffer
27 CIndexBuffer()
29 #ifdef _DEBUG
30 setDebugName("CIndexBuffer");
31 #endif
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
42 return Data.data();
45 void *getData() override
47 return Data.data();
50 u32 getCount() const override
52 return static_cast<u32>(Data.size());
55 E_HARDWARE_MAPPING getHardwareMappingHint() const override
57 return MappingHint;
60 void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint) override
62 MappingHint = NewMappingHint;
65 void setDirty() override
67 ++ChangedID;
68 #ifdef INDEXBUFFER_HINT_DEBUG
69 if (MappingHint == EHM_STATIC && HWBuffer) {
70 char buf[100];
71 snprintf_irr(buf, sizeof(buf), "CIndexBuffer @ %p modified, but it has a static hint", this);
72 os::Printer::log(buf, ELL_WARNING);
74 #endif
77 u32 getChangedID() const override { return ChangedID; }
79 void setHWBuffer(void *ptr) const override
81 HWBuffer = ptr;
84 void *getHWBuffer() const override
86 return HWBuffer;
89 u32 ChangedID = 1;
91 //! hardware mapping hint
92 E_HARDWARE_MAPPING MappingHint = EHM_NEVER;
93 mutable void *HWBuffer = nullptr;
95 //! Indices of this buffer
96 std::vector<T> Data;
99 //! Standard 16-bit buffer
100 typedef CIndexBuffer<u16> SIndexBuffer;
102 } // end namespace scene
103 } // end namespace irr