1 #include <msp/gl/extensions/arb_multitexture.h>
2 #include <msp/gl/extensions/arb_vertex_shader.h>
7 #include "vertexarray.h"
14 VertexArray::VertexArray(const VertexFormat &f)
19 void VertexArray::reset(const VertexFormat &f)
23 stride = format.stride();
26 void VertexArray::clear()
31 void VertexArray::reserve(unsigned n)
33 data.reserve(n*stride);
36 float *VertexArray::append()
38 data.insert(data.end(), stride, 0.0f);
41 return &*(data.end()-stride);
44 float *VertexArray::modify(unsigned i)
47 return &data[0]+i*stride;
50 unsigned VertexArray::get_data_size() const
52 return data.size()*sizeof(float);
56 VertexArray::Loader::Loader(VertexArray &a):
59 add("vertex", static_cast<void (Loader::*)(float, float)>(&Loader::vertex));
60 add("vertex", static_cast<void (Loader::*)(float, float, float)>(&Loader::vertex));
61 add("vertex", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::vertex));
62 add("normal", static_cast<void (Loader::*)(float, float, float)>(&Loader::normal));
63 add("texcoord", static_cast<void (Loader::*)(float)>(&Loader::texcoord));
64 add("texcoord", static_cast<void (Loader::*)(float, float)>(&Loader::texcoord));
65 add("texcoord", static_cast<void (Loader::*)(float, float, float)>(&Loader::texcoord));
66 add("texcoord", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::texcoord));
67 add("multitexcoord", static_cast<void (Loader::*)(unsigned, float)>(&Loader::multitexcoord));
68 add("multitexcoord", static_cast<void (Loader::*)(unsigned, float, float)>(&Loader::multitexcoord));
69 add("multitexcoord", static_cast<void (Loader::*)(unsigned, float, float, float)>(&Loader::multitexcoord));
70 add("multitexcoord", static_cast<void (Loader::*)(unsigned, float, float, float, float)>(&Loader::multitexcoord));
71 add("color", static_cast<void (Loader::*)(float, float, float)>(&Loader::color));
72 add("color", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::color));
73 add("generic", static_cast<void (Loader::*)(unsigned, float)>(&Loader::generic));
74 add("generic", static_cast<void (Loader::*)(unsigned, float, float)>(&Loader::generic));
75 add("generic", static_cast<void (Loader::*)(unsigned, float, float, float)>(&Loader::generic));
76 add("generic", static_cast<void (Loader::*)(unsigned, float, float, float, float)>(&Loader::generic));
77 add("tangent", static_cast<void (Loader::*)(float, float, float)>(&Loader::tangent));
78 add("binormal", static_cast<void (Loader::*)(float, float, float)>(&Loader::binormal));
79 add("group", static_cast<void (Loader::*)(int)>(&Loader::group));
80 add("group", static_cast<void (Loader::*)(int, int)>(&Loader::group));
81 add("group", static_cast<void (Loader::*)(int, int, int)>(&Loader::group));
82 add("group", static_cast<void (Loader::*)(int, int, int, int)>(&Loader::group));
83 add("weight", static_cast<void (Loader::*)(float)>(&Loader::weight));
84 add("weight", static_cast<void (Loader::*)(float, float)>(&Loader::weight));
85 add("weight", static_cast<void (Loader::*)(float, float, float)>(&Loader::weight));
86 add("weight", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::weight));
88 add("vertex2", static_cast<void (Loader::*)(float, float)>(&Loader::vertex));
89 add("vertex3", static_cast<void (Loader::*)(float, float, float)>(&Loader::vertex));
90 add("vertex4", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::vertex));
91 add("normal3", static_cast<void (Loader::*)(float, float, float)>(&Loader::normal));
92 add("texcoord1", static_cast<void (Loader::*)(float)>(&Loader::texcoord));
93 add("texcoord2", static_cast<void (Loader::*)(float, float)>(&Loader::texcoord));
94 add("texcoord3", static_cast<void (Loader::*)(float, float, float)>(&Loader::texcoord));
95 add("texcoord4", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::texcoord));
96 add("multitexcoord1", static_cast<void (Loader::*)(unsigned, float)>(&Loader::multitexcoord));
97 add("multitexcoord2", static_cast<void (Loader::*)(unsigned, float, float)>(&Loader::multitexcoord));
98 add("multitexcoord3", static_cast<void (Loader::*)(unsigned, float, float, float)>(&Loader::multitexcoord));
99 add("multitexcoord4", static_cast<void (Loader::*)(unsigned, float, float, float, float)>(&Loader::multitexcoord));
100 add("color3", static_cast<void (Loader::*)(float, float, float)>(&Loader::color));
101 add("color4", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::color));
102 add("generic1", static_cast<void (Loader::*)(unsigned, float)>(&Loader::generic));
103 add("generic2", static_cast<void (Loader::*)(unsigned, float, float)>(&Loader::generic));
104 add("generic3", static_cast<void (Loader::*)(unsigned, float, float, float)>(&Loader::generic));
105 add("generic4", static_cast<void (Loader::*)(unsigned, float, float, float, float)>(&Loader::generic));
106 add("tangent3", static_cast<void (Loader::*)(float, float, float)>(&Loader::tangent));
107 add("binormal3", static_cast<void (Loader::*)(float, float, float)>(&Loader::binormal));