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.
Implementations of compatibility contexts
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.
Detecting legacy OpenGL
Although by no means exhaustive, the following examples are common in most legacy OpenGL applications.
One typical sign that code is using Legacy OpenGL 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*()
Other regularly employed facilities are the matrix stack and matrix manipulation commands:
glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(90.0, 0.0, 1.0, 0.0); glTranslatef(0.0, 0.0, -5.0);
Fixed-Function lighting is found in most legacy applications as well. For that purpose, command such as
- glLight*() for setting certain parameters of a specific light source
- glLightModel() for determining the shading algorithm
- glMaterial() for setting material properties that influence said shading algorithm
are used to coarsely approximate real-world lighting with either flat shading or Gouraud shading.
A comprehensive list of all functionality removed from core OpenGL 3.1 and higher can be found in Appendix E of the OpenGL 3.0 specification. The following enumeration shows some important areas that are affected by removal.
- Fixed-function vertex and fragment processing. These stages of the rendering pipeline are now the developers responsibility and can be fully programmed using shaders.
- Immediate-mode vertex attribute specification, client-side vertex arrays. Vertex attributes must be stored in one or more Buffer Objects or be specified explicitly using glVertexAttrib*(). Since OpenGL 3.2 using Vertex Array Objects is mandatory.
- The GL_QUAD and GL_POLYGON primitive types.
- The matrix stack and related matrix manipulation functions. This includes projection, model-view and texture matrices. Corresponding built-in GLSL functions have also been removed. Managing matrices and sending data to shaders is now the developers responsibility. See this page for libraries designed for that purpose.
- Fixed-function lighting, materials and color materials, fixed-function shadow mapping and bump mapping. Everything possible with functions corresponding to these areas can easily be emulated with shaders.
- Accumulation and auxiliary buffers. If additional buffers are needed framebuffer objects can be used.
- Versions 1.10 and 1.20 of the GLSL.
Reasons to avoid 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.