1 #ifndef MSP_GL_VERTEXFORMAT_H_
2 #define MSP_GL_VERTEXFORMAT_H_
4 #include <msp/strings/lexicalcast.h>
9 /** A single vertex component. Symbolic names are provided for commonly used
10 attributes. These are aliased with with generic attributes, so be careful when
11 picking your attribute indices. */
36 enum { MAX_COMPONENTS = 15 };
39 unsigned char components[MAX_COMPONENTS];
43 VertexFormat(VertexComponent);
45 VertexFormat operator,(VertexComponent c) const;
46 VertexFormat operator,(unsigned i) const;
48 bool empty() const { return !count; }
49 const unsigned char *begin() const { return components; }
50 const unsigned char *end() const { return components+count; }
51 unsigned stride() const;
52 int offset(VertexComponent) const;
55 inline VertexFormat operator,(VertexComponent c1, VertexComponent c2)
56 { return (VertexFormat(c1), c2); }
58 inline VertexFormat operator,(VertexComponent c, unsigned i)
59 { return (VertexFormat(c), i); }
61 VertexComponent make_indexed_component(VertexComponent, unsigned);
63 inline unsigned get_component_type(unsigned char c)
66 inline unsigned get_component_size(unsigned char c)
69 inline unsigned get_stride(const VertexFormat &f)
70 { return f.stride(); }
72 void operator>>(const LexicalConverter &, VertexComponent &);