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 attribute. Commonly used attributes are named by their
11 semantical meaning in the standard shaders. Texture coordinates and generic
12 attributes can additionally be given an index. There are four texture
13 coordinate attributes available. The number of available generic attributes
14 depends on implementation limits, but is at least five.
16 RAW_ATTRIB is handled in a special way; creating an indexed attribute based on
17 it uses the index as raw attribute number. Only use it if you know what you
51 DEPRECATED typedef VertexAttribute VertexComponent;
56 enum { MAX_ATTRIBUTES = 15 };
59 unsigned char attributes[MAX_ATTRIBUTES];
63 VertexFormat(VertexAttribute);
65 VertexFormat operator,(VertexAttribute) const;
66 VertexFormat operator,(unsigned) const;
67 bool operator==(const VertexFormat &) const;
68 bool operator!=(const VertexFormat &other) const { return !(*this==other); }
70 bool empty() const { return !count; }
71 const unsigned char *begin() const { return attributes; }
72 const unsigned char *end() const { return attributes+count; }
73 unsigned stride() const;
74 int offset(VertexAttribute) const;
77 inline VertexFormat operator,(VertexAttribute a1, VertexAttribute a2)
78 { return (VertexFormat(a1), a2); }
80 inline VertexFormat operator,(VertexAttribute a, unsigned i)
81 { return (VertexFormat(a), i); }
83 VertexAttribute make_indexed_attribute(VertexAttribute, unsigned);
85 DEPRECATED inline VertexAttribute make_indexed_component(VertexAttribute a, unsigned i)
86 { return make_indexed_attribute(a, i); }
88 inline unsigned get_attribute_semantic(unsigned char a)
91 inline unsigned get_attribute_size(unsigned char a)
94 DEPRECATED inline unsigned get_component_type(unsigned char c)
95 { return get_attribute_semantic(c); }
97 DEPRECATED inline unsigned get_component_size(unsigned char c)
98 { return get_attribute_size(c); }
100 DEPRECATED inline unsigned get_stride(const VertexFormat &f)
101 { return f.stride(); }
103 void operator>>(const LexicalConverter &, VertexAttribute &);