From: Mikko Rasa Date: Sat, 3 Apr 2021 18:55:58 +0000 (+0300) Subject: Do an early return from Mesh::draw if there's no data X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=db349c75a9563d38afaf1a8a602d9ee1155d62bb;p=libs%2Fgl.git Do an early return from Mesh::draw if there's no data Otherwise if would try to set zero-sized storage for the buffers, which is not allowed. Also guard against empty batches in resize_buffers just in case. --- diff --git a/source/core/mesh.cpp b/source/core/mesh.cpp index 3a79f3e5..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; }