Graphics Reference
In-Depth Information
reason that
eglCreateContext
would fail is if the
EGLConfig
we provide
is not valid, in which case the error returned by
eglGetError
is
EGL_BAD_
CONFIG
.
Example 3-6 shows how to create a context after selecting an appropriate
EGLConfig
.
Example 3-6
Creating an EGL Context
const EGLint attribList[] =
{
// EGL_KHR_create_context is required
EGL_CONTEXT_CLIENT_VERSION, 3,
EGL_NONE
};
EGLContext context = eglCreateContext ( display, config,
EGL_NO_CONTEXT,
attribList );
if ( context == EGL_NO_CONTEXT )
{
EGLError error = eglGetError ( );
if ( error == EGL_BAD_CONFIG )
{
// Handle error and recover
}
}
Other errors may be generated by
eglCreateContext
, but for the
moment we will check for only bad
EGLConfig
errors.
After successfully creating an
EGLContext
, we need to complete one final
step before we can render.
As an application might have created multiple
EGLContext
s for various
purposes, we need a way to associate a particular
EGLContext
with our
rendering surface—a process commonly called “make current.”