-
Notifications
You must be signed in to change notification settings - Fork 107
GL \ Version and extensions query
Normally, OpenGL applications requires an OpenGL version and uses quite a few extensions to achieve better performances. However, to get this information, the application is required to create a (temporary) OpenGL context in order to execute the necessary methods for retrieving the information.
OpenGL.Net retrieves all information automatically, letting the user to execute all methods without worrying OpenGL version, extensions and limits.
The Gl.CurrentExtensions specifies the currently supported extensions; its type is Gl.Extensions, which defines for every OpenGL extension the support for the current OpenGL implementation.
Using Gl.CurrentExtensions can be fast and easy, but there is a problem: the current OpenGL context implementation may support a different set of extensions respect to the ones defined by Gl.CurrentExtensions. To overcome this issue, users can instantiate their instance of Gl.Extensions, and query and cache available extensions once an OpenGL context is made current, by calling the Gl.Extensions.Query() method.
The Gl.CurrentVersion and Gl.CurrentShadingVersion defines the OpenGL version and the OpenGL Shading Language version. Their type is KhronosVersion, indeed compare operators are supported for testing OpenGL versions; in conjunction with the Gl.Version_ constants, you can write if (Gl.Version >= Gl.Version_200) { ... }.
However, the current OpenGL context version can be different from Gl.CurrentVersion. To overcome this issue, you can parse the OpenGL context version calling KhronoVersion.Parse with the string returned by Gl.GetString(Gl.Version).
Even Wgl, Glx and Egl classes have their own Extensions type and Current* properties. However, those platform APIs version and extensions are not dependent on the current OpenGL context. Indeed the extension can be directly accesses from the CurrentVersion and CurrentExtensions properties.