EGL_KHR_create_context#

Supported Hardware#

Series5, Series5XT, Series6, Series6XE, Series6XT

Valid APIs#

EGL 1.4

Description#

This extension enables a number of new context attributes to be specified in EGL to allow greater control of the returned context. The new functionality consists of four aspects; version control, core vs compatibility layer control for OpenGL, debugging (see extension GL_KHR_debug), and robustness in OpenGL (see desktop extension “GL_ARB_robustness”). This extension mirrors the desktop WGL_ARB_create_context and GLX_ARB_create_context extensions and provides similar functionality through EGL.

Version Control#

This part of the extension enables developers to explicitly create a context with a given level of API support. An explicitly defined EGL_OPENGL_ES3_BIT is provided to query the new API via the original mechanism to make sure a compatible context is available, and then this extension allows developers to explicitly state which version of OpenGL ES they are actually going to be using. The two additional attributes to specify this are EGL_CONTEXT_MAJOR_VERSION_KHR (which is an alias for EGL_CONTEXT_CLIENT_VERSION) and EGL_CONTEXT_MINOR_VERSION_KHR. Each then accepts an integer value specifying what version you require.

OpenGL Core vs Compatibility#

EGL_OPENGL_PROFILE_MASK_KHR allows a developer to specify EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR or EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR to explicitly choose a core or compatibility context when using the OpenGL client API.

There is also a bit that can be set for EGL_CONTEXT_FLAGS_KHR which tells the implementation to return only OpenGL contexts which do not support functionality marked as deprecated by any version of OpenGL after OpenGL 3.0. Further information on this is available in the OpenGL specification.

Debug Contexts#

When the GL_KHR_debug extension exists in a client OpenGL/ES API, this bit flag tells the implementation to enable debug functionality for that API. This is necessary to inform the underlying implementation that debug information should be tracked. This bit should only be set for purposes of debugging, and not in shipping code.

OpenGL Robustness#

When setting EGL_CONTEXT_FLAGS_KHR, the EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR bit is provided to allow a user to require buffer access to remain robust as defined in the GL_ARB_robustness extension.

Various problems in either hardware or software can occasionally cause a hardware reset in a GPU. Unlike a CPU, these can typically be recovered from without having to restart the device - though setting up the underlying context again is usually a necessity. Setting EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR to either EGL_NO_RESET_NOTIFICATION_KHR or EGL_LOSE_CONTEXT_ON_RESET_KHR will set the behaviour to either notify the user or ignore it, as defined by GL_ARB_robustness using GL_NO_RESET_NOTIFICATION_ARB and GL_LOSE_CONTEXT_ON_RESET_ARB respectively.

Note

This only affects OpenGL contexts, not OpenGL ES contexts, which are handled by EGL_KHR_create_context_robustness.

Note#

This functionality is core to EGL 1.5, so the extension is no longer needed.

Example#

// Set up the config attributes, specifying that we want a config with Window support and ES3
// compatibility.
EGLint configAttribs[] =
{
    EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
    EGL_RENDERABLE_TYPE , EGL_OPENGL_ES3_BIT_KHR,
    EGL_NONE
};
// Choose an appropriate configuration - just get the first available one that matches here
EGLint iConfigs;
EGLConfig eglConfig;
eglChooseConfig(eglDisplay, configAttribs, &eglConfig, 1, &iConfigs);
// Set up the context attributes, specifying OpenGL ES 3.0 support and a debug context.
EGLint contextAttribs[] =
{
    EGL_CONTEXT_MAJOR_CLIENT_VERSION, 3,
    EGL_CONTEXT_MINOR_CLIENT_VERSION, 0,
    EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR,
    EGL_NONE
};
// Create the context with the context attributes supplied
eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, contextAttribs);