tags:

views:

174

answers:

2

I've been looking for an OpenGL book lately and noticed that the OpenGL programming guide (2010) is deprecated. What's so different about OpenGL 3.x from 2.x?

+2  A: 

Many things, actually. Immediate mode is deprecated. To get OpenGL 3.0 functions, you now should create OpenGL 3.0 context explicitly (existing OpenGL 2.0 programs won't do that, so they get 2.0-compatible context). API has been expanded as well (see http://www.opengl.org for details).

alxx
the idea was to remove all the old functions that don't match the hardware anymore. This was a big change (even if everybody expected even more) so NeHe's tutorial are kinda outdated now.
Calvin1602
+9  A: 

Edit: Major changes, and some better arguments which has eluded many, including myself for a long time. Also more to the point and shorter.

Prior to OpenGL 3.0, there was no way to choose a specific OpenGL version. You always got the highest version supported by your driver and graphics adapter's capabilities. This meant that new core functionality had to be compatible with the old functionality from the previous versions, or else old applications would break when running on a later OpenGL version. The side effect from not being able to perform changes to previous versions was that OpenGL slowly started to suffer from feature creep. Functionality was added instead of enhancing what already existed. If you look at OpenGL 2.1, then the sheer number of different draw calls is a good example.

The new context creation call introduced in OpenGL 3.0 finally lets you choose a specific OpenGL version for your context, and also if you want to use deprecated functionality or not. This means that OpenGL can finally modify old core functionality, and that implies more than "just removing functions" which I've seen some people use as a counter-argument for the changes. It also means changing semantics of functions without removing them. An example is to make glGen.. functions mandatory for generation of object names, and making shaders and vertex array objects mandatory. (The latter is deprecated in OpenGL 3.3, not enforced).

With this possible now, 14 years of creep and bad design decisions could finally be remedied. What made sense when OpenGL 1.1 was introduced in 1996 doesn't necessarily make sense now in 2010. Old functions which aren't optimal on today's hardware were removed, and some were removed to make the API more general. An example of this is the removal of the gl..Pointer calls like glVertexPointer, in favor of glVertexAttribPointer. OpenGL 3.x finally doesn't label your shader data as "this" and "that"; you decide. Modifications to existing functionality was also done, so they differ in semantics from previous versions. Shaders was made mandatory by removing the default shader program 0, which used to represent "shaders disabled / use fixed functionality". Since the draw calls like glDrawElements return GL_INVALID_OPERATION when an invalid shader program is bound, you are effectively forced to make a shader first.

But everything can't be changed overnight, so OpenGL 3.x introduced a deprecation model. Functionality is deprecated for at least one version before it is removed in later versions. Removed functionality was moved into an OpenGL extension called GL_ARB_compatibility. You can switch on this functionality by making a compatibility profile, as opposed to a core profile. This is a flag in the new context creation call, which is accepted from OpenGL 3.1 and later (not in 3.0). Deprecated functionality can be enforced off by making a forward-compatible context. Again, this is a context creation flag.

So all in all, OpenGL 3.x is a first step to be able to choose specific OpenGL versions, and break compatibility with previous versions in order to enhance the API; both in usability and to reflect the hardware in the time we're in.

Mads Elvheim
Bahbar
Thanks for the thorough reply! In your opinion, is there a good book to learn OpenGL 3.0? I tried OpenGL superbible 5, but it abstracts too much in my opinion. I feel like I was learning gltools, not OpenGL.
Steve Melvin
I'd jump straight to OpenGL 3.3 or 4.x, depending on the features of the graphics card. Learning outdated versions is kind of useless. And skip the deprecated features / the GL_ARB_compatibility extension. OpenGL 4.1 is made 100% compatible with the latest OpenGL ES version too.
Mads Elvheim