Core And Compatibility in Contexts

From OpenGL Wiki
Jump to navigation Jump to search

OpenGL version 3.0 introduced the idea of deprecation; some sections of the specification could be marked as deprecated. This means that they can be removed from the core specification in later versions, which happened in version 3.1.

However, since many implementations support the deprecated and removed features anyway, some implementations want to be able to provide a way for users of higher GL versions to gain access to the old APIs. Several techniques were tried, and it has settled down into a division between Core and Compatibility

OpenGL 3.1 and ARB_compatibility

A new extension, ARB_compatibility, was introduced when OpenGL 3.1 was revealed. The presence of this extension is a signal to the user that deprecated or removed features are still available through the original entrypoints and enumerations. The behavior of such implementations is defined with a separate, much larger, OpenGL Specification. Thus, there was a backwards-compatible specification and a non-backwards compatible specification.

OpenGL 3.2 and Profiles

When OpenGL 3.0 was introduced, a new context creation mechanism was introduced as well. Since later versions could remove functionality, it was important that the user be able to ask for a specific version of OpenGL, one that they had written their code against.

However, the ARB_compatibility extension posed a problem: the implementation decided whether to define it or not. A user could not ask to not have ARB_compatibility; it was forced on them. This also meant that the core specification had to be a subset of the compatibility specification; the core specification couldn't provide functionality that the compatibility one did not provide.

Thus, another change was made to context creation.

The 3.0 form of context creation allows the user to ask for a profile. Initially, only one profile was available: core. In 3.2, a new profile was added: compatibility. An implementation is only required to define core, so compatibility is not guaranteed to be available. However, it's a safe bet that it is.

The 3.2 wording also changed, allowing 3.0 and higher contexts to be given when not directly asked, so long as they support ARB_compatibility or are the compatibility profile of that version of OpenGL. So if you ask for 2.1, the implementation is free to give you 3.2 compatibility; it was not previously free to do this.

Because of the change in wording, the way to detect the changed functionality is to check the extension string. If WGL_ARB_create_context_profile is present, then it uses the 3.2 wording. Otherwise it uses the 3.0/3.1 wording.