X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fvertexformat.cpp;h=02410857bff6e8873570055499b4be71800a6c02;hb=e06ee659c66c92065dbd767475ac9bf9f0f14846;hp=ed2b04b8dbd0784c2bf6bc67c7a10698000a8464;hpb=2e7f19b895424c3a77940e648639f8df2b395d0f;p=libs%2Fgl.git diff --git a/source/vertexformat.cpp b/source/vertexformat.cpp index ed2b04b8..02410857 100644 --- a/source/vertexformat.cpp +++ b/source/vertexformat.cpp @@ -54,7 +54,7 @@ unsigned VertexFormat::stride() const { unsigned s = 0; for(const unsigned char *i=begin(); i!=end(); ++i) - s += (*i&3)+1; + s += get_component_size(*i); return s; } @@ -63,20 +63,20 @@ int VertexFormat::offset(VertexComponent comp, unsigned index) const if((comp0) || (comp=8) || index>=53) throw out_of_range("VertexFormat::offset"); - unsigned type = (comp>>2)+index; - unsigned size = comp&3; + unsigned type = get_component_type(comp)+index; + unsigned size = get_component_size(comp); unsigned offs = 0; for(const unsigned char *i=begin(); i!=end(); ++i) { - if(static_cast(*i>>2)==type) + if(get_component_type(*i)==type) { - if((*i&3)>=size) + if(get_component_size(*i)>=size) return offs; else return -1; } else - offs += (*i&3)+1; + offs += get_component_size(*i); } return -1; @@ -114,7 +114,7 @@ VertexFormat operator,(const VertexFormat &f, unsigned i) VertexFormat r = f; unsigned char *c = r.data+r.data[0]; if((*c0) || (*c=8) || i>=53) - throw out_of_range("VertexFormat::operator,"); + throw invalid_argument("VertexFormat::operator,"); *c += i*4; return r;