return s;
}
+int VertexFormat::offset(VertexComponent comp, unsigned index) const
+{
+ if((comp<TEXCOORD1 && index>0) || (comp<ATTRIB1 && index>=8) || index>=53)
+ throw InvalidParameterValue("Vertex component index out of range");
+
+ unsigned type = (comp>>2)+index;
+ unsigned size = comp&3;
+ unsigned offs = 0;
+ for(const unsigned char *i=begin(); i!=end(); ++i)
+ {
+ if((*i>>2)==type)
+ {
+ if((*i&3)>=size)
+ return offs;
+ else
+ return -1;
+ }
+ else
+ offs += (*i&3)+1;
+ }
+
+ return -1;
+}
+
VertexFormat operator,(const VertexFormat &f, VertexComponent c)
{
VertexFormat r = f;
const unsigned char *begin() const { return data ? data+1 : 0; }
const unsigned char *end() const { return data ? data+1+data[0] : 0; }
unsigned stride() const;
+ int offset(VertexComponent, unsigned = 0) const;
};
VertexFormat operator,(const VertexFormat &f, VertexComponent c);