Legacy OpenGL

From OpenGL Wiki
Jump to navigation Jump to search

In 2008, OpenGL version 3.0 was released. With this change, immediate mode with the Fixed Function Pipeline was no longer supported. The functionality has been deprecated and removed, and is sometimes referenced as "Legacy OpenGL". It is still supported (except for Mac OSX's 3.2 support, which only supports the core profile), and you can probably count on it being available. But there are some disadvantages that should be considered.

Learning immediate mode as a beginner has a limited value, as most real applications are based on at least OpenGL3.

How do I know what is what

A typical sign of the immediate mode is the use of glBegin() and glEnd(). Immediate mode is based on a procedural method, where the vertex attribute data is provided vertex by vertex, component by component, using calls to glVertex, glColor, glNormal, etc.

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/.

Why not use immediate mode

Much of this was available before OpenGL3, but not for immediate mode.


  • Vertex data can transfered 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.

What are the basic changes

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.

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.