Difference between revisions of "Get Context Info"

From OpenGL.org
Jump to: navigation, search
(glGetString(GL_RENDERER): Spam deletion)
(Major upgrade)
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:glGetString}}
+
__TOC__
=== glGetString(GL_VERSION) ===
+
== OpenGL version number ==
The string  returned starts with <nowiki><major version>.<minor  version></nowiki>. 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 in case it runs in software  mode.
+
To get the OpenGL major and minor version numbers, you can call these functions:
  
Sometimes glGetString(GL_VERSION) also returns also the bus type used, such as AGP or PCI or PCIEx.
+
{{apifunc|glGetIntegerv}}({{enum|GL_MAJOR_VERSION}}, *);
 +
{{apifunc|glGetIntegerv}}({{enum|GL_MINOR_VERSION}}, *);
  
Alternatively, you can use glGetIntegerv(GL_MAJOR_VERSION, *) and glGetIntegerv(GL_MINOR_VERSION, *). These require GL 3.0 or greater.
+
These are available on OpenGL version 3.0 and above contexts. If those are not available, you can use this instead:
  
=== glGetString(GL_VENDOR) ===
+
{{apifunc|glGetString}}({{enum|GL_VERSION}});
This returns the company name of whoever wrote the GL driver. 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.
+
  
=== glGetString(GL_RENDERER) ===
+
The string returned starts with "<nowiki><major version>.<minor version></nowiki>". 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).
  
This returns the name of the renderer, which often is 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.
+
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.
  
=== glGetString(GL_EXTENSIONS) ===
+
Sometimes {{apifunc|glGetString|(GL_VERSION)}} also returns also the bus type used, such as AGP or PCI or PCIEx.
{{deprecated|alternate = glGetStringi(GL_EXTENSIONS, i)}}
+
This function was used to retrieve the list of extensions. This is a space-separated list of extension names. This was problematic because of poor parsing behavior. Some programs searched this string for the name of the extension. It is not the correct way to find if an extension is supported, as the name of an extension can be a substring of another extension name. For example, if the extension <code>GL_EXT_pixel_transform_color_table</code> is listed, doing a simple search for <code>GL_EXT_pixel_transform</code> will return a positive whether or not it is defined.
+
  
=== glGetStringi(GL_EXTENSIONS, i) ===
+
== Vendor string ==
  
This function retrieves the null-terminated string of the 'i'th extension. An implementation exposes a number of extensions equal to glGetInteger(GL_NUM_EXTENSIONS). The argument 'i' must be between 0 and this value - 1.
+
The OpenGL implementations have a vendor string associated with it that is used for identifying the maker of the implementation.
  
This entrypoint is supported only in GL 3.0 and above.
+
{{apifunc|glGetString}}({{enum|GL_VENDOR}});
  
Example:
+
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.
  int NumberOfExtensions;
+
 
  glGetIntegerv(GL_NUM_EXTENSIONS, &NumberOfExtensions);
+
== Renderer name ==
  for(i=0; i<NumberOfExtensions; i++)
+
 
  {
+
This names the renderer used by the implementation.
    const GLubyte *ccc=glGetStringi(GL_EXTENSIONS, i);
+
 
    //Now, do something with ccc
+
{{apifunc|glGetString}}({{enum|GL_RENDERER}});
  }
+
 
 +
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.
 +
 
 +
== Extension list ==
 +
 
 +
Extensions can be queried one by one. To do this, first use {{apifunc|glGetIntegerv|(GL_NUM_EXTENSIONS, *)}} to get the number of extensions supported by the implementation. Then iterate over each one with this:
 +
 
 +
{{apifunc|glGetString|i}}({{enum|GL_EXTENSIONS}}, k);
 +
 
 +
Where {{param|k}} is less than the {{enum|GL_NUM_EXTENSIONS}} value.
 +
 
 +
=== Legacy extension list ===
 +
{{deprecated|section=}}
 +
 
 +
A string containing a space-separated list of extension names can be queried as follows:
 +
 
 +
{{apifunc|glGetString}}({{enum|GL_EXTENSIONS}});
 +
 
 +
== Shading language version ==
 +
 
 +
The primary version of GLSL supported by the implementation can be queried:
 +
 
 +
{{apifunc|glGetString}}({{enum|GL_SHADING_LANGUAGE_VERSION​}});
 +
 
 +
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 ===
 +
{{infobox feature
 +
| name = Supported GLSL versions
 +
| core = 4.3
 +
}}
 +
 
 +
Support for specific versions of GLSL can be queried via an indexed get. The number of supported GLSL versions is queried with {{apifunc|glGetIntegerv|(GL_NUM_SHADING_LANGUAGE_VERSIONS, *)​}}. Each individual version can be queried from an indexed string:
 +
{{clear float}}
 +
{{apifunc|glGetString|i}}({{enum|GL_SHADING_LANGUAGE_VERSION​}}, k);
 +
 
 +
Where {{param|k}} is on the range 0 to {{enum|GL_NUM_SHADING_LANGUAGE_VERSIONS}} - 1. The format of this string is exactly like that for the single {{enum|GL_SHADING_LANGUAGE_VERSION}}.
  
 
[[Category:General OpenGL]]
 
[[Category:General OpenGL]]

Revision as of 00:37, 9 September 2012

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:

glGetString(GL_VERSION);

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.

Vendor string

The OpenGL implementations have a vendor string associated with it that is used for identifying the maker of the implementation.

glGetString(GL_VENDOR);

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.

Renderer name

This names the renderer used by the implementation.

glGetString(GL_RENDERER);

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.

Extension list

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:

glGetStringi(GL_EXTENSIONS, k);

Where k​ is less than the GL_NUM_EXTENSIONS value.

Legacy extension list

A string containing a space-separated list of extension names can be queried as follows:

glGetString(GL_EXTENSIONS);

Shading language version

The primary version of GLSL supported by the implementation can be queried:

glGetString(GL_SHADING_LANGUAGE_VERSION​);

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

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:

glGetStringi(GL_SHADING_LANGUAGE_VERSION​, k);

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.