3 #include <msp/strings/lexicalcast.h>
4 #include <msp/strings/utils.h>
19 Version::Version(unsigned short a, unsigned short i)
25 Version::Version(const string &s)
27 vector<string> parts = split(s, '.');
28 major = lexical_cast<unsigned>(parts[0]);
29 minor = lexical_cast<unsigned>(parts[1]);
32 bool Version::operator>=(const Version &other) const
34 return major>other.major || (major==other.major && minor>=other.minor);
38 GraphicsApi get_backend_api()
40 #ifdef GL_ES_VERSION_2_0
47 inline Version get_gl_version()
49 const char *gl_ver_ptr = reinterpret_cast<const char *>(glGetString(GL_VERSION));
51 throw runtime_error("OpenGL version not available");
53 string gl_ver = gl_ver_ptr;
54 if(!gl_ver.compare(0, 10, "OpenGL ES "))
57 Version ver(gl_ver.substr(0, gl_ver.find(' ')));
59 if(const char *force_ver_ptr = getenv("MSPGL_FORCE_VERSION"))
61 Version force_ver(force_ver_ptr);
69 const Version &get_backend_version()
71 static Version version = get_gl_version();