Difference between revisions of "Legacy OpenGL"

From OpenGL.org
Jump to: navigation, search
(Shouldn't I use the latest, which would be OpenGL 4.x?: Added section)
(Modifications and formatting.)
Line 1: Line 1:
In 2008, OpenGL version 3.0 was released.
+
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 [[Deprecation|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 [[Core_And_Compatibility_in_Contexts|the core profile]]), and you can probably count on it being available. But there are some disadvantages that should be considered.
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.
 
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.
+
== How do I know what is what ==
And these tutorials usually do not warn about the legacy status, much because they were created before the OpenGL version update.
+
A typical sign of the immediate mode is the use of {{code|glBegin()}} and {{code|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 {{code|glVertex}}, {{code|glColor}}, {{code|glNormal}}, etc.
Because of that, many beginners start out with it without knowing or understanding the consequences.
+
 
 +
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 [http://www.arcsynthesis.org/gltut/ Learning Modern 3D Graphics Programming] and http://www.opengl-tutorial.org/.
 
Good general tutorials learning the new technique are [http://www.arcsynthesis.org/gltut/ Learning Modern 3D Graphics Programming] and http://www.opengl-tutorial.org/.
  
=What are the advantages of OpenGL3?=
+
== Why not use immediate mode ==
 +
 
 
Much of this was available before OpenGL3, but not for immediate mode.
 
Much of this was available before OpenGL3, but not for immediate mode.
==Performance==
+
 
 +
=== Performance ===
 +
 
 
* Vertex data can transfered once to the GPU, and rendered many times. That can improve FPS when the amount of data is big.
 
* 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==
+
 
 +
=== 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.
 
* 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.
==Compatibility==
+
 
 +
=== Compatibility ===
 +
 
 
* 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.
 
* 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?=
+
== 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.
+
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.
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.
 
* 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]]).
 
* The vertex data is defined in one or more VBO:s ([[Vertex Buffer Object]]).
Line 33: Line 35:
 
* 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.
 
* 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.
 
* 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.
+
== Using the most recent OpenGL 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.
+
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.
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.
+
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 [[OpenGL_Extensions#Targeting_OpenGL_3.3|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.

Revision as of 18:39, 30 August 2012

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.

Performance

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

Compatibility

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

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.