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;
47 bool operator==(const VertexFormat &) const;
48 bool operator!=(const VertexFormat &other) const { return !(*this==other); }
50 bool empty() const { return !count; }
51 const unsigned char *begin() const { return components; }
52 const unsigned char *end() const { return components+count; }
53 unsigned stride() const;
54 int offset(VertexComponent) const;
57 inline VertexFormat operator,(VertexComponent c1, VertexComponent c2)
58 { return (VertexFormat(c1), c2); }
60 inline VertexFormat operator,(VertexComponent c, unsigned i)
61 { return (VertexFormat(c), i); }
63 VertexComponent make_indexed_component(VertexComponent, unsigned);
65 inline unsigned get_component_type(unsigned char c)
68 inline unsigned get_component_size(unsigned char c)
71 inline unsigned get_stride(const VertexFormat &f)
72 { return f.stride(); }
74 void operator>>(const LexicalConverter &, VertexComponent &);