From c0bd3ceee5a18bc07bf1c1fbba5a790f28838462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E9=A3=8E?= Date: Mon, 21 May 2018 00:28:59 +0800 Subject: [PATCH] fix c99 bgx_init (#1383) --- src/bgfx.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 3d5ec851e..3f0ad590c 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -4777,7 +4777,19 @@ BGFX_C_API void bgfx_init_ctor(bgfx_init_t* _init) BGFX_C_API bool bgfx_init(const bgfx_init_t* _init) { - return bgfx::init(*reinterpret_cast(_init) ); + bgfx_init_t init = *_init; + if (init.callback != NULL) { + static bgfx::CallbackC99 s_callback; + s_callback.m_interface = init.callback; + init.callback = reinterpret_cast(&s_callback); + } + if (init.allocator != NULL) { + static bgfx::AllocatorC99 s_allocator; + s_allocator.m_interface = init.allocator; + init.allocator = reinterpret_cast(&s_allocator); + } + + return bgfx::init(*reinterpret_cast(&init) ); } BGFX_C_API void bgfx_shutdown(void)