X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fvertexformat.h;h=64c89e13166abae491fa2a50d30785cddd7a86cc;hp=4ff3401778d15b5989130d4dcf6c2ce803eb4bee;hb=7ef75a4c4dbfc437e466381dd67c23357e607b82;hpb=38712d8ecc57d043a2419ffbaeeb57f7a6586f14 diff --git a/source/core/vertexformat.h b/source/core/vertexformat.h index 4ff34017..64c89e13 100644 --- a/source/core/vertexformat.h +++ b/source/core/vertexformat.h @@ -8,7 +8,8 @@ namespace Msp { namespace GL { -/** A single vertex attribute. Commonly used attributes are named by their +/** +A single vertex attribute. Commonly used attributes are named by their semantical meaning in the standard shaders. Texture coordinates and generic attributes can additionally be given an index. There are four texture coordinate attributes available. The number of available generic attributes @@ -29,7 +30,7 @@ nnnn nn_f gsss iccc └────────────╴Attribute index (semantic) This information is presented for internal documentation purposes only; it is -inadvisable for programs to rely on it. +inadvisable for applications to rely on it. */ enum VertexAttribute: std::uint16_t { @@ -70,11 +71,15 @@ enum VertexAttribute: std::uint16_t RAW_ATTRIB_I4 = 0xFCCC }; +/** +Describes the attributes of a vertex. Up to 15 attributes are allowed. +*/ class VertexFormat { -private: - enum { MAX_ATTRIBUTES = 15 }; +public: + static constexpr unsigned MAX_ATTRIBUTES = 15; +private: std::uint8_t count = 0; VertexAttribute attributes[MAX_ATTRIBUTES]; @@ -91,7 +96,13 @@ public: bool empty() const { return !count; } const VertexAttribute *begin() const { return attributes; } const VertexAttribute *end() const { return attributes+count; } + + /** Returns the displacement from one vertex to the next. */ unsigned stride() const; + + /** Returns the offset of an attribute within a vertex. A stored attribute + must have the same semantic and type and at least as many components as + requested to be considered a match. */ int offset(VertexAttribute) const; };