1 #include <msp/gl/extensions/arb_multitexture.h>
2 #include <msp/gl/extensions/arb_vertex_shader.h>
7 #include "vertexarray.h"
14 VertexArray::VertexArray():
18 VertexArray::VertexArray(const VertexFormat &f)
23 void VertexArray::set_format(const VertexFormat &f)
26 throw invalid_operation("VertexArray::set_format");
28 stride = format.stride();
31 void VertexArray::clear()
36 void VertexArray::reserve(unsigned n)
39 throw invalid_operation("VertexArray::reserve");
40 data.reserve(n*stride);
43 char *VertexArray::append()
46 throw invalid_operation("VertexArray::append");
47 data.insert(data.end(), stride, 0.0f);
50 return &*(data.end()-stride);
53 char *VertexArray::modify(unsigned i)
56 throw invalid_operation("VertexArray::modify");
58 return &data[0]+i*stride;
61 unsigned VertexArray::get_data_size() const
67 VertexArray::Loader::Loader(VertexArray &a):
70 add("vertex", static_cast<void (Loader::*)(float, float)>(&Loader::vertex));
71 add("vertex", static_cast<void (Loader::*)(float, float, float)>(&Loader::vertex));
72 add("vertex", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::vertex));
73 add("normal", static_cast<void (Loader::*)(float, float, float)>(&Loader::normal));
74 add("tangent", static_cast<void (Loader::*)(float, float, float)>(&Loader::tangent));
75 add("texcoord", static_cast<void (Loader::*)(float)>(&Loader::texcoord));
76 add("texcoord", static_cast<void (Loader::*)(float, float)>(&Loader::texcoord));
77 add("texcoord", static_cast<void (Loader::*)(float, float, float)>(&Loader::texcoord));
78 add("texcoord", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::texcoord));
79 add("multitexcoord", static_cast<void (Loader::*)(unsigned, float)>(&Loader::multitexcoord));
80 add("multitexcoord", static_cast<void (Loader::*)(unsigned, float, float)>(&Loader::multitexcoord));
81 add("multitexcoord", static_cast<void (Loader::*)(unsigned, float, float, float)>(&Loader::multitexcoord));
82 add("multitexcoord", static_cast<void (Loader::*)(unsigned, float, float, float, float)>(&Loader::multitexcoord));
83 add("color", static_cast<void (Loader::*)(float, float, float)>(&Loader::color));
84 add("color", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::color));
85 add("generic", static_cast<void (Loader::*)(unsigned, float)>(&Loader::generic));
86 add("generic", static_cast<void (Loader::*)(unsigned, float, float)>(&Loader::generic));
87 add("generic", static_cast<void (Loader::*)(unsigned, float, float, float)>(&Loader::generic));
88 add("generic", static_cast<void (Loader::*)(unsigned, float, float, float, float)>(&Loader::generic));
89 add("group", static_cast<void (Loader::*)(int)>(&Loader::group));
90 add("group", static_cast<void (Loader::*)(int, int)>(&Loader::group));
91 add("group", static_cast<void (Loader::*)(int, int, int)>(&Loader::group));
92 add("group", static_cast<void (Loader::*)(int, int, int, int)>(&Loader::group));
93 add("weight", static_cast<void (Loader::*)(float)>(&Loader::weight));
94 add("weight", static_cast<void (Loader::*)(float, float)>(&Loader::weight));
95 add("weight", static_cast<void (Loader::*)(float, float, float)>(&Loader::weight));
96 add("weight", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::weight));