1 #ifndef MSP_GL_VERTEXFORMAT_H_
2 #define MSP_GL_VERTEXFORMAT_H_
4 #include <msp/core/attributes.h>
5 #include <msp/strings/lexicalcast.h>
10 /** A single vertex component. Symbolic names are provided for commonly used
11 attributes. These are aliased with with generic attributes, so be careful when
12 picking your attribute indices. */
34 DEPRECATED typedef VertexAttribute VertexComponent;
39 enum { MAX_ATTRIBUTES = 15 };
42 unsigned char attributes[MAX_ATTRIBUTES];
46 VertexFormat(VertexAttribute);
48 VertexFormat operator,(VertexAttribute) const;
49 VertexFormat operator,(unsigned) const;
50 bool operator==(const VertexFormat &) const;
51 bool operator!=(const VertexFormat &other) const { return !(*this==other); }
53 bool empty() const { return !count; }
54 const unsigned char *begin() const { return attributes; }
55 const unsigned char *end() const { return attributes+count; }
56 unsigned stride() const;
57 int offset(VertexAttribute) const;
60 inline VertexFormat operator,(VertexAttribute a1, VertexAttribute a2)
61 { return (VertexFormat(a1), a2); }
63 inline VertexFormat operator,(VertexAttribute a, unsigned i)
64 { return (VertexFormat(a), i); }
66 VertexAttribute make_indexed_attribute(VertexAttribute, unsigned);
68 DEPRECATED inline VertexAttribute make_indexed_component(VertexAttribute a, unsigned i)
69 { return make_indexed_attribute(a, i); }
71 inline unsigned get_attribute_semantic(unsigned char a)
74 inline unsigned get_attribute_size(unsigned char a)
77 DEPRECATED inline unsigned get_component_type(unsigned char c)
78 { return get_attribute_semantic(c); }
80 DEPRECATED inline unsigned get_component_size(unsigned char c)
81 { return get_attribute_size(c); }
83 DEPRECATED inline unsigned get_stride(const VertexFormat &f)
84 { return f.stride(); }
86 void operator>>(const LexicalConverter &, VertexAttribute &);