+ unsigned gl_version_major = opts.gl_version_major;
+ unsigned gl_version_minor = opts.gl_version_minor;
+ if(opts.gl_version_major==GLOptions::LATEST_VERSION)
+ {
+ ContextHandle probe_context = glXCreateNewContext(dpy, fb_configs[0], GLX_RGBA_TYPE, 0, true);
+ glXMakeContextCurrent(dpy, priv->glxwnd, priv->glxwnd, probe_context);
+
+ const char *gl_ver_ptr = reinterpret_cast<const char *>(glGetString(GL_VERSION));
+ if(!gl_ver_ptr)
+ throw unsupported_gl_mode(opts);
+
+ string gl_ver = gl_ver_ptr;
+ vector<string> parts = split(gl_ver.substr(0, gl_ver.find(' ')), '.');
+
+ gl_version_major = lexical_cast<unsigned>(parts[0]);
+ gl_version_minor = lexical_cast<unsigned>(parts[1]);
+
+ glXMakeContextCurrent(dpy, 0, 0, 0);
+ glXDestroyContext(dpy, probe_context);
+ }
+