Which Version Am I Using? (OpenGL Programming)

The portability of OpenGL applications is one of OpenGL’s attractive features. However, new versions of OpenGL introduce new features, and if you use new features, you may have problems running your code on older versions of OpenGL. In addition, you may want your application to perform equally well on a variety of implementations. For example, you might make texture mapping the default rendering mode on one machine, but have only flat shading on another. You can use glGetStringO to obtain release information about your OpenGL implementation.

const GLubyte* gIGetString(GLenum name);

Returns a pointer to a string that describes an aspect of the OpenGL implementation, name can be one of the following: GL_VENDOR„ * GI _RENDERER, GL_VERSION, or GL_EXTENSIONS.

GL_VENDOR returns the name of the company responsible for the OpenGL implementation. GL_RENDERER returns an identifier of the renderer, which is usually the hardware platform. For more about GL_EXTENSIONS, see the section "Extensions to the Standard.”

GL_VERSION returns a string that identifies the version number of your implementation of OpenGL. The version string is laid out as follows:

tmp73ec-48_thumb


The version number is of the form

tmp73ec-49_thumb

where the numbers all have one or more digits. The vendor-specific information is optional. For example, if this OpenGL implementation is from the fictitious XYZ Corporation, the string returned might be

tmp73ec-50_thumb

which means that this implementation is XYZ’s fourth release of an OpenGL library that conforms to the specification for OpenGL Version 1.2. It probably also means that this is release 3.2 of XYZ’s proprietary operating system.

Another way to query the OpenGL version number is to use the preprocessor statement #ifdef to look for the symbolic constants named GL_VERSION_ 1_4, GL_VERSION_l_3, GL_VERSION_l_2, and GL_VERSION_l_l. The absence of the constant GL_VERSION_l_2 means that you have OpenGL Version 1.0 or 1.1. The absence of the constant GL_VERSION_l_l means that you have OpenGL Version 1.0.

Note: If running from client to server, such as when performing indirect rendering with the OpenGL extension to the X Window System, the client and server may be different versions. If your client version is ahead of your server, your client might request an operation that is not supported on your server.

Utility Library Version

gluGetStringO is a query function for the Utility Library (GLU) and is similar to glGetString().

const GLubyte* gluGetString(GLenum name);

Returns a pointer to a string that describes an aspect of the OpenGL implementation, name can be GLU_VERSION or GLU_EXTENS!ONS.

Note that gluGetString() was not available in GLU 1.0. Another way to query the GLU version number is to look for the symbolic constant GLU_ VERSION_l_3. The absence of the constant GLU_VERSION_l_3 means that you have GLU 1.2 or an earlier version. The same principle is true for constants GLU_VERSION_l_l and GLU_VERSION_l_2.

Also note that GLU extensions are different from OpenGL extensions. Window System Extension Versions

For window system extensions for OpenGL, such as GLX, WGL, PGL, and AGL, there are similar routines (such as glXQueryExtensionStringO) for querying version information.

(The aforementioned glXQueryExtensionStringO and related routines were introduced with GLX 1.1 and are not supported with GLX 1.0.)

Next post:

Previous post: