现在的位置: 首页 > 综合 > 正文

EGL interface

2014年11月19日 ⁄ 综合 ⁄ 共 2863字 ⁄ 字号 评论关闭

 Step 1 - Get the default display.
EGL


uses the concept of a "display" which in most environments
corresponds to a single physical screen. Since we usually want
to draw to the main screen or only have a single screen to begin
with, we let EGL pick the default display.
Querying other displays is platform. specific.
======================
GLAPI EGLDisplay APIENTRY eglGetDisplay (NativeDisplayType display);

Step 2 - Initialize EGL.
EGL has to be initialized with the display obtained in the
previous step. We cannot use other EGL functions except
eglGetDisplay and eglGetError before eglInitialize has been
called.
If we're not interested in the EGL version number we can just
pass NULL for the second and third parameters.
======================
GLAPI EGLBoolean APIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor);

Step 3 - Specify the required configuration attributes.
An EGL "configuration" describes the pixel format and type of
surfaces that can be used for drawing.
For now we just want to use a 16 bit RGB surface that is a
Window surface, i.e. it will be visible on screen. The list
has to contain key/value pairs, terminated with EGL_NONE.
======================
GLAPI EGLBoolean APIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint
*attrib_list, EGLConfig *configs, EGLint config_size, EGLint
*num_config);

Step 5 - Create a surface to draw to.
Use the config picked in the previous step and the native window
handle when available to create a window surface. A window surface
is one that will be visible on screen inside the native display (or
fullscreen if there is no windowing system).
Pixmaps and pbuffers are surfaces which only exist in off-screen
memory.
======================
GLAPI EGLSurface APIENTRY eglCreateWindowSurface (EGLDisplay dpy,
EGLConfig config, NativeWindowType window, const EGLint *attrib_list);

Step 6 - Create a context.
EGL has to create a context for OpenGL ES. Our OpenGL ES resources
like textures will only be valid inside this context
(or shared contexts)
======================
GLAPI EGLContext APIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);

Step 7 - Bind the context to the current thread and use our
window surface for drawing and reading.
Contexts are bound to a thread. This means you don't have to
worry about other threads and processes interfering with your
OpenGL ES application.
We need to specify a surface that will be the target of all
subsequent drawing operations, and one that will be the source
of read operations. They can be the same surface.
======================
GLAPI EGLBoolean APIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);

Step 8 - Draw something with OpenGL ES.
At this point everything is initialized and we're ready to use
OpenGL ES to draw something on the screen.
======================
OpenGL ES API

Step 9 - Terminate OpenGL ES and destroy the window (if present).
eglTerminate takes care of destroying any context or surface created
with this display, so we don't need to call eglDestroySurface or
eglDestroyContext here.
======================
GLAPI EGLBoolean APIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);

Step 10 - Destroy the eglWindow.
Again, this is platform. specific and delegated to a separate function.

抱歉!评论已关闭.