diff options
author | Sam Lantinga <slouken@libsdl.org> | 2021-01-14 14:42:53 -0800 |
---|---|---|
committer | Sam Lantinga <slouken@libsdl.org> | 2021-01-14 14:42:53 -0800 |
commit | 31a064040ed10ec21d53f400efcf1a51c06bf3c5 (patch) | |
tree | 3f6ee76da198b6f30e72da1613740d1417011027 /include | |
parent | e0e9337cd546c196076572fbe36a9c6f2390a70a (diff) | |
download | sdl-31a064040ed10ec21d53f400efcf1a51c06bf3c5.tar.gz |
Fixed bug 5451 - Can't create EGLSurface in Wayland from SDLWindow (no EGLNativeWindow pointer)
sashikknox
In some cases, need create EGLWindow with SDLWindow. In X11 i can get pointer to NativeWindow from **struct SDL_SysWMinfo wmInfo**
```C++
struct SDL_SysWMinfo wmInfo;
SDL_GetWindowWMInfo(ptSDLWindow, &wmInfo)
#if defined(__unix__) && defined(SDL_VIDEO_DRIVER_X11)
nativeWindow=(EGLNativeWindowType)wmInfo.info.x11.window;
nativeDisplay=(EGLNativeDisplayType)wmInfo.info.x11.display;
#endif
```
than i can create EGLSurface
```
eglCreateWindowSurface(nativeDisplay, EGL_CONFIG, nativeWindow, SURFACE_ATTRIBUTES);
```
in Wayland i can do it with same way, just need pointer to **EGLWindow**, we already have pointer to **wl_display** from **SDL_sysWMInfo**, need add to **wl** struct in SDL_SysWMInfo another pointer to **struct wl_egl_window *egl_window;**. And in wayland backend, in function **Wayland_GetWindowWMInfo** return pointer to **egl_window** from **SDL_WindowData**
Now i use patched statically built SDL2 in port of Quake 2 GLES2 for SailfishOS (it use QtWayland):
link to SDL2 commit and changed string for patch:
- https://github.com/savegame/lp-public/commit/6858a618cd179b766fe3cab36055f07cb03ad0ea
- https://github.com/savegame/lp-public/blob/b1e29e87b9d15780e47f04918b329ac15554fc69/SDL2/src/video/wayland/SDL_waylandwindow.c#L463
link to use in Quake2 port:
1. here i get pointer to EGLNativeWindowType: https://github.com/savegame/lp-public/blob/6d94fedb1b720da24999ae6286a1809cd3d55ff5/Engine/Sources/Compatibility/OpenGLES/EGLWrapper.c#L319
2. then use it for create EGLSurface: https://github.com/savegame/lp-public/blob/6d94fedb1b720da24999ae6286a1809cd3d55ff5/Engine/Sources/Compatibility/OpenGLES/EGLWrapper.c#L391
Diffstat (limited to 'include')
-rw-r--r-- | include/SDL_syswm.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h index 6dae3778f..ee3705de2 100644 --- a/include/SDL_syswm.h +++ b/include/SDL_syswm.h @@ -274,9 +274,10 @@ struct SDL_SysWMinfo #if defined(SDL_VIDEO_DRIVER_WAYLAND) struct { - struct wl_display *display; /**< Wayland display */ - struct wl_surface *surface; /**< Wayland surface */ + struct wl_display *display; /**< Wayland display */ + struct wl_surface *surface; /**< Wayland surface */ struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */ + struct wl_egl_window *egl_window; /**< Wayland EGL window (native window) */ } wl; #endif #if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ |