X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fvertexformat.h;h=4ff3401778d15b5989130d4dcf6c2ce803eb4bee;hp=85d525f9571e90d276cff19e9928c9bfb9d1cc3e;hb=38712d8ecc57d043a2419ffbaeeb57f7a6586f14;hpb=3a1b9cbe2441ae670a97541dc8ccb0a2860c8302 diff --git a/source/core/vertexformat.h b/source/core/vertexformat.h index 85d525f9..4ff34017 100644 --- a/source/core/vertexformat.h +++ b/source/core/vertexformat.h @@ -31,7 +31,7 @@ nnnn nn_f gsss iccc This information is presented for internal documentation purposes only; it is inadvisable for programs to rely on it. */ -enum VertexAttribute +enum VertexAttribute: std::uint16_t { VERTEX2 = 0x01C2, VERTEX3 = 0x01C3, @@ -75,11 +75,11 @@ class VertexFormat private: enum { MAX_ATTRIBUTES = 15 }; - std::uint8_t count; - std::uint16_t attributes[MAX_ATTRIBUTES]; + std::uint8_t count = 0; + VertexAttribute attributes[MAX_ATTRIBUTES]; public: - VertexFormat(); + VertexFormat() = default; VertexFormat(VertexAttribute); VertexFormat operator,(VertexAttribute) const; @@ -89,8 +89,8 @@ public: bool operator!=(const VertexFormat &other) const { return !(*this==other); } bool empty() const { return !count; } - const std::uint16_t *begin() const { return attributes; } - const std::uint16_t *end() const { return attributes+count; } + const VertexAttribute *begin() const { return attributes; } + const VertexAttribute *end() const { return attributes+count; } unsigned stride() const; int offset(VertexAttribute) const; }; @@ -108,19 +108,19 @@ VertexAttribute make_indexed_attribute(VertexAttribute, unsigned); inline VertexAttribute operator,(VertexAttribute a, unsigned i) { return make_indexed_attribute(a, i); } -inline unsigned get_attribute_semantic(std::uint16_t a) +inline unsigned get_attribute_semantic(VertexAttribute a) { return a>>10; } -inline DataType get_attribute_source_type(std::uint16_t a) +inline DataType get_attribute_source_type(VertexAttribute a) { return static_cast((a&0x70)>>4 | (a&0x180)<<1); } -inline unsigned get_attribute_component_count(std::uint16_t a) +inline unsigned get_attribute_component_count(VertexAttribute a) { return a&7; } -inline unsigned get_attribute_size(std::uint16_t a) +inline unsigned get_attribute_size(VertexAttribute a) { return get_attribute_component_count(a)*get_type_size(get_attribute_source_type(a)); } -inline bool is_integer_attribute(std::uint16_t a) +inline bool is_integer_attribute(VertexAttribute a) { return a&8; } void operator>>(const LexicalConverter &, VertexAttribute &);