summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
diff options
context:
space:
mode:
author Miodrag Milanović <mmicko@gmail.com>2023-01-05 15:32:40 +0100
committer GitHub <noreply@github.com>2023-01-05 09:32:40 -0500
commit812e6094f47bb8d1da5a6b421aa4c724cf2035c0 (patch)
tree0f5bab2fe9393d1f629e9bf63e76cecca74ec0c9 /3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
parent4a1b41854bba8fc2567906b88bab8ca81e75d187 (diff)
Update BGFX, BX and BIMG (#10789)
* Update to bgfx a93a714632b79b5ddbf5c86ac323fa9b76ed3433 Co-authored-by: Бранимир Караџић <branimirkaradzic@gmail.com>
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry_sdl.cpp')
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_sdl.cpp61
1 files changed, 28 insertions, 33 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
index 360d1df0add..8744b98e763 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright 2011-2021 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ * Copyright 2011-2022 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/
#include "entry_p.h"
@@ -74,35 +74,6 @@ namespace entry
# endif // BX_PLATFORM_
}
- inline bool sdlSetWindow(SDL_Window* _window)
- {
- SDL_SysWMinfo wmi;
- SDL_VERSION(&wmi.version);
- if (!SDL_GetWindowWMInfo(_window, &wmi) )
- {
- return false;
- }
-
- bgfx::PlatformData pd;
-# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD
-# if ENTRY_CONFIG_USE_WAYLAND
- pd.ndt = wmi.info.wl.display;
-# else
- pd.ndt = wmi.info.x11.display;
-# endif
-# else
- pd.ndt = NULL;
-# endif // BX_PLATFORM_
- pd.nwh = sdlNativeWindowHandle(_window);
-
- pd.context = NULL;
- pd.backBuffer = NULL;
- pd.backBufferDS = NULL;
- bgfx::setPlatformData(pd);
-
- return true;
- }
-
static void sdlDestroyWindow(SDL_Window* _window)
{
if(!_window)
@@ -513,7 +484,6 @@ namespace entry
s_userEventStart = SDL_RegisterEvents(7);
- sdlSetWindow(m_window[0]);
bgfx::renderFrame();
m_thread.init(MainThreadEntry::threadFunc, &m_mte);
@@ -536,7 +506,7 @@ namespace entry
bx::AllocatorI* allocator = getAllocator();
uint32_t size = (uint32_t)bx::getSize(reader);
void* data = BX_ALLOC(allocator, size + 1);
- bx::read(reader, data, size);
+ bx::read(reader, data, size, bx::ErrorAssert{});
bx::close(reader);
((char*)data)[size] = '\0';
@@ -1162,6 +1132,31 @@ namespace entry
sdlPostEvent(SDL_USER_WINDOW_MOUSE_LOCK, _handle, NULL, _lock);
}
+ void* getNativeWindowHandle(WindowHandle _handle)
+ {
+ return sdlNativeWindowHandle(s_ctx.m_window[_handle.idx]);
+ }
+
+ void* getNativeDisplayHandle()
+ {
+ SDL_SysWMinfo wmi;
+ SDL_VERSION(&wmi.version);
+ if (!SDL_GetWindowWMInfo(s_ctx.m_window[0], &wmi) )
+ {
+ 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;
+# endif // ENTRY_CONFIG_USE_WAYLAND
+# else
+ return NULL;
+# endif // BX_PLATFORM_*
+ }
+
int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData)
{
BX_UNUSED(_thread);