From: Steinar H. Gunderson Date: Thu, 30 Jul 2015 11:09:12 +0000 (+0200) Subject: Use std::scientific when outputting floats, so we do not get issues with 0.0 being... X-Git-Tag: 1.2.0~37 X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=457b9a7fa5a508084142dd97290fb590397069ff Use std::scientific when outputting floats, so we do not get issues with 0.0 being outputs as 0 (which is an int, which cannot always be implicitly converted to float in GLSL). --- diff --git a/util.cpp b/util.cpp index 0a294e6..e266fb8 100644 --- a/util.cpp +++ b/util.cpp @@ -177,6 +177,7 @@ string output_glsl_mat3(const string &name, const Eigen::Matrix3d &m) stringstream ss; ss.imbue(locale("C")); ss.precision(8); + ss << scientific; ss << "const mat3 " << name << " = mat3(\n"; ss << " " << m(0,0) << ", " << m(1,0) << ", " << m(2,0) << ",\n"; ss << " " << m(0,1) << ", " << m(1,1) << ", " << m(2,1) << ",\n"; @@ -190,6 +191,7 @@ string output_glsl_float(const string &name, float x) stringstream ss; ss.imbue(locale("C")); ss.precision(8); + ss << scientific; ss << "const float " << name << " = " << x << ";\n"; return ss.str(); } @@ -200,6 +202,7 @@ string output_glsl_vec2(const string &name, float x, float y) stringstream ss; ss.imbue(locale("C")); ss.precision(8); + ss << scientific; ss << "const vec2 " << name << " = vec2(" << x << ", " << y << ");\n"; return ss.str(); } @@ -210,6 +213,7 @@ string output_glsl_vec3(const string &name, float x, float y, float z) stringstream ss; ss.imbue(locale("C")); ss.precision(8); + ss << scientific; ss << "const vec3 " << name << " = vec3(" << x << ", " << y << ", " << z << ");\n"; return ss.str(); }