From: Mikko Rasa Date: Fri, 17 Oct 2014 10:36:54 +0000 (+0300) Subject: Add facilities to disable extensions and force lower versions X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=72efb2325bcac4ba2bfc243fe4766357681868a5;p=libs%2Fgl.git Add facilities to disable extensions and force lower versions Useful for testing some exotic combinations without actually having to dig up suitable hardware. --- 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()