X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fmesh.cpp;h=d3fd7360f756680ef198c44916b9fe71ed7042ac;hb=412996297a287c9e97a7207458877c0ab07cc8b6;hp=dba8a9915489aede7906f8a684b9d59e288428b5;hpb=7aaec9a70b8d7733429bec043f8e33e02956f266;p=libs%2Fgl.git diff --git a/source/core/mesh.cpp b/source/core/mesh.cpp index dba8a991..d3fd7360 100644 --- a/source/core/mesh.cpp +++ b/source/core/mesh.cpp @@ -155,6 +155,9 @@ void Mesh::draw(Renderer &renderer, const VertexSetup *vs, unsigned count) const return; } + if(batches.empty()) + return; + if(dirty) resize_buffers(); @@ -177,7 +180,7 @@ void Mesh::resize_buffers() const { if(dirty&VERTEX_BUFFER) vbuf->storage(vertices.get_required_buffer_size()); - if(dirty&INDEX_BUFFER) + if((dirty&INDEX_BUFFER) && !batches.empty()) ibuf->storage(batches.front().get_required_buffer_size()); dirty = 0; } @@ -218,13 +221,13 @@ Mesh::Loader::Loader(Mesh &m, bool g): add("winding", &Loader::winding); } -void Mesh::Loader::vertices(const vector &c) +void Mesh::Loader::vertices(const vector &a) { - if(c.empty()) - throw invalid_argument("No vertex components"); + if(a.empty()) + throw invalid_argument("No vertex attributes"); VertexFormat fmt; - for(vector::const_iterator i=c.begin(); i!=c.end(); ++i) + for(vector::const_iterator i=a.begin(); i!=a.end(); ++i) fmt = (fmt, *i); obj.vertices.reset(fmt); load_sub(obj.vertices);