diff options
Diffstat (limited to 'libraries/irrlicht-1.8/include/CIndexBuffer.h')
-rw-r--r-- | libraries/irrlicht-1.8/include/CIndexBuffer.h | 452 |
1 files changed, 226 insertions, 226 deletions
diff --git a/libraries/irrlicht-1.8/include/CIndexBuffer.h b/libraries/irrlicht-1.8/include/CIndexBuffer.h index b0bb436..4ecadb7 100644 --- a/libraries/irrlicht-1.8/include/CIndexBuffer.h +++ b/libraries/irrlicht-1.8/include/CIndexBuffer.h | |||
@@ -1,226 +1,226 @@ | |||
1 | // Copyright (C) 2008-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2008-2012 Nikolaus Gebhardt |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #ifndef __C_INDEX_BUFFER_H_INCLUDED__ | 5 | #ifndef __C_INDEX_BUFFER_H_INCLUDED__ |
6 | #define __C_INDEX_BUFFER_H_INCLUDED__ | 6 | #define __C_INDEX_BUFFER_H_INCLUDED__ |
7 | 7 | ||
8 | #include "IIndexBuffer.h" | 8 | #include "IIndexBuffer.h" |
9 | 9 | ||
10 | namespace irr | 10 | namespace irr |
11 | { | 11 | { |
12 | namespace scene | 12 | namespace scene |
13 | { | 13 | { |
14 | 14 | ||
15 | class CIndexBuffer : public IIndexBuffer | 15 | class CIndexBuffer : public IIndexBuffer |
16 | { | 16 | { |
17 | 17 | ||
18 | class IIndexList | 18 | class IIndexList |
19 | { | 19 | { |
20 | public: | 20 | public: |
21 | virtual ~IIndexList(){}; | 21 | virtual ~IIndexList(){}; |
22 | 22 | ||
23 | virtual u32 stride() const =0; | 23 | virtual u32 stride() const =0; |
24 | virtual u32 size() const =0; | 24 | virtual u32 size() const =0; |
25 | virtual void push_back(const u32 &element) =0; | 25 | virtual void push_back(const u32 &element) =0; |
26 | virtual u32 operator [](u32 index) const =0; | 26 | virtual u32 operator [](u32 index) const =0; |
27 | virtual u32 getLast() =0; | 27 | virtual u32 getLast() =0; |
28 | virtual void setValue(u32 index, u32 value) =0; | 28 | virtual void setValue(u32 index, u32 value) =0; |
29 | virtual void set_used(u32 usedNow) =0; | 29 | virtual void set_used(u32 usedNow) =0; |
30 | virtual void reallocate(u32 new_size) =0; | 30 | virtual void reallocate(u32 new_size) =0; |
31 | virtual u32 allocated_size() const =0; | 31 | virtual u32 allocated_size() const =0; |
32 | virtual void* pointer() =0; | 32 | virtual void* pointer() =0; |
33 | virtual video::E_INDEX_TYPE getType() const =0; | 33 | virtual video::E_INDEX_TYPE getType() const =0; |
34 | }; | 34 | }; |
35 | 35 | ||
36 | template <class T> | 36 | template <class T> |
37 | class CSpecificIndexList : public IIndexList | 37 | class CSpecificIndexList : public IIndexList |
38 | { | 38 | { |
39 | public: | 39 | public: |
40 | core::array<T> Indices; | 40 | core::array<T> Indices; |
41 | 41 | ||
42 | virtual u32 stride() const {return sizeof(T);} | 42 | virtual u32 stride() const {return sizeof(T);} |
43 | 43 | ||
44 | virtual u32 size() const {return Indices.size();} | 44 | virtual u32 size() const {return Indices.size();} |
45 | 45 | ||
46 | virtual void push_back(const u32 &element) | 46 | virtual void push_back(const u32 &element) |
47 | { | 47 | { |
48 | // push const ref due to compiler problem with gcc 4.6, big endian | 48 | // push const ref due to compiler problem with gcc 4.6, big endian |
49 | Indices.push_back((const T&)element); | 49 | Indices.push_back((const T&)element); |
50 | } | 50 | } |
51 | 51 | ||
52 | virtual u32 operator [](u32 index) const | 52 | virtual u32 operator [](u32 index) const |
53 | { | 53 | { |
54 | return (u32)(Indices[index]); | 54 | return (u32)(Indices[index]); |
55 | } | 55 | } |
56 | 56 | ||
57 | virtual u32 getLast() {return (u32)Indices.getLast();} | 57 | virtual u32 getLast() {return (u32)Indices.getLast();} |
58 | 58 | ||
59 | virtual void setValue(u32 index, u32 value) | 59 | virtual void setValue(u32 index, u32 value) |
60 | { | 60 | { |
61 | Indices[index]=(T)value; | 61 | Indices[index]=(T)value; |
62 | } | 62 | } |
63 | 63 | ||
64 | virtual void set_used(u32 usedNow) | 64 | virtual void set_used(u32 usedNow) |
65 | { | 65 | { |
66 | Indices.set_used(usedNow); | 66 | Indices.set_used(usedNow); |
67 | } | 67 | } |
68 | 68 | ||
69 | virtual void reallocate(u32 new_size) | 69 | virtual void reallocate(u32 new_size) |
70 | { | 70 | { |
71 | Indices.reallocate(new_size); | 71 | Indices.reallocate(new_size); |
72 | } | 72 | } |
73 | 73 | ||
74 | virtual u32 allocated_size() const | 74 | virtual u32 allocated_size() const |
75 | { | 75 | { |
76 | return Indices.allocated_size(); | 76 | return Indices.allocated_size(); |
77 | } | 77 | } |
78 | 78 | ||
79 | virtual void* pointer() {return Indices.pointer();} | 79 | virtual void* pointer() {return Indices.pointer();} |
80 | 80 | ||
81 | virtual video::E_INDEX_TYPE getType() const | 81 | virtual video::E_INDEX_TYPE getType() const |
82 | { | 82 | { |
83 | if (sizeof(T)==sizeof(u16)) | 83 | if (sizeof(T)==sizeof(u16)) |
84 | return video::EIT_16BIT; | 84 | return video::EIT_16BIT; |
85 | else | 85 | else |
86 | return video::EIT_32BIT; | 86 | return video::EIT_32BIT; |
87 | } | 87 | } |
88 | }; | 88 | }; |
89 | 89 | ||
90 | public: | 90 | public: |
91 | IIndexList *Indices; | 91 | IIndexList *Indices; |
92 | 92 | ||
93 | CIndexBuffer(video::E_INDEX_TYPE IndexType) :Indices(0), MappingHint(EHM_NEVER), ChangedID(1) | 93 | CIndexBuffer(video::E_INDEX_TYPE IndexType) :Indices(0), MappingHint(EHM_NEVER), ChangedID(1) |
94 | { | 94 | { |
95 | setType(IndexType); | 95 | setType(IndexType); |
96 | } | 96 | } |
97 | 97 | ||
98 | CIndexBuffer(const IIndexBuffer &IndexBufferCopy) :Indices(0), MappingHint(EHM_NEVER), ChangedID(1) | 98 | CIndexBuffer(const IIndexBuffer &IndexBufferCopy) :Indices(0), MappingHint(EHM_NEVER), ChangedID(1) |
99 | { | 99 | { |
100 | setType(IndexBufferCopy.getType()); | 100 | setType(IndexBufferCopy.getType()); |
101 | reallocate(IndexBufferCopy.size()); | 101 | reallocate(IndexBufferCopy.size()); |
102 | 102 | ||
103 | for (u32 n=0;n<IndexBufferCopy.size();++n) | 103 | for (u32 n=0;n<IndexBufferCopy.size();++n) |
104 | push_back(IndexBufferCopy[n]); | 104 | push_back(IndexBufferCopy[n]); |
105 | } | 105 | } |
106 | 106 | ||
107 | virtual ~CIndexBuffer() | 107 | virtual ~CIndexBuffer() |
108 | { | 108 | { |
109 | delete Indices; | 109 | delete Indices; |
110 | } | 110 | } |
111 | 111 | ||
112 | //virtual void setType(video::E_INDEX_TYPE IndexType); | 112 | //virtual void setType(video::E_INDEX_TYPE IndexType); |
113 | virtual void setType(video::E_INDEX_TYPE IndexType) | 113 | virtual void setType(video::E_INDEX_TYPE IndexType) |
114 | { | 114 | { |
115 | IIndexList *NewIndices=0; | 115 | IIndexList *NewIndices=0; |
116 | 116 | ||
117 | switch (IndexType) | 117 | switch (IndexType) |
118 | { | 118 | { |
119 | case video::EIT_16BIT: | 119 | case video::EIT_16BIT: |
120 | { | 120 | { |
121 | NewIndices=new CSpecificIndexList<u16>; | 121 | NewIndices=new CSpecificIndexList<u16>; |
122 | break; | 122 | break; |
123 | } | 123 | } |
124 | case video::EIT_32BIT: | 124 | case video::EIT_32BIT: |
125 | { | 125 | { |
126 | NewIndices=new CSpecificIndexList<u32>; | 126 | NewIndices=new CSpecificIndexList<u32>; |
127 | break; | 127 | break; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | if (Indices) | 131 | if (Indices) |
132 | { | 132 | { |
133 | NewIndices->reallocate( Indices->size() ); | 133 | NewIndices->reallocate( Indices->size() ); |
134 | 134 | ||
135 | for(u32 n=0;n<Indices->size();++n) | 135 | for(u32 n=0;n<Indices->size();++n) |
136 | NewIndices->push_back((*Indices)[n]); | 136 | NewIndices->push_back((*Indices)[n]); |
137 | 137 | ||
138 | delete Indices; | 138 | delete Indices; |
139 | } | 139 | } |
140 | 140 | ||
141 | Indices=NewIndices; | 141 | Indices=NewIndices; |
142 | } | 142 | } |
143 | 143 | ||
144 | virtual void* getData() {return Indices->pointer();} | 144 | virtual void* getData() {return Indices->pointer();} |
145 | 145 | ||
146 | virtual video::E_INDEX_TYPE getType() const {return Indices->getType();} | 146 | virtual video::E_INDEX_TYPE getType() const {return Indices->getType();} |
147 | 147 | ||
148 | virtual u32 stride() const {return Indices->stride();} | 148 | virtual u32 stride() const {return Indices->stride();} |
149 | 149 | ||
150 | virtual u32 size() const | 150 | virtual u32 size() const |
151 | { | 151 | { |
152 | return Indices->size(); | 152 | return Indices->size(); |
153 | } | 153 | } |
154 | 154 | ||
155 | virtual void push_back(const u32 &element) | 155 | virtual void push_back(const u32 &element) |
156 | { | 156 | { |
157 | Indices->push_back(element); | 157 | Indices->push_back(element); |
158 | } | 158 | } |
159 | 159 | ||
160 | virtual u32 operator [](u32 index) const | 160 | virtual u32 operator [](u32 index) const |
161 | { | 161 | { |
162 | return (*Indices)[index]; | 162 | return (*Indices)[index]; |
163 | } | 163 | } |
164 | 164 | ||
165 | virtual u32 getLast() | 165 | virtual u32 getLast() |
166 | { | 166 | { |
167 | return Indices->getLast(); | 167 | return Indices->getLast(); |
168 | } | 168 | } |
169 | 169 | ||
170 | virtual void setValue(u32 index, u32 value) | 170 | virtual void setValue(u32 index, u32 value) |
171 | { | 171 | { |
172 | Indices->setValue(index, value); | 172 | Indices->setValue(index, value); |
173 | } | 173 | } |
174 | 174 | ||
175 | virtual void set_used(u32 usedNow) | 175 | virtual void set_used(u32 usedNow) |
176 | { | 176 | { |
177 | Indices->set_used(usedNow); | 177 | Indices->set_used(usedNow); |
178 | } | 178 | } |
179 | 179 | ||
180 | virtual void reallocate(u32 new_size) | 180 | virtual void reallocate(u32 new_size) |
181 | { | 181 | { |
182 | Indices->reallocate(new_size); | 182 | Indices->reallocate(new_size); |
183 | } | 183 | } |
184 | 184 | ||
185 | virtual u32 allocated_size() const | 185 | virtual u32 allocated_size() const |
186 | { | 186 | { |
187 | return Indices->allocated_size(); | 187 | return Indices->allocated_size(); |
188 | } | 188 | } |
189 | 189 | ||
190 | virtual void* pointer() | 190 | virtual void* pointer() |
191 | { | 191 | { |
192 | return Indices->pointer(); | 192 | return Indices->pointer(); |
193 | } | 193 | } |
194 | 194 | ||
195 | //! get the current hardware mapping hint | 195 | //! get the current hardware mapping hint |
196 | virtual E_HARDWARE_MAPPING getHardwareMappingHint() const | 196 | virtual E_HARDWARE_MAPPING getHardwareMappingHint() const |
197 | { | 197 | { |
198 | return MappingHint; | 198 | return MappingHint; |
199 | } | 199 | } |
200 | 200 | ||
201 | //! set the hardware mapping hint, for driver | 201 | //! set the hardware mapping hint, for driver |
202 | virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint ) | 202 | virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint ) |
203 | { | 203 | { |
204 | MappingHint=NewMappingHint; | 204 | MappingHint=NewMappingHint; |
205 | } | 205 | } |
206 | 206 | ||
207 | //! flags the mesh as changed, reloads hardware buffers | 207 | //! flags the mesh as changed, reloads hardware buffers |
208 | virtual void setDirty() | 208 | virtual void setDirty() |
209 | { | 209 | { |
210 | ++ChangedID; | 210 | ++ChangedID; |
211 | } | 211 | } |
212 | 212 | ||
213 | //! Get the currently used ID for identification of changes. | 213 | //! Get the currently used ID for identification of changes. |
214 | /** This shouldn't be used for anything outside the VideoDriver. */ | 214 | /** This shouldn't be used for anything outside the VideoDriver. */ |
215 | virtual u32 getChangedID() const {return ChangedID;} | 215 | virtual u32 getChangedID() const {return ChangedID;} |
216 | 216 | ||
217 | E_HARDWARE_MAPPING MappingHint; | 217 | E_HARDWARE_MAPPING MappingHint; |
218 | u32 ChangedID; | 218 | u32 ChangedID; |
219 | }; | 219 | }; |
220 | 220 | ||
221 | 221 | ||
222 | } // end namespace scene | 222 | } // end namespace scene |
223 | } // end namespace irr | 223 | } // end namespace irr |
224 | 224 | ||
225 | #endif | 225 | #endif |
226 | 226 | ||