Graphics Reference
In-Depth Information
To associate a particular
EGLContext
with an
EGLSurface
, use the call
EGLBoolean
eglMakeCurrent
(EGLDisplay
display
,
EGLSurface
draw
,
EGLSurface
read
,
EGLContext
context
)
display
specifies the EGL display connection
draw
specifies the EGL draw surface
read
specifies the EGL read surface
context
specifies the EGL rendering context to be attached to the
surfaces
This function returns
EGL_TRUE
if the call succeeded. On failure, it returns
EGL_FALSE
.
You probably noticed that this call takes two
EGLSurface
s. Although
this approach allows flexibility that we will exploit in our discussion of
advanced EGL usage, we set both read and draw to the same value, the
window that we created previously.
Note:
Because the EGL specification requires a flush for
eglMakeCurrent
implementation, this call is expensive for tile-based architectures.
This chapter concludes with a complete example showing the entire
process starting with the initialization of the EGL through binding an
EGLContext
to an
EGLSurface
. We will assume that a native window has
already been created, and that if any errors occur, the application will
terminate.
In fact, Example 3-7 is similar to what is done in
esCreateWindow
, our
homegrown function that wraps the required EGL window creation code,
as shown in Chapter 2, “Hello Triangle: An OpenGL ES 3.0 Example,”
except for those routines that separate the creation of the window and the
context (for reasons that we discuss later).