From 62fa7b4e028db5364d033ec0b6b497df7bc67457 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 16 Jul 2010 23:37:59 +0100 Subject: [PATCH] material-arbfp: Use locale-independent double to string conversion The ARBfp programs are created with a printf() wrapper, which usually fails in non-en locales as soon as you start throwing things like floating point values in the mix. We should use the g_ascii_dtostr() function which places a double into a string buffer in a locale-independent way. http://bugzilla.clutter-project.org/show_bug.cgi?id=2219 --- cogl/cogl-material-arbfp.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cogl/cogl-material-arbfp.c b/cogl/cogl-material-arbfp.c index 21b0d7a34..1eb6c6846 100644 --- a/cogl/cogl-material-arbfp.c +++ b/cogl/cogl-material-arbfp.c @@ -525,18 +525,24 @@ 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]; arg->type = COGL_MATERIAL_BACKEND_ARBFP_ARG_TYPE_CONSTANT; arg->name = "constant%d"; arg->constant_id = priv->next_constant_id++; + g_string_append_printf (priv->source, "PARAM constant%d = " - " {%f, %f, %f, %f};\n", + " {%s, %s, %s, %s};\n", arg->constant_id, - big_state->texture_combine_constant[0], - big_state->texture_combine_constant[1], - big_state->texture_combine_constant[2], - big_state->texture_combine_constant[3]); + 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])); break; } case GL_PRIMARY_COLOR: