Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant create EGLSurface in Wayland from SDLWindow (no EGLNativeWindow pointer) #3973

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.12
Reported for operating system, platform: Linux, All

Comments on the original bug report:

On 2021-01-08 15:28:48 +0000, sashikknox wrote:

In some cases, need create EGLWindow with SDLWindow. In X11 i can get pointer to NativeWindow from struct SDL_SysWMinfo wmInfo

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:

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

On 2021-01-08 18:12:57 +0000, Sam Lantinga wrote:

Yes, this sounds fine.

Can you attach a tested patch that implements this, relative to the latest SDL code?

Thanks!

On 2021-01-08 18:51:12 +0000, sashikknox wrote:

Ok, i'll try do it as fast as i can )

On 2021-01-08 22:51:21 +0000, sashikknox wrote:

Created attachment 4644
egl wayland

patch for Wayland backend of SDL2

On 2021-01-08 22:53:21 +0000, sashikknox wrote:

Created attachment 4645
patch

On 2021-01-13 10:37:28 +0000, sashikknox wrote:

(In reply to Sam Lantinga from comment # 1)

Yes, this sounds fine.

Can you attach a tested patch that implements this, relative to the latest
SDL code?

Thanks!

is my patch enough?

On 2021-01-14 22:43:41 +0000, Sam Lantinga wrote:

Pretty close. I added a version check and pushed it:
https://hg.libsdl.org/SDL/rev/72d90e6fd083

Thanks!

@SDLBugzilla SDLBugzilla added the enhancement New feature or request label Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant