X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fvertexformat.h;h=4ff3401778d15b5989130d4dcf6c2ce803eb4bee;hp=a503aff83f84f19bcbbb1d9e3009c77fd526d4bb;hb=38712d8ecc57d043a2419ffbaeeb57f7a6586f14;hpb=d493917dbc215cd6ba3f8773a52a289d9f14380d diff --git a/source/core/vertexformat.h b/source/core/vertexformat.h index a503aff8..4ff34017 100644 --- a/source/core/vertexformat.h +++ b/source/core/vertexformat.h @@ -1,7 +1,7 @@ #ifndef MSP_GL_VERTEXFORMAT_H_ #define MSP_GL_VERTEXFORMAT_H_ -#include +#include #include #include "datatype.h" @@ -20,8 +20,9 @@ are doing. The values are bitfields laid as follows: -nnnn nn_f gsss _ccc - │ │ │ │ └╴Number of components +nnnn nn_f gsss iccc + │ │ │ │ │ └╴Number of components + │ │ │ │ └───╴Integer attribute flag │ │ │ └─────╴Size of one component │ │ └────────╴Signed flag │ └──────────╴Floating-point flag @@ -30,7 +31,7 @@ nnnn nn_f gsss _ccc 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, @@ -39,10 +40,10 @@ enum VertexAttribute COLOR4 = 0x05C4, NORMAL3 = 0x09C3, TANGENT3 = 0x0DC3, - GROUP1 = 0x11C1, - GROUP2 = 0x11C2, - GROUP3 = 0x11C3, - GROUP4 = 0x11C4, + GROUP1 = 0x10C9, + GROUP2 = 0x10CA, + GROUP3 = 0x10CB, + GROUP4 = 0x10CC, WEIGHT1 = 0x15C1, WEIGHT2 = 0x15C2, WEIGHT3 = 0x15C3, @@ -55,10 +56,18 @@ enum VertexAttribute GENERIC2 = 0x29C2, GENERIC3 = 0x29C3, GENERIC4 = 0x29C4, + GENERIC_I1 = 0x28C9, + GENERIC_I2 = 0x28CA, + GENERIC_I3 = 0x28CB, + GENERIC_I4 = 0x28CC, RAW_ATTRIB1 = 0xFDC1, RAW_ATTRIB2 = 0xFDC2, RAW_ATTRIB3 = 0xFDC3, - RAW_ATTRIB4 = 0xFDC4 + RAW_ATTRIB4 = 0xFDC4, + RAW_ATTRIB_I1 = 0xFCC9, + RAW_ATTRIB_I2 = 0xFCCA, + RAW_ATTRIB_I3 = 0xFCCB, + RAW_ATTRIB_I4 = 0xFCCC }; class VertexFormat @@ -66,11 +75,11 @@ class VertexFormat private: enum { MAX_ATTRIBUTES = 15 }; - UInt8 count; - UInt16 attributes[MAX_ATTRIBUTES]; + std::uint8_t count = 0; + VertexAttribute attributes[MAX_ATTRIBUTES]; public: - VertexFormat(); + VertexFormat() = default; VertexFormat(VertexAttribute); VertexFormat operator,(VertexAttribute) const; @@ -80,8 +89,8 @@ public: bool operator!=(const VertexFormat &other) const { return !(*this==other); } bool empty() const { return !count; } - const UInt16 *begin() const { return attributes; } - const UInt16 *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; }; @@ -99,18 +108,21 @@ VertexAttribute make_indexed_attribute(VertexAttribute, unsigned); inline VertexAttribute operator,(VertexAttribute a, unsigned i) { return make_indexed_attribute(a, i); } -inline unsigned get_attribute_semantic(UInt16 a) +inline unsigned get_attribute_semantic(VertexAttribute a) { return a>>10; } -inline DataType get_attribute_source_type(UInt16 a) +inline DataType get_attribute_source_type(VertexAttribute a) { return static_cast((a&0x70)>>4 | (a&0x180)<<1); } -inline unsigned get_attribute_component_count(UInt16 a) +inline unsigned get_attribute_component_count(VertexAttribute a) { return a&7; } -inline unsigned get_attribute_size(UInt16 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(VertexAttribute a) +{ return a&8; } + void operator>>(const LexicalConverter &, VertexAttribute &); } // namespace GL