summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2009-06-03 15:22:42 +0100
committerNeil Roberts <neil@linux.intel.com>2009-06-04 14:04:32 +0100
commitb7c8f8111e86be48eb440358d13e677ccc29cf19 (patch)
treee94cb5e3655c55851ef2274515dc3d9d99ea91b3
parent8909d6a1298fb756f98bd22a870ee4091bb6414a (diff)
downloadcogl-b7c8f8111e86be48eb440358d13e677ccc29cf19.tar.gz
[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.
-rw-r--r--common/cogl-material.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/common/cogl-material.c b/common/cogl-material.c
index 85f9f343..f3e7bb41 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);