]> git.tdb.fi Git - libs/gl.git/commitdiff
Do an early return from Mesh::draw if there's no data
authorMikko Rasa <tdb@tdb.fi>
Sat, 3 Apr 2021 18:55:58 +0000 (21:55 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 3 Apr 2021 18:55:58 +0000 (21:55 +0300)
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.

source/core/mesh.cpp

index 3a79f3e53193c0c1c63cb32bde351926c2cb4a63..d3fd7360f756680ef198c44916b9fe71ed7042ac 100644 (file)
@@ -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;
 }