X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fvertexarray.cpp;h=2bb6a6677b9ef5e2099a1a5922b1d2990910708c;hp=347e42595a1387bf7630a87344a6dc96f7425ac3;hb=d40673bd28c4b4524d3642b949d9d109dc6f9f24;hpb=11266e8093e56524a68de1d0a08d275de95c56a0 diff --git a/source/core/vertexarray.cpp b/source/core/vertexarray.cpp index 347e4259..2bb6a667 100644 --- a/source/core/vertexarray.cpp +++ b/source/core/vertexarray.cpp @@ -11,14 +11,19 @@ using namespace std; 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(); } @@ -30,11 +35,15 @@ void VertexArray::clear() 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; @@ -43,6 +52,8 @@ float *VertexArray::append() float *VertexArray::modify(unsigned i) { + if(format.empty()) + throw invalid_operation("VertexArray::modify"); dirty = true; return &data[0]+i*stride; }