I'd like to get into EGL. However, the "only" I've been able to find is the API reference. Searching for "egl guide", "egl tutorial" or "egl for beginners" hasn't succeeded. Does anyone know of a good resource?

EGL may not be a "library for beginners". In that case, I guess I should start from the beginning - but, what's the beginning? I just read that EGL is an abstraction layer over system-dependent drawing APIs, thus being the "correct" way to go. Wayland uses it, and so does kmscon. Looking into their source code, though, has only given me a headache.

P.S.: As a side note, I feel more comfortable with C++ (although I guess that, if it works on C, it should work too on C++). Also, I'm using the latest kernel, with the latest Mesa release, so I guess there's support available for EGL.

有帮助吗?

解决方案

To begin learning EGL, I recommend the following resources.

  • The OpenGL ES 3.0 Programming Guide from Addison-Wesley provides a good tutorial on using EGL with OpenGL ES, complete with example code on Github. The book's text provides an introduction to the parts of EGL that are independent of operating system. To cover the operating system specific parts, the book's example code provides a complete program that works on each major operating system. (Addison-Wesley is the publisher of many well-known OpenGL books, such as The Red Book and the OpenGL SuperBible).

    Dan Ginsburg, Budirijanto Purnomo, Dave Shreiner, Aaftab Munshi. OpenGL ES 3.0 Programming Guide, 2e, Chapter 3: An Introduction to EGL. Addison-Wesley, 2014. ISBN-13: 978-0-321-93388-1, ISBN-13: 978-0-13-344016-4.

  • As you're learning, keep by your side the official EGL 1.4 Quick Reference Card.

  • (Linux only) The example code in the EGL_EXT_platform_x11 extension specification demonstrates how to create an X11 window and produce an EGLSurface from that window. (The example programs from the OpenGL ES 3.0 Programming Guide also demonstrates how to do this, but you may find the more focused treatment in the EGL_EXT_platform_x11 specification easier to follow).

  • (Linux only) Likewise, the EGL_MESA_platform_gbm extension specification demonstrates how to do the same, but for GBM, a headless EGL backend supported by opensource Linux drivers.(The OpenGL ES 3.0 Programming Guide does not touch GBM).

Depending on your goals, you may also find useful the following low-level resources, all found in the Khronos EGL Registry.

其他提示

I am a bit surprised that the eglIntro has not been mentioned yet.
It is the closest I could find to a tutorial and was a really useful resource when learning EGL.

EDIT: I recently discovered a good EGL tutorial published by Addison-Wesley. See my new answer for the details. This answer is out-of-date, but should be preserved because it still contains useful information.

I am not aware of any EGL tutorials. The only documentation I know of is:

EGL 1.5 is a lowlevel system API for creating OpenGL and OpenGL ES contexts; connecting those contexts to the window system; and sharing graphics buffers and grapics events between applications, the window system, and other system components such as OpenCL, video decode engines, and camera hardware.

Considering EGL's target use cases and developer audience, I'm unsurprised that no tutorials exist.

If you are investigating how to accomplish some task with EGL, and you are using Linux with opensource OpenGL drivers, then you may find your answers by contacting the Mesa developers [http://mesa3d.org/lists.html].

I have found this tutorial for iOS and this for Windows.

Here's some sample code extracted from the latter for obtaining a display and configuring it with EGL:

// Obtain an EGL display object.
EGLDisplay display = eglGetDisplay(GetDC(hWnd));
if (display == EGL_NO_DISPLAY)
{
  return EGL_FALSE;
}

// Initialize the display
if (!eglInitialize(display, &majorVersion, &minorVersion))
{
  return EGL_FALSE;
}

// Obtain the display configs
if (!eglGetConfigs(display, NULL, 0, &numConfigs))
{
  return EGL_FALSE;
}

// Choose the display config
if (!eglChooseConfig(display, attribList, &config, 1, &numConfigs))
{
  return EGL_FALSE;
}

// Create a surface
surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)hWnd, NULL);
if (surface == EGL_NO_SURFACE)
{
  return EGL_FALSE;
}

// Create a drawing context from the EGLDisplay
context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs);
if (context == EGL_NO_CONTEXT)
{
    return EGL_FALSE;
}

// Make the context current
if (!eglMakeCurrent(display, surface, surface, context))
{
    return EGL_FALSE;
}

//to show your drawing you swap the buffers like this
eglSwapBuffers(drawContext->eglDisplay, drawContext->eglSurface);

//Terminating a display (release the window resources)
EGLBoolean eglTerminate(eglDisplay);

I do not know any tutorial to help you but I found this example useful for Android

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top