]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/vertexformat.h
Rename VertexComponent to VertexAttribute
[libs/gl.git] / source / core / vertexformat.h
index 3561292245fc640deb2859629cbf8f39c1776e5b..3317a015d1ce195f0793fca816159a415a6f0b7c 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MSP_GL_VERTEXFORMAT_H_
 #define MSP_GL_VERTEXFORMAT_H_
 
+#include <msp/core/attributes.h>
 #include <msp/strings/lexicalcast.h>
 
 namespace Msp {
@@ -9,7 +10,7 @@ namespace GL {
 /** A single vertex component.  Symbolic names are provided for commonly used
 attributes.  These are aliased with with generic attributes, so be careful when
 picking your attribute indices. */
-enum VertexComponent
+enum VertexAttribute
 {
        VERTEX2 = 1,
        VERTEX3,
@@ -30,48 +31,59 @@ enum VertexComponent
        ATTRIB4
 };
 
+DEPRECATED typedef VertexAttribute VertexComponent;
+
 class VertexFormat
 {
 private:
-       enum { MAX_COMPONENTS = 15 };
+       enum { MAX_ATTRIBUTES = 15 };
 
        unsigned char count;
-       unsigned char components[MAX_COMPONENTS];
+       unsigned char attributes[MAX_ATTRIBUTES];
 
 public:
        VertexFormat();
-       VertexFormat(VertexComponent);
+       VertexFormat(VertexAttribute);
 
-       VertexFormat operator,(VertexComponent c) const;
-       VertexFormat operator,(unsigned i) const;
+       VertexFormat operator,(VertexAttribute) const;
+       VertexFormat operator,(unsigned) const;
        bool operator==(const VertexFormat &) const;
        bool operator!=(const VertexFormat &other) const { return !(*this==other); }
 
        bool empty() const { return !count; }
-       const unsigned char *begin() const { return components; }
-       const unsigned char *end() const { return components+count; }
+       const unsigned char *begin() const { return attributes; }
+       const unsigned char *end() const { return attributes+count; }
        unsigned stride() const;
-       int offset(VertexComponent) const;
+       int offset(VertexAttribute) const;
 };
 
-inline VertexFormat operator,(VertexComponent c1, VertexComponent c2)
-{ return (VertexFormat(c1), c2); }
+inline VertexFormat operator,(VertexAttribute a1, VertexAttribute a2)
+{ return (VertexFormat(a1), a2); }
+
+inline VertexFormat operator,(VertexAttribute a, unsigned i)
+{ return (VertexFormat(a), i); }
+
+VertexAttribute make_indexed_attribute(VertexAttribute, unsigned);
+
+DEPRECATED inline VertexAttribute make_indexed_component(VertexAttribute a, unsigned i)
+{ return make_indexed_attribute(a, i); }
 
-inline VertexFormat operator,(VertexComponent c, unsigned i)
-{ return (VertexFormat(c), i); }
+inline unsigned get_attribute_semantic(unsigned char a)
+{ return a>>2; }
 
-VertexComponent make_indexed_component(VertexComponent, unsigned);
+inline unsigned get_attribute_size(unsigned char a)
+{ return (a&3)+1; }
 
-inline unsigned get_component_type(unsigned char c)
-{ return c>>2; }
+DEPRECATED inline unsigned get_component_type(unsigned char c)
+{ return get_attribute_semantic(c); }
 
-inline unsigned get_component_size(unsigned char c)
-{ return (c&3)+1; }
+DEPRECATED inline unsigned get_component_size(unsigned char c)
+{ return get_attribute_size(c); }
 
-inline unsigned get_stride(const VertexFormat &f)
+DEPRECATED inline unsigned get_stride(const VertexFormat &f)
 { return f.stride(); }
 
-void operator>>(const LexicalConverter &, VertexComponent &);
+void operator>>(const LexicalConverter &, VertexAttribute &);
 
 } // namespace GL
 } // namespace Msp