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 = get_stride(format);
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("attrib", static_cast<void (Loader::*)(unsigned, float)>(&Loader::attrib));
74 add("attrib", static_cast<void (Loader::*)(unsigned, float, float)>(&Loader::attrib));
75 add("attrib", static_cast<void (Loader::*)(unsigned, float, float, float)>(&Loader::attrib));
76 add("attrib", static_cast<void (Loader::*)(unsigned, float, float, float, float)>(&Loader::attrib));
77 add("tangent", static_cast<void (Loader::*)(float, float, float)>(&Loader::tangent));
78 add("binormal", static_cast<void (Loader::*)(float, float, float)>(&Loader::binormal));
80 add("vertex2", static_cast<void (Loader::*)(float, float)>(&Loader::vertex));
81 add("vertex3", static_cast<void (Loader::*)(float, float, float)>(&Loader::vertex));
82 add("vertex4", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::vertex));
83 add("normal3", static_cast<void (Loader::*)(float, float, float)>(&Loader::normal));
84 add("texcoord1", static_cast<void (Loader::*)(float)>(&Loader::texcoord));
85 add("texcoord2", static_cast<void (Loader::*)(float, float)>(&Loader::texcoord));
86 add("texcoord3", static_cast<void (Loader::*)(float, float, float)>(&Loader::texcoord));
87 add("texcoord4", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::texcoord));
88 add("multitexcoord1", static_cast<void (Loader::*)(unsigned, float)>(&Loader::multitexcoord));
89 add("multitexcoord2", static_cast<void (Loader::*)(unsigned, float, float)>(&Loader::multitexcoord));
90 add("multitexcoord3", static_cast<void (Loader::*)(unsigned, float, float, float)>(&Loader::multitexcoord));
91 add("multitexcoord4", static_cast<void (Loader::*)(unsigned, float, float, float, float)>(&Loader::multitexcoord));
92 add("color3", static_cast<void (Loader::*)(float, float, float)>(&Loader::color));
93 add("color4", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::color));
94 add("attrib1", static_cast<void (Loader::*)(unsigned, float)>(&Loader::attrib));
95 add("attrib2", static_cast<void (Loader::*)(unsigned, float, float)>(&Loader::attrib));
96 add("attrib3", static_cast<void (Loader::*)(unsigned, float, float, float)>(&Loader::attrib));
97 add("attrib4", static_cast<void (Loader::*)(unsigned, float, float, float, float)>(&Loader::attrib));
98 add("tangent3", static_cast<void (Loader::*)(float, float, float)>(&Loader::tangent));
99 add("binormal3", static_cast<void (Loader::*)(float, float, float)>(&Loader::binormal));