diff options
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry_sdl.cpp')
-rw-r--r-- | 3rdparty/bgfx/examples/common/entry/entry_sdl.cpp | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp index 8744b98e763..360d1df0add 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-2022 Branimir Karadzic. All rights reserved. - * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE + * Copyright 2011-2021 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause */ #include "entry_p.h" @@ -74,6 +74,35 @@ 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) @@ -484,6 +513,7 @@ namespace entry s_userEventStart = SDL_RegisterEvents(7); + sdlSetWindow(m_window[0]); bgfx::renderFrame(); m_thread.init(MainThreadEntry::threadFunc, &m_mte); @@ -506,7 +536,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::ErrorAssert{}); + bx::read(reader, data, size); bx::close(reader); ((char*)data)[size] = '\0'; @@ -1132,31 +1162,6 @@ 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); |