From: Mikko Rasa Date: Mon, 25 Jan 2021 23:41:16 +0000 (+0200) Subject: Disallow drawing batches without an index buffer X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=d5790b342a54e6fbf4d3a443edad1505db0a3614 Disallow drawing batches without an index buffer --- diff --git a/source/batch.cpp b/source/batch.cpp index 64187eed..f14cc307 100644 --- a/source/batch.cpp +++ b/source/batch.cpp @@ -204,6 +204,9 @@ void Batch::draw_instanced(unsigned count) const const void *Batch::setup_draw() const { + if(!get_buffer()) + throw invalid_operation("Batch::setup_draw"); + if(restart) { unsigned index = (index_type==UNSIGNED_INT ? 0xFFFFFFFF : 0xFFFF); @@ -214,14 +217,9 @@ const void *Batch::setup_draw() const else if(restart_index && restart_index<=max_index) set_restart_index(0); - if(get_buffer()) - { - refresh(); + refresh(); - return reinterpret_cast(get_offset()); - } - else - return &data[0]; + return reinterpret_cast(get_offset()); } void Batch::set_restart_index(unsigned index)