material-arbfp: Use locale-independent double to string conversion
authorEmmanuele Bassi <ebassi@linux.intel.com>
Fri, 16 Jul 2010 22:37:59 +0000 (23:37 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Fri, 16 Jul 2010 22:40:34 +0000 (23:40 +0100)
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

clutter/cogl/cogl/cogl-material-arbfp.c

index 21b0d7a..1eb6c68 100644 (file)
@@ -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: