Gawain: Fix instancing messing next draw.

Everything was fine if one batch is always used with instancing. But problem arise if the next drawcall for this batch is not using instancing as the attrib divisor stays set to 1 in th VAO.

As instancing is less used than normal drawing I prefer to reset the divisor after drawing as it is reset before drawing instances.
This commit is contained in:
Clément Foucault 2017-10-11 02:14:15 +02:00
parent d46842108d
commit ef1918d312
1 changed files with 8 additions and 0 deletions

View File

@ -396,6 +396,10 @@ void GWN_batch_draw_stupid_instanced(Gwn_Batch* batch, unsigned int instance_vbo
else
glDrawArraysInstanced(batch->gl_prim_type, 0, batch->verts[0]->vertex_ct, instance_count);
// Reset divisor to prevent messing the next draw
for (unsigned a_idx = 0; a_idx < GWN_VERT_ATTR_MAX_LEN; ++a_idx)
glVertexAttribDivisor(a_idx, 0);
// GWN_batch_program_use_end(batch);
glBindVertexArray(0);
}
@ -466,6 +470,10 @@ void GWN_batch_draw_stupid_instanced_with_batch(Gwn_Batch* batch_instanced, Gwn_
else
glDrawArraysInstanced(batch_instanced->gl_prim_type, 0, batch_instanced->verts[0]->vertex_ct, verts->vertex_ct);
// Reset divisor to prevent messing the next draw
for (unsigned a_idx = 0; a_idx < GWN_VERT_ATTR_MAX_LEN; ++a_idx)
glVertexAttribDivisor(a_idx, 0);
// GWN_batch_program_use_end(batch);
glBindVertexArray(0);
}