From 76d8119a7fcdbd64566d8ef16f73e50b0ae28c7f Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Sat, 17 Jul 2010 12:40:19 +0100 Subject: [PATCH] cogl-material-arbfp: Use separate buffers when calling g_ascii_dtostr g_ascii_dtostr was being used in four separate arguments to g_string_append_printf but all invocations of it were using the same buffer. This would end up with all of the arguments having the same value which would depend on whichever order the compiler evaluates them in. This patches changes it to use a multi-dimensional array and a loop to fill in the separate buffers. http://bugzilla.clutter-project.org/show_bug.cgi?id=2219 --- clutter/cogl/cogl/cogl-material-arbfp.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/clutter/cogl/cogl/cogl-material-arbfp.c b/clutter/cogl/cogl/cogl-material-arbfp.c index 1eb6c68..50297f0 100644 --- a/clutter/cogl/cogl/cogl-material-arbfp.c +++ b/clutter/cogl/cogl/cogl-material-arbfp.c @@ -525,24 +525,25 @@ setup_arg (CoglMaterial *material, CoglMaterialLayer *authority = _cogl_material_layer_get_authority (layer, state); CoglMaterialLayerBigState *big_state = authority->big_state; - char buf[G_ASCII_DTOSTR_BUF_SIZE]; + char buf[4][G_ASCII_DTOSTR_BUF_SIZE]; + int i; arg->type = COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_CONSTANT; arg->name = "constant%d"; arg->constant_id = priv->next_constant_id++; + for (i = 0; i < 4; i++) + g_ascii_dtostr (buf[i], G_ASCII_DTOSTR_BUF_SIZE, + big_state->texture_combine_constant[i]); + g_string_append_printf (priv->source, "PARAM constant%d = " " {%s, %s, %s, %s};\n", arg->constant_id, - g_ascii_dtostr (buf, sizeof (buf), - big_state->texture_combine_constant[0]), - g_ascii_dtostr (buf, sizeof (buf), - big_state->texture_combine_constant[1]), - g_ascii_dtostr (buf, sizeof (buf), - big_state->texture_combine_constant[2]), - g_ascii_dtostr (buf, sizeof (buf), - big_state->texture_combine_constant[3])); + buf[0], + buf[1], + buf[2], + buf[3]); break; } case GL_PRIMARY_COLOR: -- 2.7.4