-void combine_two_samples(float w1, float w2, float *offset, float *total_weight, float *sum_sq_error)
+string output_glsl_vec2(const string &name, float x, float y)
+{
+ // Use stringstream to be independent of the current locale in a thread-safe manner.
+ stringstream ss;
+ ss.imbue(locale("C"));
+ ss.precision(8);
+ ss << "const vec2 " << name << " = vec2(" << x << ", " << y << ");\n";
+ return ss.str();
+}
+
+string output_glsl_vec3(const string &name, float x, float y, float z)
+{
+ // Use stringstream to be independent of the current locale in a thread-safe manner.
+ stringstream ss;
+ ss.imbue(locale("C"));
+ ss.precision(8);
+ ss << "const vec3 " << name << " = vec3(" << x << ", " << y << ", " << z << ");\n";
+ return ss.str();
+}
+
+template<class DestFloat>
+void combine_two_samples(float w1, float w2, float pos1, float pos2, unsigned size,
+ DestFloat *offset, DestFloat *total_weight, float *sum_sq_error)