X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fvertexformat.cpp;h=ff043f7d0466bef73b08e216836617ef8fe9200f;hp=9bfca5d295ad9688303d575434999700a368240e;hb=38712d8ecc57d043a2419ffbaeeb57f7a6586f14;hpb=3a1b9cbe2441ae670a97541dc8ccb0a2860c8302 diff --git a/source/core/vertexformat.cpp b/source/core/vertexformat.cpp index 9bfca5d2..ff043f7d 100644 --- a/source/core/vertexformat.cpp +++ b/source/core/vertexformat.cpp @@ -1,8 +1,4 @@ -#include -#include #include -#include -#include #include "error.h" #include "vertexformat.h" @@ -11,10 +7,6 @@ using namespace std; namespace Msp { namespace GL { -VertexFormat::VertexFormat(): - count(0) -{ } - VertexFormat::VertexFormat(VertexAttribute a): count(1) { @@ -38,8 +30,8 @@ VertexFormat VertexFormat::operator,(DataType t) const throw invalid_operation("VertexFormat::operator,"); VertexFormat r = *this; - uint16_t &a = r.attributes[r.count-1]; - a = make_typed_attribute(static_cast(a), t); + VertexAttribute &a = r.attributes[r.count-1]; + a = make_typed_attribute(a, t); return r; } @@ -50,8 +42,8 @@ VertexFormat VertexFormat::operator,(unsigned i) const throw invalid_operation("VertexFormat::operator,"); VertexFormat r = *this; - uint16_t &a = r.attributes[r.count-1]; - a = make_indexed_attribute(static_cast(a), i); + VertexAttribute &a = r.attributes[r.count-1]; + a = make_indexed_attribute(a, i); return r; } @@ -66,8 +58,8 @@ bool VertexFormat::operator==(const VertexFormat &other) const unsigned VertexFormat::stride() const { unsigned s = 0; - for(const uint16_t *i=begin(); i!=end(); ++i) - s += get_attribute_size(*i); + for(VertexAttribute a: *this) + s += get_attribute_size(a); return s; } @@ -75,18 +67,18 @@ int VertexFormat::offset(VertexAttribute attr) const { unsigned sem = get_attribute_semantic(attr); unsigned offs = 0; - for(const uint16_t *i=begin(); i!=end(); ++i) + for(VertexAttribute a: *this) { - if(get_attribute_semantic(*i)==sem) + if(get_attribute_semantic(a)==sem) { - if(get_attribute_source_type(*i)==get_attribute_source_type(attr) && - get_attribute_component_count(*i)>=get_attribute_component_count(attr)) + if(get_attribute_source_type(a)==get_attribute_source_type(attr) && + get_attribute_component_count(a)>=get_attribute_component_count(attr)) return offs; else return -1; } else - offs += get_attribute_size(*i); + offs += get_attribute_size(a); } return -1; @@ -105,14 +97,14 @@ VertexAttribute make_typed_attribute(VertexAttribute attr, DataType type) VertexAttribute make_indexed_attribute(VertexAttribute attr, unsigned index) { - unsigned base = attr; + VertexAttribute base = attr; if(get_attribute_semantic(attr)==get_attribute_semantic(TEXCOORD1)) { if(index>=4) throw out_of_range("make_indexed_attribute"); } else if(get_attribute_semantic(attr)==get_attribute_semantic(RAW_ATTRIB1)) - base &= 0x3FF; + base = static_cast(base&0x3FF); else if(get_attribute_semantic(attr)!=get_attribute_semantic(GENERIC1)) throw invalid_argument("make_indexed_attribute");