Question

EGL provides two ways to create EGL surfaces with native backing stores, eglCreateWindowSurface and egCreatePixmapSurface. Both create EGL surfaces which interact with the native graphics layer. (In contrast to pbuffer surfaces, which do not interact with the native graphics layer.)

What are pixmaps good for that windows are not? (I.e. why does EGL distinguish between the two types of surfaces?) I am having trouble understanding the difference.

Was it helpful?

Solution

EGL pixmaps are meant to mirror any pixmap-like concept supported by the underlying windowing system. The terminology comes from X11. The EGL spec says:

EGL defines several types of drawing surfaces collectively referred to as EGLSurfaces. These include windows, used for onscreen rendering; pbuffers, used for offscreen rendering; and pixmaps, used for offscreen rendering into buffers that may be accessed through native APIs. EGL windows and pixmaps are tied to native window system windows and pixmaps.

The main differences between pixmaps and windows are:

  • An EGL implementation doesn't need to support pixmaps (the native windowing system might not have an equivalent concept)
  • Pixmaps are typically single-buffered, whereas a window might be double- or triple-buffered.
  • Pixmaps are offscreen surfaces (although offscreen windows might be possible as well)

If the underlying windowing system doesn't support pixmaps, there's no real use for EGL pixmaps (and they probably won't be exposed by the EGL implementation). They're only provided so you can render to X11 pixmaps (or something similar) in case you need to do that for some reason.

One example might be: you want to render a 3D object using the GPU and then use it as an X11 cursor. In that case you might create a pixmap, create an EGL pixmap drawable, draw something, and then use XCreateCursorFromPixmap to turn your pixmap into a cursor (this is an example of the kind of "native API" the EGL spec is referring to). Examples more useful than this probably exist.

OTHER TIPS

Maybe this part from the egl specifications helps:

EGL also supports rendering surfaces whose color buffers are stored in native pixmaps. Pixmaps differ from windows in that they are typically allocated in off- screen (non-visible) graphics or CPU memory. Pixmaps differ from pbuffers in that they do have an associated native pixmap and native pixmap type, and it may be possible to render to pixmaps using APIs other than client APIs .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top