eglCreateContext — create a new EGL rendering context

C Specification

EGLContext eglCreateContext( EGLDisplay display,
  EGLConfig config,
  EGLContext share_context,
  EGLint const * attrib_list);



Specifies the EGL display connection.


Specifies the EGL frame buffer configuration that defines the frame buffer resource available to the rendering context.


Specifies another EGL rendering context with which to share data, as defined by the client API corresponding to the contexts. Data is also shared with all other contexts with which share_context shares data. EGL_NO_CONTEXT indicates that no sharing is to take place.


Specifies attributes and attribute values for the context being created. Only the attribute EGL_CONTEXT_CLIENT_VERSION may be specified.


eglCreateContext creates an EGL rendering context for the current rendering API (as set with eglBindAPI) and returns a handle to the context. The context can then be used to render into an EGL drawing surface. If eglCreateContext fails to create a rendering context, EGL_NO_CONTEXT is returned.

If share_context is not EGL_NO_CONTEXT, then all shareable data in the context (as defined by the client API specification for the current rendering API) are shared by context share_context, all other contexts share_context already shares with, and the newly created context. An arbitrary number of rendering contexts can share data. However, all rendering contexts that share data must themselves exist in the same address space. Two rendering contexts share an address space if both are owned by a single process.

attrib_list specifies a list of attributes for the context. The list has the same structure as described for eglChooseConfig. The attributes and attribute values which may be specified are as follows:


Must be followed by an integer that determines which version of an OpenGL ES context to create. A value of 1 specifies creation of an OpenGL ES 1.x context. An attribute value of 2 specifies creation of an OpenGL ES 2.x context. The default value is 1. This attribute can only be specified when creating a OpenGL ES context (e.g. when the current rendering API is EGL_OPENGL_ES_API).


The current rendering API is only respected if the EGL version is 1.2 or greater. Otherwise, an OpenGL ES context will always be created.

The EGL_CONTEXT_CLIENT_VERSION attribute is only supported if the EGL version is 1.3 or greater.

A process is a single execution environment, implemented in a single address space, consisting of one or more threads.

A thread is one of a set of subprocesses that share a single address space, but maintain separate program counters, stack spaces, and other related global data. A thread is the only member of its subprocess group is equivalent to a process.


EGL_NO_CONTEXT is returned if creation of the context fails.

EGL_BAD_MATCH is generated if the current rendering API is EGL_NONE (this can only arise in an EGL implementation which does not support OpenGL ES, prior to the first call to eglBindAPI).

EGL_BAD_MATCH is generated if the server context state for share_context exists in an address space which cannot be shared with the newly created context, if share_context was created on a different display than the one referenced by config, or if the contexts are otherwise incompatible.

EGL_BAD_DISPLAY is generated if display is not an EGL display connection.

EGL_NOT_INITIALIZED is generated if display has not been initialized.

EGL_BAD_CONFIG is generated if config is not an EGL frame buffer configuration, or does not support the current rendering API. This includes requesting creation of an OpenGL ES 1.x context when the EGL_RENDERABLE_TYPE attribute of config does not contain EGL_OPENGL_ES_BIT, or creation of an OpenGL ES 2.x context when the attribute does not contain EGL_OPENGL_ES2_BIT.

EGL_BAD_CONTEXT is generated if share_context is not an EGL rendering context of the same client API type as the newly created context and is not EGL_NO_CONTEXT.

EGL_BAD_ATTRIBUTE is generated if attrib_list contains an invalid context attribute or if an attribute is not recognized or out of range. Note that attribute EGL_CONTEXT_CLIENT_VERSION is only valid when the current rendering API is EGL_OPENGL_ES_API.

EGL_BAD_ALLOC is generated if there are not enough resources to allocate the new context.