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 is sometimes referenced as Legacy OpenGL. It is still supported, and you can probably count on it being available. But there are some serious 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 vertex data is defined by using 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/.

What are the advantages of OpenGL3?

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.
  • The vertex data is defined in one or more VBO:s (Vertex Buffer Object).
  • You have to create at least one VAO (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.
  • Your polygons can never have more than 3 vertices. That is, a triangle. Though GL_TRIANGLE_STRIP and similar are still supported.

Shouldn't I use the latest, which would be OpenGL 4.x?

The usual recommendation for libraries are to always get the latest version. OpenGL 4+ has some added advanced features compared to OpenGL 3. But if you don't know that you need them, you may as well wait. There is no big conceptual change when going from OpenGL 3 to OpenGL 4, as there was when going from version 2 to 3. One advantage of only using OpenGL 3 is that there are more old graphic cars supporting OpenGL 3 than OpenGL 4.