From 72efb2325bcac4ba2bfc243fe4766357681868a5 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 17 Oct 2014 13:36:54 +0300 Subject: [PATCH 1/1] Add facilities to disable extensions and force lower versions Useful for testing some exotic combinations without actually having to dig up suitable hardware. --- source/extension.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/source/extension.cpp b/source/extension.cpp index d0361665..fdbefb53 100644 --- a/source/extension.cpp +++ b/source/extension.cpp @@ -85,6 +85,13 @@ bool is_supported(const string &ext) buffer. */ extensions.erase("GL_NV_primitive_restart"); + if(const char *disable_ptr = getenv("MSPGL_DISABLE_EXTENSIONS")) + { + vector disable = split(disable_ptr); + for(vector::const_iterator i=disable.begin(); i!=disable.end(); ++i) + extensions.erase(*i); + } + init_done = true; } @@ -94,7 +101,16 @@ bool is_supported(const string &ext) inline Version _get_gl_version() { string gl_ver = reinterpret_cast(glGetString(GL_VERSION)); - return Version(gl_ver.substr(0, gl_ver.find(' '))); + Version ver(gl_ver.substr(0, gl_ver.find(' '))); + + if(const char *force_ver_ptr = getenv("MSPGL_FORCE_VERSION")) + { + Version force_ver(force_ver_ptr); + if(!(force_ver>=ver)) + ver = force_ver; + } + + return ver; } const Version &get_gl_version() @@ -106,7 +122,16 @@ const Version &get_gl_version() inline Version _get_glsl_version() { string glsl_ver = reinterpret_cast(glGetString(GL_SHADING_LANGUAGE_VERSION)); - return Version(glsl_ver.substr(0, glsl_ver.find(' '))); + Version ver(glsl_ver.substr(0, glsl_ver.find(' '))); + + if(const char *force_ver_ptr = getenv("MSPGL_FORCE_GLSL_VERSION")) + { + Version force_ver(force_ver_ptr); + if(!(force_ver>=ver)) + ver = force_ver; + } + + return ver; } const Version &get_glsl_version() -- 2.45.2