From b7c8f8111e86be48eb440358d13e677ccc29cf19 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 3 Jun 2009 15:22:42 +0100 Subject: [PATCH] [cogl-material] Allow setting a layer with an invalid texture handle It was previously possible to create a material layer with no texture by setting some property on it such as the matrix. However it was not possible to get back to that state without removing the layer and recreating it. It is useful to be able to remove the texture to free resources without forgetting the state of the layer so we can put a different texture in later. --- common/cogl-material.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/cogl-material.c b/common/cogl-material.c index 85f9f343b..f3e7bb417 100644 --- a/common/cogl-material.c +++ b/common/cogl-material.c @@ -671,7 +671,8 @@ cogl_material_set_layer (CoglHandle material_handle, int n_layers; g_return_if_fail (cogl_is_material (material_handle)); - g_return_if_fail (cogl_is_texture (texture_handle)); + g_return_if_fail (texture_handle == COGL_INVALID_HANDLE + || cogl_is_texture (texture_handle)); material = _cogl_material_pointer_from_handle (material_handle); layer = _cogl_material_get_layer (material_handle, layer_index, TRUE); @@ -692,7 +693,8 @@ cogl_material_set_layer (CoglHandle material_handle, * MAX_COMBINED_TEXTURE_IMAGE_UNITS layers. */ } - cogl_handle_ref (texture_handle); + if (texture_handle) + cogl_handle_ref (texture_handle); if (layer->texture) cogl_handle_unref (layer->texture);