1 #ifndef MSP_GL_VERTEXFORMAT_H_
2 #define MSP_GL_VERTEXFORMAT_H_
4 #include <msp/strings/lexicalcast.h>
9 /** A single vertex attribute. Commonly used attributes are named by their
10 semantical meaning in the standard shaders. Texture coordinates and generic
11 attributes can additionally be given an index. There are four texture
12 coordinate attributes available. The number of available generic attributes
13 depends on implementation limits, but is at least five.
15 RAW_ATTRIB is handled in a special way; creating an indexed attribute based on
16 it uses the index as raw attribute number. Only use it if you know what you
53 enum { MAX_ATTRIBUTES = 15 };
56 unsigned char attributes[MAX_ATTRIBUTES];
60 VertexFormat(VertexAttribute);
62 VertexFormat operator,(VertexAttribute) const;
63 VertexFormat operator,(unsigned) const;
64 bool operator==(const VertexFormat &) const;
65 bool operator!=(const VertexFormat &other) const { return !(*this==other); }
67 bool empty() const { return !count; }
68 const unsigned char *begin() const { return attributes; }
69 const unsigned char *end() const { return attributes+count; }
70 unsigned stride() const;
71 int offset(VertexAttribute) const;
74 inline VertexFormat operator,(VertexAttribute a1, VertexAttribute a2)
75 { return (VertexFormat(a1), a2); }
77 VertexAttribute make_indexed_attribute(VertexAttribute, unsigned);
79 inline VertexAttribute operator,(VertexAttribute a, unsigned i)
80 { return make_indexed_attribute(a, i); }
82 inline unsigned get_attribute_semantic(unsigned char a)
85 inline unsigned get_attribute_size(unsigned char a)
88 void operator>>(const LexicalConverter &, VertexAttribute &);