-#include <algorithm>
-#include <msp/io/print.h>
#include <msp/strings/format.h>
-#include <msp/strings/lexicalcast.h>
-#include <msp/strings/utils.h>
#include "error.h"
#include "vertexformat.h"
namespace Msp {
namespace GL {
-VertexFormat::VertexFormat():
- count(0)
-{ }
-
VertexFormat::VertexFormat(VertexAttribute a):
count(1)
{
throw invalid_operation("VertexFormat::operator,");
VertexFormat r = *this;
- uint16_t &a = r.attributes[r.count-1];
- a = make_typed_attribute(static_cast<VertexAttribute>(a), t);
+ VertexAttribute &a = r.attributes[r.count-1];
+ a = make_typed_attribute(a, t);
return r;
}
throw invalid_operation("VertexFormat::operator,");
VertexFormat r = *this;
- uint16_t &a = r.attributes[r.count-1];
- a = make_indexed_attribute(static_cast<VertexAttribute>(a), i);
+ VertexAttribute &a = r.attributes[r.count-1];
+ a = make_indexed_attribute(a, i);
return r;
}
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;
}
{
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;
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<VertexAttribute>(base&0x3FF);
else if(get_attribute_semantic(attr)!=get_attribute_semantic(GENERIC1))
throw invalid_argument("make_indexed_attribute");
convert_attribute(str, "GROUP", 1, 4, a, GROUP1) ||
convert_attribute(str, "WEIGHT", 1, 4, a, WEIGHT1) ||
convert_attribute(str, "TEXCOORD", 1, 4, a, TEXCOORD1) ||
- convert_attribute(str, "GENERIC", 1, 4, a, GENERIC1))
+ convert_attribute(str, "GENERIC", 1, 4, a, GENERIC1) ||
+ convert_attribute(str, "PADDING", 1, 4, a, PADDING1))
return;
}
catch(...)