diff options
author | 2023-01-05 05:12:10 +0100 | |
---|---|---|
committer | 2023-01-04 23:12:10 -0500 | |
commit | 5581eaa50a42256242f32569f59ce10d70ddd8c2 (patch) | |
tree | 0d79e41b381ebf6d50ab5b7e20c0993b7328b5b6 /3rdparty/bgfx/examples/common/entry/entry.cpp | |
parent | 34c37d4f5415f886ec3ae462b008cebbf5fa22f9 (diff) |
Update BGFX, BX and BIMG (#10750)
* Update to bgfx a93a714632b79b5ddbf5c86ac323fa9b76ed3433
Co-authored-by: Бранимир Караџић <branimirkaradzic@gmail.com>
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry.cpp')
-rw-r--r-- | 3rdparty/bgfx/examples/common/entry/entry.cpp | 71 |
1 files changed, 52 insertions, 19 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry.cpp b/3rdparty/bgfx/examples/common/entry/entry.cpp index 852abe91623..58a671e6a70 100644 --- a/3rdparty/bgfx/examples/common/entry/entry.cpp +++ b/3rdparty/bgfx/examples/common/entry/entry.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 <bx/bx.h> @@ -443,12 +443,27 @@ BX_PRAGMA_DIAGNOSTIC_POP(); return bx::kExitFailure; } + struct AppInternal + { + AppI* m_next; + const char* m_name; + const char* m_description; + const char* m_url; + }; + + static ptrdiff_t s_offset = 0; + AppI::AppI(const char* _name, const char* _description, const char* _url) { - m_name = _name; - m_description = _description; - m_url = _url; - m_next = s_apps; + BX_STATIC_ASSERT(sizeof(AppInternal) <= sizeof(m_internal) ); + s_offset = BX_OFFSETOF(AppI, m_internal); + + AppInternal* ai = (AppInternal*)m_internal; + + ai->m_name = _name; + ai->m_description = _description; + ai->m_url = _url; + ai->m_next = s_apps; s_apps = this; s_numApps++; @@ -464,7 +479,8 @@ BX_PRAGMA_DIAGNOSTIC_POP(); { if (NULL != prev) { - prev->m_next = next; + AppInternal* ai = bx::addressOf<AppInternal>(prev, s_offset); + ai->m_next = next; } else { @@ -480,22 +496,26 @@ BX_PRAGMA_DIAGNOSTIC_POP(); const char* AppI::getName() const { - return m_name; + AppInternal* ai = (AppInternal*)m_internal; + return ai->m_name; } const char* AppI::getDescription() const { - return m_description; + AppInternal* ai = (AppInternal*)m_internal; + return ai->m_description; } const char* AppI::getUrl() const { - return m_url; + AppInternal* ai = (AppInternal*)m_internal; + return ai->m_url; } AppI* AppI::getNext() { - return m_next; + AppInternal* ai = (AppInternal*)m_internal; + return ai->m_next; } AppI* getFirstApp() @@ -513,8 +533,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); _app->init(_argc, _argv, s_width, s_height); bgfx::frame(); - WindowHandle defaultWindow = { 0 }; - setWindowSize(defaultWindow, s_width, s_height); + setWindowSize(kDefaultWindowHandle, s_width, s_height); #if BX_PLATFORM_EMSCRIPTEN s_app = _app; @@ -560,9 +579,15 @@ BX_PRAGMA_DIAGNOSTIC_POP(); for (ii = 1; ii < s_numApps; ++ii) { AppI* app = apps[ii-1]; - app->m_next = apps[ii]; + + AppInternal* ai = bx::addressOf<AppInternal>(app, s_offset); + ai->m_next = apps[ii]; + } + + { + AppInternal* ai = bx::addressOf<AppInternal>(apps[s_numApps-1], s_offset); + ai->m_next = NULL; } - apps[s_numApps-1]->m_next = NULL; BX_FREE(g_allocator, apps); } @@ -583,14 +608,12 @@ BX_PRAGMA_DIAGNOSTIC_POP(); inputInit(); inputAddBindings("bindings", s_bindings); - entry::WindowHandle defaultWindow = { 0 }; - bx::FilePath fp(_argv[0]); char title[bx::kMaxFilePath]; bx::strCopy(title, BX_COUNTOF(title), fp.getBaseName() ); - entry::setWindowTitle(defaultWindow, title); - setWindowSize(defaultWindow, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT); + entry::setWindowTitle(kDefaultWindowHandle, title); + setWindowSize(kDefaultWindowHandle, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT); sortApps(); @@ -1004,3 +1027,13 @@ extern "C" bool entry_process_events(uint32_t* _width, uint32_t* _height, uint32 { return entry::processEvents(*_width, *_height, *_debug, *_reset, NULL); } + +extern "C" void* entry_get_default_native_window_handle() +{ + return entry::getNativeWindowHandle(entry::kDefaultWindowHandle); +} + +extern "C" void* entry_get_native_display_handle() +{ + return entry::getNativeDisplayHandle(); +} |