]> git.tdb.fi Git - libs/gl.git/commitdiff
Disallow drawing batches without an index buffer
authorMikko Rasa <tdb@tdb.fi>
Mon, 25 Jan 2021 23:41:16 +0000 (01:41 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 25 Jan 2021 23:41:16 +0000 (01:41 +0200)
source/batch.cpp

index 64187eedb123aff7bdcef7d41fb5d67f8327f44b..f14cc307ff71b92deb212e9f759ac70f1c8d69f0 100644 (file)
@@ -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<const void *>(get_offset());
-       }
-       else
-               return &data[0];
+       return reinterpret_cast<const void *>(get_offset());
 }
 
 void Batch::set_restart_index(unsigned index)