/// <summary> /// Builds a cache of the supported extensions to speed up searches. /// </summary> private static void BuildExtensionList() { // Assumes there is an opengl context current. AvailableExtensions.Clear(); string version_string = GL.GetString(StringName.Version); if (String.IsNullOrEmpty(version_string)) { throw new ApplicationException("Failed to build extension list. Is there an opengl context current?"); } string version; // Most drivers return the version in the 3 first characters of the version string, // (e.g. on Ati X1950 with Catalyst 7.10 -> "2.0.6956 Release"). However, Mesa seems // to do something strange: "1.4 (2.1 Mesa 7.0.1).". // Update: this seems to occur with indirect rendering. E.g. Ati 8.2: 1.4 (2.1.7281 ...) // We'll do some trickery to get the second number (2.1), but this may break on // some implementations... //if (version_string.ToLower().Contains("mesa")) { int index = version_string.IndexOf('('); if (index != -1) { version = version_string.Substring(index + 1, 3); } else { version = version_string.TrimStart(' '); } } //else // version = version_string.TrimStart(' '); if (version.StartsWith("1.1")) { AvailableExtensions.Add("glversion11", true); } else if (version.StartsWith("1.2")) { AvailableExtensions.Add("glversion11", true); AvailableExtensions.Add("glversion12", true); } else if (version.StartsWith("1.3")) { AvailableExtensions.Add("glversion11", true); AvailableExtensions.Add("glversion12", true); AvailableExtensions.Add("glversion13", true); } else if (version.StartsWith("1.4")) { AvailableExtensions.Add("glversion11", true); AvailableExtensions.Add("glversion12", true); AvailableExtensions.Add("glversion13", true); AvailableExtensions.Add("glversion14", true); } else if (version.StartsWith("1.5")) { AvailableExtensions.Add("glversion11", true); AvailableExtensions.Add("glversion12", true); AvailableExtensions.Add("glversion13", true); AvailableExtensions.Add("glversion14", true); AvailableExtensions.Add("glversion15", true); } else if (version.StartsWith("2.0")) { AvailableExtensions.Add("glversion11", true); AvailableExtensions.Add("glversion12", true); AvailableExtensions.Add("glversion13", true); AvailableExtensions.Add("glversion14", true); AvailableExtensions.Add("glversion15", true); AvailableExtensions.Add("glversion20", true); } else if (version.StartsWith("2.1")) { AvailableExtensions.Add("glversion11", true); AvailableExtensions.Add("glversion12", true); AvailableExtensions.Add("glversion13", true); AvailableExtensions.Add("glversion14", true); AvailableExtensions.Add("glversion15", true); AvailableExtensions.Add("glversion20", true); AvailableExtensions.Add("glversion21", true); } else if (version.StartsWith("3.0")) { AvailableExtensions.Add("glversion11", true); AvailableExtensions.Add("glversion12", true); AvailableExtensions.Add("glversion13", true); AvailableExtensions.Add("glversion14", true); AvailableExtensions.Add("glversion15", true); AvailableExtensions.Add("glversion20", true); AvailableExtensions.Add("glversion21", true); AvailableExtensions.Add("glversion30", true); } else if (version.StartsWith("3.1")) { AvailableExtensions.Add("glversion11", true); AvailableExtensions.Add("glversion12", true); AvailableExtensions.Add("glversion13", true); AvailableExtensions.Add("glversion14", true); AvailableExtensions.Add("glversion15", true); AvailableExtensions.Add("glversion20", true); AvailableExtensions.Add("glversion21", true); AvailableExtensions.Add("glversion30", true); AvailableExtensions.Add("glversion31", true); } string extension_string = GL.GetString(StringName.Extensions); if (String.IsNullOrEmpty(extension_string)) { return; // no extensions are available } string[] extensions = extension_string.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string ext in extensions) { AvailableExtensions.Add(ext.Replace("_", String.Empty).ToLower(), true); } rebuildExtensionList = false; }