Legacy OpenGL

From OpenGL Wiki
Revision as of 16:49, 5 September 2012 by Thokra (talk | contribs) (Rewording of introduction. Add section with information about who implements GL_ARB_compatibility. Restructuring. Reword and expand certain sections. Fix typos.)
Jump to navigation Jump to search

In 2008, version 3.0 of the OpenGL specification was released. With this revision, the Fixed Function Pipeline as well as most of the related OpenGL functions and constants were declared deprecated. These deprecated elements and concepts are now commonly referred to as legacy OpenGL. Legacy OpenGL is still supported by certain implementations that support core OpenGL 3.1 or higher and the GL_ARB_compatibility extension. Implementations that do not expose this extension do only offer features defined in the core OpenGL specification the implementation is based upon.

Note: There is a distinction between the above extension and the corresponding profile which was introduced with OpenGL 3.2.

Which hardware vendors implement the compatibility extension?

Both AMD and NVIDIA provide backwards-compatible implementations at least on Windows and Linux. Apple does only provide an implementation of the core profile and supports core OpenGL 3.2 on Mac OSX. Intel provides an implementation for Windows up to OpenGL 3.1 with Sandy Bridge CPUs and OpenGL 4.0 with Ivy Bridge CPUs. However, Intel's Linux open-source driver developers have recently stated that they will not provide backward-compatibility on Linux.

How do I recognize deprecated functionality?

One typical sign is immediate mode vertex attribute specification starting with a call to glBegin() ending with a call to glEnd(). This concept is based on a procedural method, where vertex attributes are provided vertex by vertex and attribute by attribute. For instance

  • setting the object-space position with glVertex*()
  • setting the vertex color with glColor*()
  • setting the direction of the normal at that vertex with glNormal*()

Another very common example is the use of the matrix stack and matrix manipulation commands. For example:

glRotatef(90.0, 0.0, 1.0, 0.0);
glTranslatef(0.0, 0.0, -5.0);

A problem is that very many tutorials on internet are based on the immediate mode. And these tutorials usually do not warn about the legacy status, much because they were created before the OpenGL version update. Because of that, many beginners start out with it without knowing or understanding the consequences.

Good general tutorials learning the new technique are Learning Modern 3D Graphics Programming and http://www.opengl-tutorial.org/.

What has been deprecated?

A comprehensive list of all functionality removed from OpenGL can be found in Appendix E of the OpenGL 3.0 specification.

At first, it may look like a lot of effort to do something that was simple in immediate mode. And it is more effort, but as soon as you have got it working it is easy to expand. An application based on the immediate mode can require significant effort to adapt.

  • You have to create the shader program yourself. Minimum is a vertex shader and one fragment shader.
  • All vertex data must be stored in one or more Buffer Objects.
  • You have to create at least one Vertex Array Object to store the states of your geometry.
  • You can no longer use glMatrixMode or the other pre defined matrix functions. Instead, you manage the matrices yourself, and deliver them to the shader program using uniforms. There are good external libraries for this.
  • The GL_QUAD and related Primitives are not available, nor is GL_POLYGON.

Why not use legacy OpenGL?

Much of the functionality that was promoted to core OpenGL 3.0 was available as extensions before the specification was released. However, most of the features already moved away from legacy concepts like immediate mode vertex attribute specification and offered advantages in one or more of the following fields.


  • Vertex data can be transferred once to the GPU, and rendered many times. That can improve FPS when the amount of data is big.

Flexibility using shaders

  • Sooner or later, real 3D projects come to a point where something more complicated needs to be done. At that point, the flexibility with the free data format of VBOs and the possibility to compute the results using flexible shader programs, will enable efficient design.


  • OpenGL ES 2 doesn't support immediate mode. If the application is supposed to portable or compatible with mobile devices, the legacy options is not available.

Using the most recent OpenGL version

Remember: OpenGL is not a library, it is a specification. Like TCP/IP isn't a library; TCP and IP simply define communication protocols, which libraries can implement.

You should always use the latest driver version. But OpenGL versions correspond in part to hardware facilities. The major version numbers for OpenGL generally represent tiers of hardware. For example, OpenGL 3.x is roughly equivalent to Direct3D 10-level hardware. OpenGL 4.x is roughly equivalent to Direct3D 11-level hardware.

So to use OpenGL 4.x features (hardware-based features that is. There are several features of 4.x that are available in 3.x hardware as extensions) means to confine your program to only running on 4.x hardware.

GL 3.x hardware is widely available these days, though 4.x hardware has been around for several years now and will only become more widely available. Which you choose is up to you and your needs.