From 1192bf6f2cccfbddeef53df519ae60b239c30b66 Mon Sep 17 00:00:00 2001 From: Max Fedotov Date: Wed, 13 Nov 2024 09:50:35 +0300 Subject: [PATCH] EGL: use eglGetPlatformDisplay if available (#865) POSIX Ports: When acquiring an EGL context, try calling the client-specific eglGetPlatformDisplay() before falling back to the more generic eglGetDisplay(). Hopefully fixes #864. --- desmume/src/frontend/posix/shared/egl_3Demu.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/desmume/src/frontend/posix/shared/egl_3Demu.cpp b/desmume/src/frontend/posix/shared/egl_3Demu.cpp index 7ca1cb3db..49e118567 100644 --- a/desmume/src/frontend/posix/shared/egl_3Demu.cpp +++ b/desmume/src/frontend/posix/shared/egl_3Demu.cpp @@ -45,8 +45,18 @@ static bool __egl_initOpenGL(const int requestedAPI, const int requestedProfile, EGLint eglMajorVersion; EGLint eglMinorVersion; - - currDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); + + EGLAttrib displayAttr[] = {EGL_NONE}; + currDisplay = eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, EGL_DEFAULT_DISPLAY, displayAttr); + if(currDisplay == EGL_NO_DISPLAY) + currDisplay = eglGetPlatformDisplay(EGL_PLATFORM_XCB_EXT, EGL_DEFAULT_DISPLAY, displayAttr); + if(currDisplay == EGL_NO_DISPLAY) + currDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if(currDisplay == EGL_NO_DISPLAY) + { + puts("EGL: failed to obtain display handle"); + return false; + } if (eglInitialize(currDisplay, &eglMajorVersion, &eglMinorVersion) == EGL_FALSE) { puts("EGL: eglInitialize failed");