From ea7c59db33a4c030bbc445f2a65f977f55eef8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 4 Nov 2017 15:18:33 -0700 Subject: [PATCH 1/2] Updated thread funcs to match bx. --- examples/common/entry/entry_windows.cpp | 4 ++-- src/bgfx_p.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/common/entry/entry_windows.cpp b/examples/common/entry/entry_windows.cpp index 18e55531b..68045859e 100644 --- a/examples/common/entry/entry_windows.cpp +++ b/examples/common/entry/entry_windows.cpp @@ -313,7 +313,7 @@ namespace entry int m_argc; const char* const* m_argv; - static int32_t threadFunc(void* _userData); + static int32_t threadFunc(bx::Thread* _thread, void* _userData); }; struct Msg @@ -1096,7 +1096,7 @@ namespace entry PostMessage(s_ctx.m_hwnd[0], WM_USER_WINDOW_MOUSE_LOCK, _handle.idx, _lock); } - int32_t MainThreadEntry::threadFunc(void* _userData) + int32_t MainThreadEntry::threadFunc(bx::Thread* /*_thread*/, void* _userData) { MainThreadEntry* self = (MainThreadEntry*)_userData; int32_t result = main(self->m_argc, self->m_argv); diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 181f6a437..00b37521a 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -2562,7 +2562,7 @@ namespace bgfx { } - static int32_t renderThread(void* /*_userData*/) + static int32_t renderThread(bx::Thread* /*_self*/, void* /*_userData*/) { BX_TRACE("render thread start"); BGFX_PROFILER_SET_CURRENT_THREAD_NAME("bgfx - Render Thread"); From 2d835155a977563d34f3da4cca473617d8296691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 4 Nov 2017 15:25:11 -0700 Subject: [PATCH 2/2] Fixed build. --- examples/common/entry/entry_android.cpp | 6 ++++-- examples/common/entry/entry_glfw.cpp | 6 ++++-- examples/common/entry/entry_ios.mm | 13 ++++++++----- examples/common/entry/entry_osx.mm | 11 +++++++---- examples/common/entry/entry_sdl.cpp | 6 ++++-- examples/common/entry/entry_x11.cpp | 6 ++++-- 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/examples/common/entry/entry_android.cpp b/examples/common/entry/entry_android.cpp index cbcdb563b..3c39f6085 100644 --- a/examples/common/entry/entry_android.cpp +++ b/examples/common/entry/entry_android.cpp @@ -88,7 +88,7 @@ namespace entry int m_argc; const char* const* m_argv; - static int32_t threadFunc(void* _userData); + static int32_t threadFunc(bx::Thread* _thread, void* _userData); }; class FileReaderAndroid : public bx::FileReaderI @@ -550,8 +550,10 @@ namespace entry BX_UNUSED(_handle, _lock); } - int32_t MainThreadEntry::threadFunc(void* _userData) + int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData) { + BX_UNUSED(_thread); + int32_t result = chdir("/sdcard/bgfx/examples/runtime"); BX_CHECK(0 == result, "Failed to chdir to dir. android.permission.WRITE_EXTERNAL_STORAGE?", errno); diff --git a/examples/common/entry/entry_glfw.cpp b/examples/common/entry/entry_glfw.cpp index 312494350..9453bcd23 100644 --- a/examples/common/entry/entry_glfw.cpp +++ b/examples/common/entry/entry_glfw.cpp @@ -230,7 +230,7 @@ namespace entry int m_argc; const char* const* m_argv; - static int32_t threadFunc(void* _userData); + static int32_t threadFunc(bx::Thread* _thread, void* _userData); }; enum MsgType @@ -837,8 +837,10 @@ namespace entry glfwPostEmptyEvent(); } - int32_t MainThreadEntry::threadFunc(void* _userData) + int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData) { + BX_UNUSED(_thread); + MainThreadEntry* self = (MainThreadEntry*)_userData; int32_t result = main(self->m_argc, self->m_argv); diff --git a/examples/common/entry/entry_ios.mm b/examples/common/entry/entry_ios.mm index 1b32ba425..d781089fb 100644 --- a/examples/common/entry/entry_ios.mm +++ b/examples/common/entry/entry_ios.mm @@ -29,7 +29,7 @@ namespace entry int m_argc; const char* const* m_argv; - static int32_t threadFunc(void* _userData); + static int32_t threadFunc(bx::Thread* _thread, void* _userData); }; static WindowHandle s_defaultWindow = { 0 }; @@ -63,19 +63,22 @@ namespace entry static Context* s_ctx; - int32_t MainThreadEntry::threadFunc(void* _userData) + int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData) { + BX_UNUSED(_thread); + CFBundleRef mainBundle = CFBundleGetMainBundle(); - if ( mainBundle != nil ) + if (mainBundle != nil) { CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); - if ( resourcesURL != nil ) + if (resourcesURL != nil) { char path[PATH_MAX]; - if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX) ) + if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8*)path, PATH_MAX) ) { chdir(path); } + CFRelease(resourcesURL); } } diff --git a/examples/common/entry/entry_osx.mm b/examples/common/entry/entry_osx.mm index 12be9ec9d..a31e711e0 100644 --- a/examples/common/entry/entry_osx.mm +++ b/examples/common/entry/entry_osx.mm @@ -66,19 +66,22 @@ namespace entry int m_argc; const char* const* m_argv; - static int32_t threadFunc(void* _userData) + static int32_t threadFunc(bx::Thread* _thread, void* _userData); { + BX_UNUSED(_thread); + CFBundleRef mainBundle = CFBundleGetMainBundle(); - if ( mainBundle != nil ) + if (mainBundle != nil) { CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); - if ( resourcesURL != nil ) + if (resourcesURL != nil) { char path[PATH_MAX]; - if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX) ) + if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8*)path, PATH_MAX) ) { chdir(path); } + CFRelease(resourcesURL); } } diff --git a/examples/common/entry/entry_sdl.cpp b/examples/common/entry/entry_sdl.cpp index e8c82d387..62a59b5bc 100644 --- a/examples/common/entry/entry_sdl.cpp +++ b/examples/common/entry/entry_sdl.cpp @@ -249,7 +249,7 @@ namespace entry int m_argc; char** m_argv; - static int32_t threadFunc(void* _userData); + static int32_t threadFunc(bx::Thread* _thread, void* _userData); }; /// @@ -1090,8 +1090,10 @@ namespace entry sdlPostEvent(SDL_USER_WINDOW_MOUSE_LOCK, _handle, NULL, _lock); } - int32_t MainThreadEntry::threadFunc(void* _userData) + int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData) { + BX_UNUSED(_thread); + MainThreadEntry* self = (MainThreadEntry*)_userData; int32_t result = main(self->m_argc, self->m_argv); diff --git a/examples/common/entry/entry_x11.cpp b/examples/common/entry/entry_x11.cpp index f55ee4baf..d65520f4f 100644 --- a/examples/common/entry/entry_x11.cpp +++ b/examples/common/entry/entry_x11.cpp @@ -223,7 +223,7 @@ namespace entry int32_t m_argc; const char* const* m_argv; - static int32_t threadFunc(void* _userData); + static int32_t threadFunc(bx::Thread* _thread, void* _userData); }; struct Msg @@ -679,8 +679,10 @@ namespace entry static Context s_ctx; - int32_t MainThreadEntry::threadFunc(void* _userData) + int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData) { + BX_UNUSED(_thread); + MainThreadEntry* self = (MainThreadEntry*)_userData; int32_t result = main(self->m_argc, self->m_argv); s_ctx.m_exit = true;