From bc187dc31e18c008103b20deaf7283d07c1711bb Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Mon, 13 Sep 2010 21:21:09 +0100 Subject: [PATCH] material: Adds _get_layer_combine_constant API This adds an internal _cogl_material_get_layer_combine_constant function so we can query the current layer combine constant back. We should probably make this a public property getter, but for now we just need this so we can read the constant in the arbfp backend. --- cogl/cogl-material-private.h | 5 +++++ cogl/cogl-material.c | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/cogl/cogl-material-private.h b/cogl/cogl-material-private.h index 448367725..ca260c2ee 100644 --- a/cogl/cogl-material-private.h +++ b/cogl/cogl-material-private.h @@ -913,5 +913,10 @@ _cogl_material_foreach_layer (CoglMaterial *material, int _cogl_material_layer_get_unit_index (CoglMaterialLayer *layer); +void +_cogl_material_get_layer_combine_constant (CoglMaterial *material, + int layer_index, + float *constant); + #endif /* __COGL_MATERIAL_PRIVATE_H */ diff --git a/cogl/cogl-material.c b/cogl/cogl-material.c index 435d02d2e..734865784 100644 --- a/cogl/cogl-material.c +++ b/cogl/cogl-material.c @@ -4875,6 +4875,32 @@ changed: handle_automatic_blend_enable (material, COGL_MATERIAL_STATE_LAYERS); } +void +_cogl_material_get_layer_combine_constant (CoglMaterial *material, + int layer_index, + float *constant) +{ + CoglMaterialLayerState change = + COGL_MATERIAL_LAYER_STATE_COMBINE_CONSTANT; + CoglMaterialLayer *layer; + CoglMaterialLayer *authority; + + g_return_if_fail (cogl_is_material (material)); + + /* Note: this will ensure that the layer exists, creating one if it + * doesn't already. + * + * Note: If the layer already existed it's possibly owned by another + * material. If the layer is created then it will be owned by + * material. */ + layer = _cogl_material_get_layer (material, layer_index); + /* FIXME: we shouldn't ever construct a layer in a getter function */ + + authority = _cogl_material_layer_get_authority (layer, change); + memcpy (constant, authority->big_state->texture_combine_constant, + sizeof (float) * 4); +} + void cogl_material_set_layer_matrix (CoglMaterial *material, int layer_index,