5#ifndef NIRT_C_VERTEX_BUFFER_HPP_INCLUDED
6#define NIRT_C_VERTEX_BUFFER_HPP_INCLUDED
8#include <nirtcpp/core/engine/IVertexBuffer.hpp>
21 virtual ~IVertexList(){};
23 virtual u32 stride()
const =0;
25 virtual u32 size()
const =0;
37 virtual void set_used(
u32 usedNow) =0;
38 virtual void reallocate(
u32 new_size,
bool canShrink=
true) =0;
39 virtual u32 allocated_size()
const =0;
40 virtual void* pointer() =0;
41 virtual const void* const_pointer()
const =0;
46 class CSpecificVertexList :
public IVertexList
51 virtual u32 stride()
const override {
return sizeof(T);}
53 virtual u32 size()
const override {
return Vertices.size();}
56 {Vertices.push_back(element);}
58 {Vertices.push_back(element);}
60 {Vertices.push_back(element);}
63 {Vertices[index] = value;}
65 {Vertices[index] = value;}
67 {Vertices[index] = value;}
78 virtual void set_used(
u32 usedNow)
override
79 {Vertices.set_used(usedNow);}
81 virtual void reallocate(
u32 new_size,
bool canShrink)
override
82 {Vertices.reallocate(new_size, canShrink);}
84 virtual u32 allocated_size()
const override
86 return Vertices.allocated_size();
89 virtual void* pointer()
override {
return Vertices.pointer();}
90 virtual const void* const_pointer()
const override {
return Vertices.const_pointer();}
96 IVertexList *Vertices;
108 setType(VertexBufferCopy.getType());
109 reallocate(VertexBufferCopy.
size());
111 for (
u32 n=0;n<VertexBufferCopy.
size();++n)
122 if ( Vertices && Vertices->getType() == vertexType )
125 IVertexList *NewVertices=0;
131 NewVertices=
new CSpecificVertexList<video::S3DVertex>;
136 NewVertices=
new CSpecificVertexList<video::S3DVertex2TCoords>;
141 NewVertices=
new CSpecificVertexList<video::S3DVertexTangents>;
147 NewVertices->reallocate( Vertices->size() );
149 switch (Vertices->getType())
153 for(
u32 n=0;n<Vertices->size();++n)
154 NewVertices->push_back((*Vertices)[n]);
159 for(
u32 n=0;n<Vertices->size();++n)
165 for(
u32 n=0;n<Vertices->size();++n)
174 Vertices=NewVertices;
177 virtual void*
getData()
override {
return Vertices->pointer();}
178 virtual const void*
getData()
const override {
return Vertices->const_pointer();}
182 virtual u32 stride()
const override {
return Vertices->stride();}
186 return Vertices->size();
191 Vertices->push_back(element);
196 Vertices->push_back(element);
201 Vertices->push_back(element);
206 Vertices->setValue(index, value);
211 Vertices->setValue(index, value);
216 Vertices->setValue(index, value);
221 return (*Vertices)[index];
226 return (*Vertices)[index];
231 return Vertices->getLast();
234 virtual void set_used(
u32 usedNow)
override
236 Vertices->set_used(usedNow);
239 virtual void reallocate(
u32 new_size,
bool canShrink=
true)
override
241 Vertices->reallocate(new_size, canShrink);
244 virtual u32 allocated_size()
const override
246 return Vertices->allocated_size();
258 MappingHint=NewMappingHint;
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
Definition CVertexBuffer.hpp:17
virtual void setDirty() override
flags the mesh as changed, reloads hardware buffers
Definition CVertexBuffer.hpp:262
virtual u32 stride() const override
Number of bytes per element.
Definition CVertexBuffer.hpp:182
virtual void push_back(const video::S3DVertex &element) override
Add vertex to end.
Definition CVertexBuffer.hpp:189
virtual const void * getData() const override
Const pointer to first element.
Definition CVertexBuffer.hpp:178
virtual video::S3DVertex & operator[](u32 index) override
Direct access to elements. Risky to use!
Definition CVertexBuffer.hpp:219
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint) override
set the hardware mapping hint, for driver
Definition CVertexBuffer.hpp:256
virtual E_HARDWARE_MAPPING getHardwareMappingHint() const override
get the current hardware mapping hint
Definition CVertexBuffer.hpp:250
virtual u32 size() const override
Number of elements.
Definition CVertexBuffer.hpp:184
virtual void setValue(u32 index, const video::S3DVertex &value) override
Set value at index. Buffer must be already large enough that element exists.
Definition CVertexBuffer.hpp:204
virtual void * getData() override
Pointer to first element of vertex data.
Definition CVertexBuffer.hpp:177
virtual u32 getChangedID() const override
Get the currently used ID for identification of changes.
Definition CVertexBuffer.hpp:269
Definition IVertexBuffer.hpp:19
virtual u32 size() const =0
Number of elements.
Vertex with two texture coordinates.
Definition S3DVertex.hpp:116
Vertex with a tangent and binormal vector.
Definition S3DVertex.hpp:199
standard vertex used by the Nirtcpp engine.
Definition S3DVertex.hpp:45
E_HARDWARE_MAPPING
Definition EHardwareBufferFlags.hpp:14
@ EHM_NEVER
Don't store on the hardware.
Definition EHardwareBufferFlags.hpp:16
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition S3DVertex.hpp:19
@ EVT_2TCOORDS
Vertex with two texture coordinates, video::S3DVertex2TCoords.
Definition S3DVertex.hpp:25
@ EVT_STANDARD
Standard vertex type used by the Nirtcpp engine, video::S3DVertex.
Definition S3DVertex.hpp:21
@ EVT_TANGENTS
Vertex with a tangent and binormal vector, video::S3DVertexTangents.
Definition S3DVertex.hpp:31
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64