eglGetDisplay(EGL_DEFAULT_DISPLAY)
Pekka Paalanen
pekka.paalanen at haloniitty.fi
Tue Apr 30 14:39:44 UTC 2024
On Tue, 30 Apr 2024 09:58:32 -0300
Thiago Milczarek Sayão <thiago.sayao at gmail.com> wrote:
> Hi,
>
> I'm looking the docs at
> https://registry.khronos.org/EGL/sdk/docs/man/html/eglGetDisplay.xhtml
>
> But I'm still in doubt how it actually works, especially on Mesa.
>
> Will it detect which platform it's on if I pass EGL_DEFAULT_DISPLAY ? For
> example, if I want to use the same code for Wayland and X11.
I think Mesa EGL will first look at environment variable EGL_PLATFORM
for a hard-override of the chosen platform. Otherwise, it tries to
detect a platform from the native display passed in, which
EGL_DEFAULT_DISPLAY does not provide. Finally there is a build-time
chosen fallback.
eglGetDisplay itself is a bit problematic since it was not intended to
support choosing the platform at runtime (only at EGL implementation
build time). New code would be better using eglGetPlatformDisplay(EXT)
if at all possible, especially when you want it to work on multiple
platforms, or just to be safe that EGL does not guess wrong what kind
of native display you are passing in. Guessing it wrong would cause
nonsensical errors or crashes. This is also why using EGL_PLATFORM
environment variable is not a good idea.
FWIW, on Wayland, EGL_DEFAULT_DISPLAY will not allow you to render into
a window. It would open a new Wayland connection, but your application
windows are created through a connection you made yourself, so EGL
would not be able to target your windows. Each wl_surface is private to
the connection where it was created.
Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/mesa-users/attachments/20240430/2082507f/attachment.sig>
More information about the mesa-users
mailing list