]> git.tdb.fi Git - libs/gl.git/commitdiff
Add facilities to disable extensions and force lower versions
authorMikko Rasa <tdb@tdb.fi>
Fri, 17 Oct 2014 10:36:54 +0000 (13:36 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 17 Oct 2014 10:36:54 +0000 (13:36 +0300)
Useful for testing some exotic combinations without actually having to
dig up suitable hardware.

source/extension.cpp

index d03616651b39e97c7937c9f9902d7108c11f7b89..fdbefb5336407e402ba0985985804ba4d527c241 100644 (file)
@@ -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<string> disable = split(disable_ptr);
+                       for(vector<string>::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<const char *>(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<const char *>(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()