Allow simultaneous X11 and Wayland support (#3152)
* Allow simultaneous X11 and Wayland support * Add NativeWindowHandleType * Set default value for g_platformData.type * Use g_platformData.type to check for a native Wayland window * Stub getNativeWindowHandleType on platform where Wayland is not an option * Implement getNativeWindowHandleType for GLFW * Add getNativeWindowHandleType to the remaining C++ examples * Add getNativeWindowHandleType to the C example
This commit is contained in:
parent
a16f603e3c
commit
f4d463990a
@ -34,6 +34,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -149,6 +149,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -508,6 +508,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -121,6 +121,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -84,6 +84,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -104,6 +104,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -331,6 +331,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -247,6 +247,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -159,6 +159,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -814,6 +814,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_viewState.m_width;
|
||||
init.resolution.height = m_viewState.m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -1786,6 +1786,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_viewState.m_width;
|
||||
init.resolution.height = m_viewState.m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -80,6 +80,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -1159,6 +1159,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_viewState.m_width;
|
||||
init.resolution.height = m_viewState.m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -131,6 +131,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -420,6 +420,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -171,6 +171,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -1404,6 +1404,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -213,6 +213,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -88,6 +88,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -132,6 +132,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -9,6 +9,7 @@
|
||||
extern bool entry_process_events(uint32_t* _width, uint32_t* _height, uint32_t* _debug, uint32_t* _reset);
|
||||
extern void* entry_get_default_native_window_handle(void);
|
||||
extern void* entry_get_native_display_handle(void);
|
||||
extern bgfx_native_window_handle_type_t entry_get_native_window_handle_type(void);
|
||||
|
||||
uint16_t uint16_max(uint16_t _a, uint16_t _b)
|
||||
{
|
||||
@ -29,6 +30,7 @@ int32_t _main_(int32_t _argc, char** _argv)
|
||||
|
||||
init.platformData.nwh = entry_get_default_native_window_handle();
|
||||
init.platformData.ndt = entry_get_native_display_handle();
|
||||
init.platformData.type = entry_get_native_window_handle_type();
|
||||
|
||||
bgfx_init(&init);
|
||||
bgfx_reset(width, height, reset, init.resolution.format);
|
||||
|
@ -84,6 +84,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -80,6 +80,7 @@ ExampleTerrain(const char* _name, const char* _description, const char* _url)
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -293,6 +293,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -780,6 +780,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -213,6 +213,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -248,6 +248,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -130,6 +130,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -126,6 +126,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -104,6 +104,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -420,6 +420,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -330,6 +330,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -200,6 +200,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -271,6 +271,7 @@ namespace
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -339,6 +339,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -264,6 +264,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -253,6 +253,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -265,6 +265,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -247,6 +247,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -429,6 +429,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -146,6 +146,7 @@ public:
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -85,6 +85,7 @@ namespace
|
||||
init.vendorId = args.m_pciId;
|
||||
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
|
||||
init.platformData.ndt = entry::getNativeDisplayHandle();
|
||||
init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
init.resolution.width = m_width;
|
||||
init.resolution.height = m_height;
|
||||
init.resolution.reset = m_reset;
|
||||
|
@ -1037,3 +1037,8 @@ extern "C" void* entry_get_native_display_handle()
|
||||
{
|
||||
return entry::getNativeDisplayHandle();
|
||||
}
|
||||
|
||||
extern "C" bgfx::NativeWindowHandleType::Enum entry_get_native_window_handle_type()
|
||||
{
|
||||
return entry::getNativeWindowHandleType(entry::kDefaultWindowHandle);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define ENTRY_H_HEADER_GUARD
|
||||
|
||||
#include "dbg.h"
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/bx.h>
|
||||
#include <bx/filepath.h>
|
||||
#include <bx/string.h>
|
||||
@ -297,6 +298,9 @@ namespace entry
|
||||
///
|
||||
void* getNativeDisplayHandle();
|
||||
|
||||
///
|
||||
bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle);
|
||||
|
||||
///
|
||||
void setCurrentDir(const char* _dir);
|
||||
|
||||
|
@ -550,6 +550,11 @@ namespace entry
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
|
||||
{
|
||||
return bgfx::NativeWindowHandleType::Default;
|
||||
}
|
||||
|
||||
int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData)
|
||||
{
|
||||
BX_UNUSED(_thread);
|
||||
|
@ -875,6 +875,19 @@ namespace entry
|
||||
# endif // BX_PLATFORM_*
|
||||
}
|
||||
|
||||
bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
|
||||
{
|
||||
# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD
|
||||
# if ENTRY_CONFIG_USE_WAYLAND
|
||||
return bgfx::NativeWindowHandleType::Wayland;
|
||||
# else
|
||||
return bgfx::NativeWindowHandleType::Default;
|
||||
# endif // ENTRY_CONFIG_USE_WAYLAND
|
||||
# else
|
||||
return bgfx::NativeWindowHandleType::Default;
|
||||
# endif // BX_PLATFORM_*
|
||||
}
|
||||
|
||||
int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData)
|
||||
{
|
||||
BX_UNUSED(_thread);
|
||||
|
@ -427,6 +427,11 @@ namespace entry
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
|
||||
{
|
||||
return bgfx::NativeWindowHandleType::Default;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int _argc, const char* const* _argv)
|
||||
|
@ -161,6 +161,11 @@ namespace entry
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
|
||||
{
|
||||
return bgfx::NativeWindowHandleType::Default;
|
||||
}
|
||||
|
||||
} // namespace entry
|
||||
|
||||
using namespace entry;
|
||||
|
@ -78,6 +78,11 @@ namespace entry
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
|
||||
{
|
||||
return bgfx::NativeWindowHandleType::Default;
|
||||
}
|
||||
|
||||
} // namespace entry
|
||||
|
||||
int main(int _argc, const char* const* _argv)
|
||||
|
@ -725,6 +725,11 @@ namespace entry
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
|
||||
{
|
||||
return bgfx::NativeWindowHandleType::Default;
|
||||
}
|
||||
|
||||
} // namespace entry
|
||||
|
||||
@implementation AppDelegate
|
||||
|
@ -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
|
||||
@ -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);
|
||||
|
@ -1169,6 +1169,11 @@ namespace entry
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
|
||||
{
|
||||
return bgfx::NativeWindowHandleType::Default;
|
||||
}
|
||||
|
||||
int32_t MainThreadEntry::threadFunc(bx::Thread* /*_thread*/, void* _userData)
|
||||
{
|
||||
MainThreadEntry* self = (MainThreadEntry*)_userData;
|
||||
|
@ -771,6 +771,11 @@ namespace entry
|
||||
return s_ctx.m_display;
|
||||
}
|
||||
|
||||
bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
|
||||
{
|
||||
return bgfx::NativeWindowHandleType::Default;
|
||||
}
|
||||
|
||||
} // namespace entry
|
||||
|
||||
int main(int _argc, const char* const* _argv)
|
||||
|
@ -403,6 +403,22 @@ namespace bgfx
|
||||
};
|
||||
};
|
||||
|
||||
/// Native window handle type.
|
||||
///
|
||||
/// @attention C99's equivalent binding is `bgfx_native_window_handle_type_t`.
|
||||
///
|
||||
|
||||
struct NativeWindowHandleType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
Default = 0, //!< Platform default handle type (X11 on Linux).
|
||||
Wayland, //!< Wayland.
|
||||
|
||||
Count
|
||||
};
|
||||
};
|
||||
|
||||
static const uint16_t kInvalidHandle = UINT16_MAX;
|
||||
|
||||
BGFX_HANDLE(DynamicIndexBufferHandle)
|
||||
@ -622,15 +638,16 @@ namespace bgfx
|
||||
{
|
||||
PlatformData();
|
||||
|
||||
void* ndt; //!< Native display type (*nix specific).
|
||||
void* nwh; //!< Native window handle. If `NULL`, bgfx will create a headless
|
||||
/// context/device, provided the rendering API supports it.
|
||||
void* context; //!< GL context, D3D device, or Vulkan device. If `NULL`, bgfx
|
||||
/// will create context/device.
|
||||
void* backBuffer; //!< GL back-buffer, or D3D render target view. If `NULL` bgfx will
|
||||
/// create back-buffer color surface.
|
||||
void* backBufferDS; //!< Backbuffer depth/stencil. If `NULL`, bgfx will create a back-buffer
|
||||
/// depth/stencil surface.
|
||||
void* ndt; //!< Native display type (*nix specific).
|
||||
void* nwh; //!< Native window handle. If `NULL`, bgfx will create a headless
|
||||
/// context/device, provided the rendering API supports it.
|
||||
void* context; //!< GL context, D3D device, or Vulkan device. If `NULL`, bgfx
|
||||
/// will create context/device.
|
||||
void* backBuffer; //!< GL back-buffer, or D3D render target view. If `NULL` bgfx will
|
||||
/// create back-buffer color surface.
|
||||
void* backBufferDS; //!< Backbuffer depth/stencil. If `NULL`, bgfx will create a back-buffer
|
||||
/// depth/stencil surface.
|
||||
NativeWindowHandleType::Enum type; //!< Handle type. Needed for platforms having more than one option.
|
||||
};
|
||||
|
||||
/// Backbuffer resolution and reset parameters.
|
||||
|
@ -391,6 +391,19 @@ typedef enum bgfx_view_mode
|
||||
|
||||
} bgfx_view_mode_t;
|
||||
|
||||
/**
|
||||
* Native window handle type..
|
||||
*
|
||||
*/
|
||||
typedef enum bgfx_native_window_handle_type
|
||||
{
|
||||
BGFX_NATIVE_WINDOW_HANDLE_TYPE_DEFAULT, /** ( 0) Platform default handle type (X11 on Linux) */
|
||||
BGFX_NATIVE_WINDOW_HANDLE_TYPE_WAYLAND, /** ( 1) Wayland. */
|
||||
|
||||
BGFX_NATIVE_WINDOW_HANDLE_TYPE_COUNT
|
||||
|
||||
} bgfx_native_window_handle_type_t;
|
||||
|
||||
/**
|
||||
* Render frame enum.
|
||||
*
|
||||
@ -625,6 +638,11 @@ typedef struct bgfx_platform_data_s
|
||||
*/
|
||||
void* backBufferDS;
|
||||
|
||||
/**
|
||||
* Handle type. Needed for platforms having more than one option.
|
||||
*/
|
||||
bgfx_native_window_handle_type_t type;
|
||||
|
||||
} bgfx_platform_data_t;
|
||||
|
||||
/**
|
||||
|
@ -3437,6 +3437,7 @@ namespace bgfx
|
||||
, context(NULL)
|
||||
, backBuffer(NULL)
|
||||
, backBufferDS(NULL)
|
||||
, type(NativeWindowHandleType::Default)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1230,7 +1230,7 @@ VK_IMPORT
|
||||
BX_TRACE("\t%s", layer.m_name);
|
||||
}
|
||||
}
|
||||
#if BX_PLATFORM_OSX
|
||||
#if BX_PLATFORM_OSX || WL_EGL_PLATFORM
|
||||
uint32_t numEnabledExtensions = headless ? 0 : 3;
|
||||
|
||||
const char* enabledExtension[Extension::Count + 3] =
|
||||
@ -6776,9 +6776,9 @@ VK_DESTROY
|
||||
}
|
||||
}
|
||||
#elif BX_PLATFORM_LINUX
|
||||
#if WL_EGL_PLATFORM
|
||||
{
|
||||
if (NULL != vkCreateWaylandSurfaceKHR)
|
||||
#if WL_EGL_PLATFORM
|
||||
if (g_platformData.type == bgfx::NativeWindowHandleType::Wayland)
|
||||
{
|
||||
VkWaylandSurfaceCreateInfoKHR sci;
|
||||
sci.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
|
||||
@ -6788,45 +6788,46 @@ VK_DESTROY
|
||||
sci.surface = (wl_surface*)((wl_egl_window*)g_platformData.nwh)->surface;
|
||||
result = vkCreateWaylandSurfaceKHR(instance, &sci, allocatorCb, &m_surface);
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
if (NULL != vkCreateXlibSurfaceKHR)
|
||||
else
|
||||
#endif // WL_EGL_PLATFORM
|
||||
{
|
||||
VkXlibSurfaceCreateInfoKHR sci;
|
||||
sci.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
|
||||
sci.pNext = NULL;
|
||||
sci.flags = 0;
|
||||
sci.dpy = (Display*)g_platformData.ndt;
|
||||
sci.window = (Window)m_nwh;
|
||||
result = vkCreateXlibSurfaceKHR(instance, &sci, allocatorCb, &m_surface);
|
||||
}
|
||||
|
||||
if (VK_SUCCESS != result)
|
||||
{
|
||||
void* xcbdll = bx::dlopen("libX11-xcb.so.1");
|
||||
|
||||
if (NULL != xcbdll
|
||||
&& NULL != vkCreateXcbSurfaceKHR)
|
||||
if (NULL != vkCreateXlibSurfaceKHR)
|
||||
{
|
||||
typedef xcb_connection_t* (*PFN_XGETXCBCONNECTION)(Display*);
|
||||
PFN_XGETXCBCONNECTION XGetXCBConnection = (PFN_XGETXCBCONNECTION)bx::dlsym(xcbdll, "XGetXCBConnection");
|
||||
VkXlibSurfaceCreateInfoKHR sci;
|
||||
sci.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
|
||||
sci.pNext = NULL;
|
||||
sci.flags = 0;
|
||||
sci.dpy = (Display*)g_platformData.ndt;
|
||||
sci.window = (Window)m_nwh;
|
||||
result = vkCreateXlibSurfaceKHR(instance, &sci, allocatorCb, &m_surface);
|
||||
}
|
||||
|
||||
union { void* ptr; xcb_window_t window; } cast = { m_nwh };
|
||||
if (VK_SUCCESS != result)
|
||||
{
|
||||
void* xcbdll = bx::dlopen("libX11-xcb.so.1");
|
||||
|
||||
VkXcbSurfaceCreateInfoKHR sci;
|
||||
sci.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
|
||||
sci.pNext = NULL;
|
||||
sci.flags = 0;
|
||||
sci.connection = XGetXCBConnection( (Display*)g_platformData.ndt);
|
||||
sci.window = cast.window;
|
||||
result = vkCreateXcbSurfaceKHR(instance, &sci, allocatorCb, &m_surface);
|
||||
if (NULL != xcbdll
|
||||
&& NULL != vkCreateXcbSurfaceKHR)
|
||||
{
|
||||
typedef xcb_connection_t* (*PFN_XGETXCBCONNECTION)(Display*);
|
||||
PFN_XGETXCBCONNECTION XGetXCBConnection = (PFN_XGETXCBCONNECTION)bx::dlsym(xcbdll, "XGetXCBConnection");
|
||||
|
||||
bx::dlclose(xcbdll);
|
||||
union { void* ptr; xcb_window_t window; } cast = { m_nwh };
|
||||
|
||||
VkXcbSurfaceCreateInfoKHR sci;
|
||||
sci.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
|
||||
sci.pNext = NULL;
|
||||
sci.flags = 0;
|
||||
sci.connection = XGetXCBConnection( (Display*)g_platformData.ndt);
|
||||
sci.window = cast.window;
|
||||
result = vkCreateXcbSurfaceKHR(instance, &sci, allocatorCb, &m_surface);
|
||||
|
||||
bx::dlclose(xcbdll);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // WL_EGL_PLATFORM
|
||||
|
||||
#elif BX_PLATFORM_OSX
|
||||
{
|
||||
if (NULL != vkCreateMacOSSurfaceMVK)
|
||||
|
@ -17,10 +17,13 @@
|
||||
#elif BX_PLATFORM_LINUX
|
||||
# if WL_EGL_PLATFORM
|
||||
# define VK_USE_PLATFORM_WAYLAND_KHR
|
||||
# define KHR_SURFACE_EXTENSION_NAME VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME
|
||||
# endif // WL_EGL_PLATFORM
|
||||
# define VK_USE_PLATFORM_XLIB_KHR
|
||||
# define VK_USE_PLATFORM_XCB_KHR
|
||||
# if WL_EGL_PLATFORM
|
||||
# define KHR_SURFACE_EXTENSION_NAME VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, \
|
||||
VK_KHR_XCB_SURFACE_EXTENSION_NAME
|
||||
# else
|
||||
# define VK_USE_PLATFORM_XLIB_KHR
|
||||
# define VK_USE_PLATFORM_XCB_KHR
|
||||
# define KHR_SURFACE_EXTENSION_NAME VK_KHR_XCB_SURFACE_EXTENSION_NAME
|
||||
# endif // WL_EGL_PLATFORM
|
||||
# define VK_IMPORT_INSTANCE_PLATFORM VK_IMPORT_INSTANCE_LINUX
|
||||
@ -75,6 +78,12 @@
|
||||
/* VK_KHR_wayland_surface */ \
|
||||
VK_IMPORT_INSTANCE_FUNC(true, vkCreateWaylandSurfaceKHR); \
|
||||
VK_IMPORT_INSTANCE_FUNC(true, vkGetPhysicalDeviceWaylandPresentationSupportKHR); \
|
||||
/* VK_KHR_xlib_surface */ \
|
||||
VK_IMPORT_INSTANCE_FUNC(true, vkCreateXlibSurfaceKHR); \
|
||||
VK_IMPORT_INSTANCE_FUNC(true, vkGetPhysicalDeviceXlibPresentationSupportKHR); \
|
||||
/* VK_KHR_xcb_surface */ \
|
||||
VK_IMPORT_INSTANCE_FUNC(true, vkCreateXcbSurfaceKHR); \
|
||||
VK_IMPORT_INSTANCE_FUNC(true, vkGetPhysicalDeviceXcbPresentationSupportKHR); \
|
||||
|
||||
#else
|
||||
#define VK_IMPORT_INSTANCE_LINUX \
|
||||
|
Loading…
Reference in New Issue
Block a user