1 #ifndef MSP_GL_VERTEXFORMAT_H_
2 #define MSP_GL_VERTEXFORMAT_H_
4 #include <msp/strings/lexicalcast.h>
9 /** A single vertex component. Nvidia drivers have aliasing between the
10 fixed-functions and generic vertex attributes, despite the standard not
11 allowing it. We use the same attribute indices here to avoid problems. */
38 VertexFormat(VertexComponent);
39 VertexFormat(const VertexFormat &);
40 VertexFormat &operator=(const VertexFormat &);
43 VertexFormat operator,(VertexComponent c) const;
44 VertexFormat operator,(unsigned i) const;
46 bool empty() const { return !data || !data[0]; }
47 const unsigned char *begin() const { return data ? data+1 : 0; }
48 const unsigned char *end() const { return data ? data+1+data[0] : 0; }
49 unsigned stride() const;
50 int offset(VertexComponent) const;
53 inline VertexFormat operator,(VertexComponent c1, VertexComponent c2)
54 { return (VertexFormat(c1), c2); }
56 inline VertexFormat operator,(VertexComponent c, unsigned i)
57 { return (VertexFormat(c), i); }
59 VertexComponent make_indexed_component(VertexComponent, unsigned);
61 inline unsigned get_component_type(unsigned char c)
64 inline unsigned get_component_size(unsigned char c)
67 inline unsigned get_stride(const VertexFormat &f)
68 { return f.stride(); }
70 void operator>>(const LexicalConverter &, VertexComponent &);