-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add initial support for wayland to bgfx renderer #11451
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
Changes from all commits
51ba341
7a0a5aa
63f382f
8542812
0db5852
2affa46
5474221
8d08909
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -56,6 +56,10 @@ extern void *GetOSWindow(void *wincontroller); | |||
| #endif | ||||
| #endif | ||||
|
|
||||
| #if defined(SDLMAME_USE_WAYLAND) | ||||
| #include <wayland-egl.h> | ||||
| #endif | ||||
|
|
||||
| #include <bgfx/bgfx.h> | ||||
| #include <bgfx/platform.h> | ||||
|
|
||||
|
|
@@ -382,6 +386,36 @@ bool video_bgfx::init_bgfx_library(osd_window &window) | |||
| } | ||||
|
|
||||
|
|
||||
| //============================================================ | ||||
| // Helper for creating a wayland window | ||||
| //============================================================ | ||||
|
|
||||
| #if defined(SDLMAME_USE_WAYLAND) | ||||
| wl_egl_window *create_wl_egl_window(SDL_Window *window, struct wl_surface *surface) | ||||
| { | ||||
| if (!surface) | ||||
| { | ||||
| osd_printf_error("Wayland surface missing, aborting\n"); | ||||
| return nullptr; | ||||
| } | ||||
| wl_egl_window *win_impl = (wl_egl_window *)SDL_GetWindowData(window, "wl_egl_window"); | ||||
| if (!win_impl) | ||||
| { | ||||
| int width, height; | ||||
| SDL_GetWindowSize(window, &width, &height); | ||||
| win_impl = wl_egl_window_create(surface, width, height); | ||||
| if (!win_impl) | ||||
| { | ||||
| osd_printf_error("Creating wayland window failed\n"); | ||||
| return nullptr; | ||||
| } | ||||
| SDL_SetWindowData(window, "wl_egl_window", win_impl); | ||||
| } | ||||
| return win_impl; | ||||
| } | ||||
| #endif | ||||
|
|
||||
|
|
||||
| //============================================================ | ||||
| // Utility for setting up window handle | ||||
| //============================================================ | ||||
|
|
@@ -423,10 +457,16 @@ bool video_bgfx::set_platform_data(bgfx::PlatformData &platform_data, osd_window | |||
| platform_data.nwh = wmi.info.cocoa.window; | ||||
| break; | ||||
| #endif | ||||
| #if defined(SDL_VIDEO_DRIVER_WAYLAND) && SDL_VERSION_ATLEAST(2, 0, 16) | ||||
| #if defined(SDL_VIDEO_DRIVER_WAYLAND) && SDL_VERSION_ATLEAST(2, 0, 16) && defined(SDLMAME_USE_WAYLAND) | ||||
| case SDL_SYSWM_WAYLAND: | ||||
| platform_data.ndt = wmi.info.wl.display; | ||||
| platform_data.nwh = wmi.info.wl.egl_window; | ||||
| platform_data.nwh = create_wl_egl_window(dynamic_cast<sdl_window_info const &>(window).platform_window(), wmi.info.wl.surface); | ||||
| if (!platform_data.nwh) | ||||
| { | ||||
| osd_printf_error("BGFX: Error creating a Wayland window\n"); | ||||
| return false; | ||||
| } | ||||
| platform_data.type = bgfx::NativeWindowHandleType::Wayland; | ||||
|
Comment on lines
-429
to
+469
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the rest of the branches in this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
mame/3rdparty/bgfx/src/bgfx.cpp Line 3425 in e6a7b3c
The reason why examples are doing it explicitly is because they all go via an intermediate getNativeWindowHandleType() function which has to return something for non-Wayland. mame appears to be setting the parameters directly which would suggest setting the window handle to default would be redundant.
|
||||
| break; | ||||
| #endif | ||||
| #if defined(SDL_VIDEO_DRIVER_ANDROID) | ||||
|
|
@@ -513,9 +553,9 @@ static void *sdlNativeWindowHandle(SDL_Window *window) | |||
| case SDL_SYSWM_COCOA: | ||||
| return wmi.info.cocoa.window; | ||||
| #endif | ||||
| #if defined(SDL_VIDEO_DRIVER_WAYLAND) && SDL_VERSION_ATLEAST(2, 0, 16) | ||||
| #if defined(SDL_VIDEO_DRIVER_WAYLAND) && SDL_VERSION_ATLEAST(2, 0, 16) && defined(SDLMAME_USE_WAYLAND) | ||||
| case SDL_SYSWM_WAYLAND: | ||||
| return wmi.info.wl.egl_window; | ||||
| return osd::create_wl_egl_window(window, wmi.info.wl.surface); | ||||
| #endif | ||||
| #if defined(SDL_VIDEO_DRIVER_ANDROID) | ||||
| case SDL_SYSWM_ANDROID: | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You really should follow the code style of files you’re modifying. Also, why are you casting data pointers through
uintptr_t? That’s only necessary when coercing pointer-to-code to pointer-to-data or vice versa.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dropped the cast. Apologies for the style, I am a C++ newbie at best. The code is more or less a copy-paste from
https://github.com/bkaradzic/bgfx/blob/3101a0d93f024e4278caaab29566647cd3e2bf84/examples/common/entry/entry_sdl.cpp#L53-L64
Do you mind being more specific in terms of what I should fix style-wise?