X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=util.cpp;h=675b25b4940c3d9a9048d3d4488220340b31817b;hp=da6057e52f13b4ad4af9ca82a4c83acab6d23388;hb=e0811ddf51aeb50575fb5f7d9c6e32b92a6bac0d;hpb=1bd97eb70a6fcb913bf954e369bc1a90ba17f74e diff --git a/util.cpp b/util.cpp index da6057e..675b25b 100644 --- a/util.cpp +++ b/util.cpp @@ -19,6 +19,7 @@ #include #else #include +#include #endif using namespace std; @@ -126,10 +127,15 @@ string read_file(const string &filename) string read_version_dependent_file(const string &base, const string &extension) { - if (movit_shader_model == MOVIT_GLSL_110) { - return read_file(base + "." + extension); + if (movit_shader_model == MOVIT_GLSL_130_AS_110) { + string contents = read_file(base + ".130." + extension); + assert(contents.find("#version 130") == 0); + contents[10] = '1'; // Change from 130 to 110. + return contents; } else if (movit_shader_model == MOVIT_GLSL_130) { return read_file(base + ".130." + extension); + } else if (movit_shader_model == MOVIT_GLSL_150) { + return read_file(base + ".150." + extension); } else if (movit_shader_model == MOVIT_ESSL_300) { return read_file(base + ".300es." + extension); } else { @@ -253,11 +259,11 @@ void combine_two_samples(float w1, float w2, float pos1, float pos2, float num_s // w = (a(1-z) + bz) / ((1-z)² + z²) // // If z had infinite precision, this would simply reduce to w = w1 + w2. - *total_weight = (w1 + z * (w2 - w1)) / (z * z + (1 - z) * (1 - z)); + *total_weight = from_fp64((w1 + z * (w2 - w1)) / (z * z + (1 - z) * (1 - z))); if (sum_sq_error != NULL) { - float err1 = *total_weight * (1 - z) - w1; - float err2 = *total_weight * z - w2; + float err1 = to_fp64(*total_weight) * (1 - z) - w1; + float err2 = to_fp64(*total_weight) * z - w2; *sum_sq_error = err1 * err1 + err2 * err2; } } @@ -333,6 +339,10 @@ void *get_gl_context_identifier() #elif defined(WIN32) return (void *)wglGetCurrentContext(); #else + void *ret = (void *)eglGetCurrentContext(); + if (ret != NULL) { + return ret; + } return (void *)glXGetCurrentContext(); #endif }