aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/include/CVertexBuffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/include/CVertexBuffer.h')
-rw-r--r--src/others/irrlicht-1.8.1/include/CVertexBuffer.h210
1 files changed, 210 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/include/CVertexBuffer.h b/src/others/irrlicht-1.8.1/include/CVertexBuffer.h
new file mode 100644
index 0000000..c721419
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/include/CVertexBuffer.h
@@ -0,0 +1,210 @@
1// Copyright (C) 2008-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
4
5#ifndef __C_VERTEX_BUFFER_H_INCLUDED__
6#define __C_VERTEX_BUFFER_H_INCLUDED__
7
8#include "IVertexBuffer.h"
9
10
11namespace irr
12{
13namespace scene
14{
15
16 class CVertexBuffer : public IVertexBuffer
17 {
18 class IVertexList
19 {
20 public:
21 virtual ~IVertexList(){};
22
23 virtual u32 stride() const =0;
24
25 virtual u32 size() const =0;
26
27 virtual void push_back (const video::S3DVertex &element) =0;
28 virtual video::S3DVertex& operator [](const u32 index) const =0;
29 virtual video::S3DVertex& getLast() =0;
30 virtual void set_used(u32 usedNow) =0;
31 virtual void reallocate(u32 new_size) =0;
32 virtual u32 allocated_size() const =0;
33 virtual video::S3DVertex* pointer() =0;
34 virtual video::E_VERTEX_TYPE getType() const =0;
35 };
36
37 template <class T>
38 class CSpecificVertexList : public IVertexList
39 {
40 public:
41 core::array<T> Vertices;
42
43 virtual u32 stride() const {return sizeof(T);}
44
45 virtual u32 size() const {return Vertices.size();}
46
47 virtual void push_back (const video::S3DVertex &element)
48 {Vertices.push_back((T&)element);}
49
50 virtual video::S3DVertex& operator [](const u32 index) const
51 {return (video::S3DVertex&)Vertices[index];}
52
53 virtual video::S3DVertex& getLast()
54 {return (video::S3DVertex&)Vertices.getLast();}
55
56 virtual void set_used(u32 usedNow)
57 {Vertices.set_used(usedNow);}
58
59 virtual void reallocate(u32 new_size)
60 {Vertices.reallocate(new_size);}
61
62 virtual u32 allocated_size() const
63 {
64 return Vertices.allocated_size();
65 }
66
67 virtual video::S3DVertex* pointer() {return Vertices.pointer();}
68
69 virtual video::E_VERTEX_TYPE getType() const {return T().getType();}
70 };
71
72 public:
73 IVertexList *Vertices;
74
75 CVertexBuffer(video::E_VERTEX_TYPE vertexType) : Vertices(0),
76 MappingHint(EHM_NEVER), ChangedID(1)
77 {
78 setType(vertexType);
79 }
80
81 CVertexBuffer(const IVertexBuffer &VertexBufferCopy) :
82 Vertices(0), MappingHint(EHM_NEVER),
83 ChangedID(1)
84 {
85 setType(VertexBufferCopy.getType());
86 reallocate(VertexBufferCopy.size());
87
88 for (u32 n=0;n<VertexBufferCopy.size();++n)
89 push_back(VertexBufferCopy[n]);
90 }
91
92 virtual ~CVertexBuffer()
93 {
94 delete Vertices;
95 }
96
97
98 virtual void setType(video::E_VERTEX_TYPE vertexType)
99 {
100 IVertexList *NewVertices=0;
101
102 switch (vertexType)
103 {
104 case video::EVT_STANDARD:
105 {
106 NewVertices=new CSpecificVertexList<video::S3DVertex>;
107 break;
108 }
109 case video::EVT_2TCOORDS:
110 {
111 NewVertices=new CSpecificVertexList<video::S3DVertex2TCoords>;
112 break;
113 }
114 case video::EVT_TANGENTS:
115 {
116 NewVertices=new CSpecificVertexList<video::S3DVertexTangents>;
117 break;
118 }
119 }
120 if (Vertices)
121 {
122 NewVertices->reallocate( Vertices->size() );
123
124 for(u32 n=0;n<Vertices->size();++n)
125 NewVertices->push_back((*Vertices)[n]);
126
127 delete Vertices;
128 }
129
130 Vertices=NewVertices;
131 }
132
133 virtual void* getData() {return Vertices->pointer();}
134
135 virtual video::E_VERTEX_TYPE getType() const {return Vertices->getType();}
136
137 virtual u32 stride() const {return Vertices->stride();}
138
139 virtual u32 size() const
140 {
141 return Vertices->size();
142 }
143
144 virtual void push_back (const video::S3DVertex &element)
145 {
146 Vertices->push_back(element);
147 }
148
149 virtual video::S3DVertex& operator [](const u32 index) const
150 {
151 return (*Vertices)[index];
152 }
153
154 virtual video::S3DVertex& getLast()
155 {
156 return Vertices->getLast();
157 }
158
159 virtual void set_used(u32 usedNow)
160 {
161 Vertices->set_used(usedNow);
162 }
163
164 virtual void reallocate(u32 new_size)
165 {
166 Vertices->reallocate(new_size);
167 }
168
169 virtual u32 allocated_size() const
170 {
171 return Vertices->allocated_size();
172 }
173
174 virtual video::S3DVertex* pointer()
175 {
176 return Vertices->pointer();
177 }
178
179 //! get the current hardware mapping hint
180 virtual E_HARDWARE_MAPPING getHardwareMappingHint() const
181 {
182 return MappingHint;
183 }
184
185 //! set the hardware mapping hint, for driver
186 virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint )
187 {
188 MappingHint=NewMappingHint;
189 }
190
191 //! flags the mesh as changed, reloads hardware buffers
192 virtual void setDirty()
193 {
194 ++ChangedID;
195 }
196
197 //! Get the currently used ID for identification of changes.
198 /** This shouldn't be used for anything outside the VideoDriver. */
199 virtual u32 getChangedID() const {return ChangedID;}
200
201 E_HARDWARE_MAPPING MappingHint;
202 u32 ChangedID;
203 };
204
205
206} // end namespace scene
207} // end namespace irr
208
209#endif
210