+unsigned VertexFormat::stride() const
+{
+ unsigned s = 0;
+ for(const unsigned char *i=begin(); i!=end(); ++i)
+ s += get_component_size(*i);
+ return s;
+}
+
+int VertexFormat::offset(VertexComponent comp, unsigned index) const
+{
+ if((comp<TEXCOORD1 && index>0) || (comp<ATTRIB1 && index>=8) || index>=53)
+ throw out_of_range("VertexFormat::offset");
+
+ unsigned type = get_component_type(comp)+index;
+ unsigned size = get_component_size(comp);
+ unsigned offs = 0;
+ for(const unsigned char *i=begin(); i!=end(); ++i)
+ {
+ if(get_component_type(*i)==type)
+ {
+ if(get_component_size(*i)>=size)
+ return offs;
+ else
+ return -1;
+ }
+ else
+ offs += get_component_size(*i);
+ }
+
+ return -1;
+}
+