namespace Msp {
namespace GL {
+Version::Version()
+{
+ major = 0;
+ minor = 0;
+}
+
+Version::Version(unsigned short a, unsigned short i)
+{
+ major = a;
+ minor = i;
+}
+
+Version::Version(const string &s)
+{
+ vector<string> parts = split(s, '.');
+ major = lexical_cast<unsigned>(parts[0]);
+ minor = lexical_cast<unsigned>(parts[1]);
+}
+
+bool Version::operator>=(const Version &other) const
+{
+ return major>other.major || (major==other.major && minor>=other.minor);
+}
+
+
Extension::Extension(const char *n, InitFunc f):
name(n),
init_func(f),
return extensions.count(ext);
}
-const Version &get_gl_version()
+inline 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]);
-
- init_done = true;
- }
+ string gl_ver = reinterpret_cast<const char *>(glGetString(GL_VERSION));
+ return Version(gl_ver.substr(0, gl_ver.find(' ')));
+}
+const Version &get_gl_version()
+{
+ static Version version = _get_gl_version();
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));
+ return get_gl_version()>=Version(a, b);
}
ExtFunc *get_proc_address(const string &name)