Skip to content

Commit

Permalink
Add protection in Instanced_Markup_Mesh::update_instancing_buffers()
Browse files Browse the repository at this point in the history
If balls is empty, don't run glBufferSubData().
  • Loading branch information
pemsley committed Jan 7, 2025
1 parent 990078d commit 10f9720
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Instanced-Markup-Mesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,10 @@ Instanced_Markup_Mesh::update_instancing_buffers(const std::vector<Instanced_Mar
if (n_instances > max_n_instances)
n_instances = max_n_instances;

glBindBuffer(GL_ARRAY_BUFFER, inst_attribs_buffer_id);
glBufferSubData(GL_ARRAY_BUFFER, 0, n_instances * sizeof(Instanced_Markup_Mesh_attrib_t), &(balls[0]));
if (n_instances > 0) {
glBindBuffer(GL_ARRAY_BUFFER, inst_attribs_buffer_id);
glBufferSubData(GL_ARRAY_BUFFER, 0, n_instances * sizeof(Instanced_Markup_Mesh_attrib_t), &(balls[0]));
}

}

Expand Down

0 comments on commit 10f9720

Please sign in to comment.