cogl-material: Fix the check to prevent using too many layers

There was a check at the bottom of the loop which sets up the state
for each of the layers so that it would break from the loop when the
maximum number of layers is reached. However after doing this it would
not increment 'i'. 'i' is later used to disable the remaining layers
so it would end up disabling the last layer it just set up.

This patch moves the check to be part of the loop condition so that
the check is performed after incrementing 'i'.

http://bugzilla.openedhand.com/show_bug.cgi?id=2064
This commit is contained in:
Neil Roberts 2010-04-27 16:38:07 +01:00
parent 3c2bb33cbd
commit 8530b7946a

View File

@ -1469,8 +1469,10 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material,
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
for (tmp = material->layers, i = 0; tmp != NULL; tmp = tmp->next, i++)
{
for (tmp = material->layers, i = 0;
tmp != NULL && i < _cogl_get_max_texture_image_units ();
tmp = tmp->next, i++)
{
CoglHandle layer_handle = (CoglHandle)tmp->data;
CoglMaterialLayer *layer =
_cogl_material_layer_pointer_from_handle (layer_handle);
@ -1621,9 +1623,6 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material,
g_array_append_val (ctx->current_layers, new_gl_layer_info);
layer->flags &= ~COGL_MATERIAL_LAYER_FLAG_DIRTY;
if ((i+1) >= _cogl_get_max_texture_image_units ())
break;
}
/* Disable additional texture units that may have previously been in use.. */