summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry_sdl.cpp')
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_sdl.cpp67
1 files changed, 45 insertions, 22 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
index 8744b98e763..2d5e9c15e76 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2022 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2023 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/
@@ -50,21 +50,24 @@ namespace entry
# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD
# if ENTRY_CONFIG_USE_WAYLAND
- 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);
- struct wl_surface* surface = wmi.info.wl.surface;
- if(!surface)
- return nullptr;
- win_impl = wl_egl_window_create(surface, width, height);
- SDL_SetWindowData(_window, "wl_egl_window", win_impl);
- }
- return (void*)(uintptr_t)win_impl;
-# else
- return (void*)wmi.info.x11.window;
-# endif
+ if (wmi.subsystem == SDL_SYSWM_WAYLAND)
+ {
+ 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);
+ struct wl_surface* surface = wmi.info.wl.surface;
+ if(!surface)
+ return nullptr;
+ win_impl = wl_egl_window_create(surface, width, height);
+ SDL_SetWindowData(_window, "wl_egl_window", win_impl);
+ }
+ return (void*)(uintptr_t)win_impl;
+ }
+ else
+# endif // ENTRY_CONFIG_USE_WAYLAND
+ return (void*)wmi.info.x11.window;
# elif BX_PLATFORM_OSX || BX_PLATFORM_IOS
return wmi.info.cocoa.window;
# elif BX_PLATFORM_WINDOWS
@@ -505,7 +508,7 @@ namespace entry
{
bx::AllocatorI* allocator = getAllocator();
uint32_t size = (uint32_t)bx::getSize(reader);
- void* data = BX_ALLOC(allocator, size + 1);
+ void* data = bx::alloc(allocator, size + 1);
bx::read(reader, data, size, bx::ErrorAssert{});
bx::close(reader);
((char*)data)[size] = '\0';
@@ -514,7 +517,7 @@ namespace entry
DBG("SDL game controller add mapping failed: %s", SDL_GetError());
}
- BX_FREE(allocator, data);
+ bx::free(allocator, data);
}
bool exit = false;
@@ -1145,18 +1148,38 @@ namespace entry
{
return NULL;
}
-
# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD
# if ENTRY_CONFIG_USE_WAYLAND
- return wmi.info.wl.display;
-# else
- return wmi.info.x11.display;
+ if (wmi.subsystem == SDL_SYSWM_WAYLAND)
+ return wmi.info.wl.display;
+ else
# endif // ENTRY_CONFIG_USE_WAYLAND
+ return wmi.info.x11.display;
# else
return NULL;
# endif // BX_PLATFORM_*
}
+ bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
+ {
+ SDL_SysWMinfo wmi;
+ SDL_VERSION(&wmi.version);
+ if (!SDL_GetWindowWMInfo(s_ctx.m_window[_handle.idx], &wmi) )
+ {
+ return bgfx::NativeWindowHandleType::Default;
+ }
+# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD
+# if ENTRY_CONFIG_USE_WAYLAND
+ if (wmi.subsystem == SDL_SYSWM_WAYLAND)
+ return bgfx::NativeWindowHandleType::Wayland;
+ else
+# endif // ENTRY_CONFIG_USE_WAYLAND
+ return bgfx::NativeWindowHandleType::Default;
+# else
+ return bgfx::NativeWindowHandleType::Default;
+# endif // BX_PLATFORM_*
+ }
+
int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData)
{
BX_UNUSED(_thread);