From: Steinar H. Gunderson Date: Sat, 12 Dec 2015 11:27:21 +0000 (+0100) Subject: Add a hack to use #version 110 but keep using 130 features, for the benefit of OS X. X-Git-Tag: 1.3.0~18 X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=e0811ddf51aeb50575fb5f7d9c6e32b92a6bac0d Add a hack to use #version 110 but keep using 130 features, for the benefit of OS X. --- diff --git a/init.cpp b/init.cpp index ed8172d..7781ba2 100644 --- a/init.cpp +++ b/init.cpp @@ -433,7 +433,14 @@ bool init_movit(const string& data_directory, MovitDebugLevel debug_level) if (get_glsl_version() < 1.30f) { fprintf(stderr, "Movit system requirements: Needs at least GLSL version 1.30 (has version %.1f)\n", get_glsl_version()); - return false; + if (get_glsl_version() >= 1.10f) { + fprintf(stderr, "Attempting to continue nevertheless; expect shader compilation issues.\n"); + fprintf(stderr, "Try switching to a core OpenGL context, as especially OS X drivers\n"); + fprintf(stderr, "support newer GLSL versions there.\n"); + movit_shader_model = MOVIT_GLSL_130_AS_110; + } else { + return false; + } } if (get_glsl_version() < 1.50f) { movit_shader_model = MOVIT_GLSL_130; diff --git a/init.h b/init.h index 7e1e130..89e3ef7 100644 --- a/init.h +++ b/init.h @@ -73,7 +73,7 @@ extern bool movit_timer_queries_supported; // What shader model we are compiling for. This only affects the choice // of a few files (like header.frag); most of the shaders are the same. enum MovitShaderModel { - MOVIT_GLSL_110, // No longer in use, but kept until next ABI break in order not to change the enums. + MOVIT_GLSL_130_AS_110, // Use 1.30 features freely, but use #version 110. MOVIT_GLSL_130, MOVIT_ESSL_300, MOVIT_GLSL_150, diff --git a/util.cpp b/util.cpp index d500399..675b25b 100644 --- a/util.cpp +++ b/util.cpp @@ -127,7 +127,12 @@ string read_file(const string &filename) string read_version_dependent_file(const string &base, const string &extension) { - if (movit_shader_model == MOVIT_GLSL_130) { + 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); diff --git a/version.h b/version.h index d8b2239..1d6ab91 100644 --- a/version.h +++ b/version.h @@ -5,6 +5,6 @@ // changes, even within git versions. There is no specific version // documentation outside the regular changelogs, though. -#define MOVIT_VERSION 13 +#define MOVIT_VERSION 14 #endif // !defined(_MOVIT_VERSION_H)