From d5790b342a54e6fbf4d3a443edad1505db0a3614 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 26 Jan 2021 01:41:16 +0200 Subject: [PATCH] Disallow drawing batches without an index buffer --- source/batch.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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) -- 2.45.2