X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fvertexformat.cpp;h=7dcb7aba5472e9438671ef31da1036ef15276c8b;hp=5d0b078fe06f154b2821ab176a2bf9310132c253;hb=e92de029768eef5f0fd744329e589161b46d0762;hpb=9904aa3d09458098541fdce0114785d6bce1777f diff --git a/source/core/vertexformat.cpp b/source/core/vertexformat.cpp index 5d0b078f..7dcb7aba 100644 --- a/source/core/vertexformat.cpp +++ b/source/core/vertexformat.cpp @@ -97,6 +97,8 @@ VertexAttribute make_typed_attribute(VertexAttribute attr, DataType type) { if(is_matrix(type) || is_vector(type) || is_image(type)) throw invalid_argument("make_typed_attribute"); + if(is_integer_attribute(attr) && is_float(type)) + throw invalid_argument("make_typed_attribute"); return static_cast((attr&0xFC0F) | (type&0x0F)<<4 | (type&0x300)>>1); } @@ -140,9 +142,19 @@ bool convert_attribute(const string &str, const char *name, int min_size, int ma for(; *name; ++name, ++i) if(*i!=*name) return false; + + VertexAttribute result = base_attr; + + if(i!=str.end() && *i=='_') + { + if(*(++i)++!='I') + return false; + result = static_cast(result|8); + } + if(i==str.end() || *i<'0'+min_size || *i>'0'+max_size) return false; - VertexAttribute result = static_cast(base_attr+(*i++-'0'-min_size)); + result = static_cast(result+(*i++-'0'-min_size)); while(i!=str.end()) {