Get Context Info
OpenGL version number
To get the OpenGL major and minor version numbers, you can call these functions:
glGetIntegerv(GL_MAJOR_VERSION, *); glGetIntegerv(GL_MINOR_VERSION, *);
These are available on OpenGL version 3.0 and above contexts. If those are not available, you can use this instead:
The string returned starts with "<major version>.<minor version>". Following the minor version, there can be another '.', then a vendor-specific build number. The string may have more content, which is completely vendor-specific (thus not a part of the OpenGL standard).
For example, the returned string may be like "2.0.6914 WinXP SSE/SSE2/SSE3/3DNow!". 2.0 is the actual version number of GL supported. 6914 is a driver build number. WinXP is the OS. SSE/SSE2/SSE3/3DNow! are CPU features that the driver can use.
Sometimes glGetString(GL_VERSION) also returns also the bus type used, such as AGP or PCI or PCIEx.
The OpenGL implementations have a vendor string associated with it that is used for identifying the maker of the implementation.
It could be "ATI Technologies", "NVIDIA Corporation", "INTEL" and so on. Note that there's no guarantee that the string for a specific vendor will remain the same in future implementations. On Windows, if it says "Microsoft" then you are using the Windows software renderer or the Windows Direct3D wrapper. You probably haven't installed the graphics drivers yet in that case.
This names the renderer used by the implementation.
This string is often the name of the GPU. In the case of Mesa, the software renderer, it would be "Mesa" or "MESA". It might even say "Direct3D" if the Windows Direct3D wrapper is being used.
Extensions can be queried one by one. To do this, first use glGetIntegerv(GL_NUM_EXTENSIONS, *) to get the number of extensions supported by the implementation. Then iterate over each one with this:
Where k is less than the GL_NUM_EXTENSIONS value.
Legacy extension list
|Warning: This section describes legacy OpenGL APIs that have been removed from core OpenGL 3.1 and above (they are only deprecated in OpenGL 3.0). It is recommended that you not use this functionality in your programs.|
A string containing a space-separated list of extension names can be queried as follows:
Shading language version
The primary version of GLSL supported by the implementation can be queried:
The version string has almost the same format as the context version string. The difference is that the minor version always has two digits.
Supported GLSL versions
|Core in version||4.5|
|Core since version||4.3|
Support for specific versions of GLSL can be queried via an indexed get. The number of supported GLSL versions is queried with glGetIntegerv(GL_NUM_SHADING_LANGUAGE_VERSIONS, *). Each individual version can be queried from an indexed string:
Where k is on the range 0 to GL_NUM_SHADING_LANGUAGE_VERSIONS - 1. The format of this string is exactly like that for the single GL_SHADING_LANGUAGE_VERSION.