summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
diff options
context:
space:
mode:
author Julian Sikorski <belegdol+github@gmail.com>2023-09-05 17:10:24 +0200
committer GitHub <noreply@github.com>2023-09-06 01:10:24 +1000
commit1c61ccfe840cdae7a9f92292946a45f3b47e2412 (patch)
treeb56d4b69b96e314abcf56407da44705a602727f1 /3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
parentb2c399c61d65063ae95e8387d34b098e9516b1a9 (diff)
Updated bgfx, bx and bimg to current upstream versions. (#11493)
* Reverted "macOS, iOS: Removed OpenGL/OpenGLES support. (commit 4693983242a698eaafed87faf4ffef1789adc8f9). * Reverted "Fix macOS build" (commit ce2c2c13eda7d699051f75f598e740a447343a88). * Reverted "macOS: Fixed deprecated warnings." (commit 10a8cb61f882ebc9bb376ee2341d003880b7037f). * Added bgfx/README.mame explaining deviations from upstream.
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);