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. */
40 VertexFormat(VertexComponent);
41 VertexFormat(const VertexFormat &);
42 VertexFormat &operator=(const VertexFormat &);
45 VertexFormat operator,(VertexComponent c) const;
46 VertexFormat operator,(unsigned i) const;
48 bool empty() const { return !data || !data[0]; }
49 const unsigned char *begin() const { return data ? data+1 : 0; }
50 const unsigned char *end() const { return data ? data+1+data[0] : 0; }
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 &);