+ throw UnsupportedExtension(ext);
+}
+
+const Version &get_gl_version()
+{
+ static Version version;
+ static bool init_done = false;
+
+ if(!init_done)
+ {
+ string gl_ver = reinterpret_cast<const char *>(glGetString(GL_VERSION));
+ vector<string> parts = split(gl_ver.substr(0, gl_ver.find(' ')), '.');
+ version.major = lexical_cast<unsigned>(parts[0]);
+ version.minor = lexical_cast<unsigned>(parts[1]);
+
+ unsigned combined = version.major*0x100+version.minor;
+ if(combined>=0x102)
+ init_version_1_2();
+ if(combined>=0x103)
+ init_version_1_3();
+
+ init_done = true;
+ }
+
+ return version;
+}
+
+bool is_version_at_least(unsigned a, unsigned b)
+{
+ const Version &ver = get_gl_version();
+ return (ver.major>a || (ver.major==a && ver.minor>=b));
+}
+
+void require_version(unsigned a, unsigned b)
+{
+ if(!is_version_at_least(a, b))
+ throw UnsupportedExtension(format("OpenGL %d.%d", a, b));