What's so different about OpenGL 3.x?

后端 未结 2 2059
無奈伤痛
無奈伤痛 2020-12-29 09:12

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条回答
  • 2020-12-29 09:21

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

    0 讨论(0)
  • 2020-12-29 09:32

    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 were also made, so they differ in semantics from previous versions. Shaders were 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.

    0 讨论(0)
提交回复
热议问题