namespace Msp {
namespace GL {
+VertexArray::VertexArray():
+ stride(0)
+{ }
+
VertexArray::VertexArray(const VertexFormat &f)
{
- reset(f);
+ set_format(f);
}
-void VertexArray::reset(const VertexFormat &f)
+void VertexArray::set_format(const VertexFormat &f)
{
- clear();
+ if(!format.empty())
+ throw invalid_operation("VertexArray::set_format");
format = f;
stride = format.stride();
}
void VertexArray::reserve(unsigned n)
{
+ if(format.empty())
+ throw invalid_operation("VertexArray::reserve");
data.reserve(n*stride);
}
float *VertexArray::append()
{
+ if(format.empty())
+ throw invalid_operation("VertexArray::append");
data.insert(data.end(), stride, 0.0f);
update_offset();
dirty = true;
float *VertexArray::modify(unsigned i)
{
+ if(format.empty())
+ throw invalid_operation("VertexArray::modify");
dirty = true;
return &data[0]+i*stride;
}