X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=util.cpp;h=e266fb813921e606abd95a374f0a5772c0fd1edb;hp=3ebf162d31a0558ddfb54d3a8520706035ee45e6;hb=9faecb6aed1b84c71286b30b6600ef5e4ee76537;hpb=0cea318493ae406e5fff6e10eb8d3e171603a0c0 diff --git a/util.cpp b/util.cpp index 3ebf162..e266fb8 100644 --- a/util.cpp +++ b/util.cpp @@ -156,6 +156,7 @@ GLuint compile_shader(const string &shader_src, GLenum type) GLint status; glGetShaderiv(obj, GL_COMPILE_STATUS, &status); if (status == GL_FALSE) { + fprintf(stderr, "Failed to compile shader: %s\n", shader_src.c_str()); exit(1); } @@ -176,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"; @@ -183,12 +185,24 @@ string output_glsl_mat3(const string &name, const Eigen::Matrix3d &m) return ss.str(); } +string output_glsl_float(const string &name, float x) +{ + // Use stringstream to be independent of the current locale in a thread-safe manner. + stringstream ss; + ss.imbue(locale("C")); + ss.precision(8); + ss << scientific; + ss << "const float " << name << " = " << x << ";\n"; + return ss.str(); +} + 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 << scientific; ss << "const vec2 " << name << " = vec2(" << x << ", " << y << ");\n"; return ss.str(); } @@ -199,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(); }