2 #include "vertexarray.h"
9 VertexArray::VertexArray(const VertexFormat &f)
14 void VertexArray::set_format(const VertexFormat &f)
17 throw invalid_operation("VertexArray::set_format");
19 stride = format.stride();
22 void VertexArray::clear()
27 void VertexArray::reserve(unsigned n)
30 throw invalid_operation("VertexArray::reserve");
31 data.reserve(n*stride);
34 char *VertexArray::append()
37 throw invalid_operation("VertexArray::append");
38 data.insert(data.end(), stride, 0.0f);
41 return &*(data.end()-stride);
44 char *VertexArray::modify(unsigned i)
47 throw invalid_operation("VertexArray::modify");
49 return &data[0]+i*stride;
52 unsigned VertexArray::get_data_size() const
58 VertexArray::Loader::Loader(VertexArray &a):
61 add("vertex", static_cast<void (Loader::*)(float, float)>(&Loader::vertex));
62 add("vertex", static_cast<void (Loader::*)(float, float, float)>(&Loader::vertex));
63 add("vertex", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::vertex));
64 add("normal", static_cast<void (Loader::*)(float, float, float)>(&Loader::normal));
65 add("tangent", static_cast<void (Loader::*)(float, float, float)>(&Loader::tangent));
66 add("texcoord", static_cast<void (Loader::*)(float)>(&Loader::texcoord));
67 add("texcoord", static_cast<void (Loader::*)(float, float)>(&Loader::texcoord));
68 add("texcoord", static_cast<void (Loader::*)(float, float, float)>(&Loader::texcoord));
69 add("texcoord", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::texcoord));
70 add("multitexcoord", static_cast<void (Loader::*)(unsigned, float)>(&Loader::multitexcoord));
71 add("multitexcoord", static_cast<void (Loader::*)(unsigned, float, float)>(&Loader::multitexcoord));
72 add("multitexcoord", static_cast<void (Loader::*)(unsigned, float, float, float)>(&Loader::multitexcoord));
73 add("multitexcoord", static_cast<void (Loader::*)(unsigned, float, float, float, float)>(&Loader::multitexcoord));
74 add("color", static_cast<void (Loader::*)(float, float, float)>(&Loader::color));
75 add("color", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::color));
76 add("generic", static_cast<void (Loader::*)(unsigned, float)>(&Loader::generic));
77 add("generic", static_cast<void (Loader::*)(unsigned, float, float)>(&Loader::generic));
78 add("generic", static_cast<void (Loader::*)(unsigned, float, float, float)>(&Loader::generic));
79 add("generic", static_cast<void (Loader::*)(unsigned, float, float, float, float)>(&Loader::generic));
80 add("group", static_cast<void (Loader::*)(int)>(&Loader::group));
81 add("group", static_cast<void (Loader::*)(int, int)>(&Loader::group));
82 add("group", static_cast<void (Loader::*)(int, int, int)>(&Loader::group));
83 add("group", static_cast<void (Loader::*)(int, int, int, int)>(&Loader::group));
84 add("weight", static_cast<void (Loader::*)(float)>(&Loader::weight));
85 add("weight", static_cast<void (Loader::*)(float, float)>(&Loader::weight));
86 add("weight", static_cast<void (Loader::*)(float, float, float)>(&Loader::weight));
87 add("weight", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::weight));