Removed PlatformData helpers.

This commit is contained in:
Branimir Karadžić 2016-08-17 20:41:09 -07:00
parent 939829f88c
commit 3ac8943e05
6 changed files with 68 additions and 115 deletions

View File

@ -17,6 +17,7 @@
#include <android/looper.h>
#include <android/window.h>
#include <android_native_app_glue.h>
#include <android/native_window.h>
extern "C"
{
@ -28,6 +29,18 @@ extern "C"
namespace entry
{
///
inline void androidSetWindow(::ANativeWindow* _window)
{
bgfx::PlatformData pd;
pd.ndt = NULL;
pd.nwh = _window;
pd.context = NULL;
pd.backBuffer = NULL;
pd.backBufferDS = NULL;
bgfx::setPlatformData(pd);
}
struct GamepadRemap
{
uint16_t m_keyCode;
@ -142,7 +155,7 @@ namespace entry
if (m_window != m_app->window)
{
m_window = m_app->window;
bgfx::androidSetWindow(m_window);
androidSetWindow(m_window);
int32_t width = ANativeWindow_getWidth(m_window);
int32_t height = ANativeWindow_getHeight(m_window);

View File

@ -46,6 +46,18 @@
namespace entry
{
///
inline void osxSetNSWindow(void* _window, void* _nsgl = NULL)
{
bgfx::PlatformData pd;
pd.ndt = NULL;
pd.nwh = _window;
pd.context = _nsgl;
pd.backBuffer = NULL;
pd.backBufferDS = NULL;
bgfx::setPlatformData(pd);
}
static WindowHandle s_defaultWindow = { 0 }; // TODO: Add support for more windows
static uint8_t s_translateKey[256];
@ -460,7 +472,7 @@ namespace entry
m_window[0] = window;
m_windowFrame = [window frame];
bgfx::osxSetNSWindow(window);
osxSetNSWindow(window);
MainThreadEntry mte;
mte.m_argc = _argc;

View File

@ -30,6 +30,18 @@
namespace entry
{
///
inline void winSetHwnd(::HWND _window)
{
bgfx::PlatformData pd;
pd.ndt = NULL;
pd.nwh = _window;
pd.context = NULL;
pd.backBuffer = NULL;
pd.backBufferDS = NULL;
bgfx::setPlatformData(pd);
}
typedef DWORD (WINAPI* PFN_XINPUT_GET_STATE)(DWORD dwUserIndex, XINPUT_STATE* pState);
typedef void (WINAPI* PFN_XINPUT_ENABLE)(BOOL enable); // 1.4+
@ -471,7 +483,7 @@ namespace entry
| ENTRY_WINDOW_FLAG_FRAME
;
bgfx::winSetHwnd(m_hwnd[0]);
winSetHwnd(m_hwnd[0]);
adjust(m_hwnd[0], ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT, true);
clear(m_hwnd[0]);

View File

@ -9,6 +9,7 @@
#include <bgfx/bgfxplatform.h>
#include <bx/thread.h>
#include <Unknwn.h>
using namespace Windows::ApplicationModel;
using namespace Windows::ApplicationModel::Core;
@ -26,6 +27,18 @@ static char* g_emptyArgs[] = { "" };
static entry::WindowHandle g_defaultWindow = { 0 };
static entry::EventQueue g_eventQueue;
///
inline void winrtSetWindow(::IUnknown* _window)
{
bgfx::PlatformData pd;
pd.ndt = NULL;
pd.nwh = _window;
pd.context = NULL;
pd.backBuffer = NULL;
pd.backBufferDS = NULL;
bgfx::setPlatformData(pd);
}
ref class App sealed : public IFrameworkView
{
public:
@ -56,7 +69,7 @@ public:
window->Closed += ref new
TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &App::OnWindowClosed);
bgfx::winrtSetWindow(reinterpret_cast<IUnknown*>(window) );
winrtSetWindow(reinterpret_cast<IUnknown*>(window) );
}
virtual void Load(String^ entryPoint)

View File

@ -24,6 +24,18 @@
namespace entry
{
///
inline void x11SetDisplayWindow(void* _display, uint32_t _window, void* _glx = NULL)
{
bgfx::PlatformData pd;
pd.ndt = _display;
pd.nwh = (void*)(uintptr_t)_window;
pd.context = _glx;
pd.backBuffer = NULL;
pd.backBufferDS = NULL;
bgfx::setPlatformData(pd);
}
#define JS_EVENT_BUTTON 0x01 /* button pressed/released */
#define JS_EVENT_AXIS 0x02 /* joystick moved */
#define JS_EVENT_INIT 0x80 /* initial state of device */
@ -387,7 +399,7 @@ namespace entry
);
//
bgfx::x11SetDisplayWindow(m_display, m_window[0]);
x11SetDisplayWindow(m_display, m_window[0]);
MainThreadEntry mte;
mte.m_argc = _argc;

View File

@ -129,61 +129,7 @@ namespace bgfx
} // namespace bgfx
#if BX_PLATFORM_ANDROID
# include <android/native_window.h>
namespace bgfx
{
///
inline void androidSetWindow(::ANativeWindow* _window)
{
PlatformData pd;
pd.ndt = NULL;
pd.nwh = _window;
pd.context = NULL;
pd.backBuffer = NULL;
pd.backBufferDS = NULL;
setPlatformData(pd);
}
} // namespace bgfx
#elif BX_PLATFORM_IOS
namespace bgfx
{
///
inline void iosSetEaglLayer(void* _window)
{
PlatformData pd;
pd.ndt = NULL;
pd.nwh = _window;
pd.context = NULL;
pd.backBuffer = NULL;
pd.backBufferDS = NULL;
setPlatformData(pd);
}
} // namespace bgfx
#elif BX_PLATFORM_BSD || BX_PLATFORM_LINUX || BX_PLATFORM_RPI
namespace bgfx
{
///
inline void x11SetDisplayWindow(void* _display, uint32_t _window, void* _glx = NULL)
{
PlatformData pd;
pd.ndt = _display;
pd.nwh = (void*)(uintptr_t)_window;
pd.context = _glx;
pd.backBuffer = NULL;
pd.backBufferDS = NULL;
setPlatformData(pd);
}
} // namespace bgfx
#elif BX_PLATFORM_NACL
#if BX_PLATFORM_NACL
# include <ppapi/c/ppb_graphics_3d.h>
# include <ppapi/c/ppb_instance.h>
@ -196,61 +142,6 @@ namespace bgfx
} // namespace bgfx
#elif BX_PLATFORM_OSX
namespace bgfx
{
///
inline void osxSetNSWindow(void* _window, void* _nsgl = NULL)
{
PlatformData pd;
pd.ndt = NULL;
pd.nwh = _window;
pd.context = _nsgl;
pd.backBuffer = NULL;
pd.backBufferDS = NULL;
setPlatformData(pd);
}
} // namespace bgfx
#elif BX_PLATFORM_WINDOWS
# include <windows.h>
namespace bgfx
{
///
inline void winSetHwnd(::HWND _window)
{
PlatformData pd;
pd.ndt = NULL;
pd.nwh = _window;
pd.context = NULL;
pd.backBuffer = NULL;
pd.backBufferDS = NULL;
setPlatformData(pd);
}
} // namespace bgfx
#elif BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
# include <Unknwn.h>
namespace bgfx
{
///
inline void winrtSetWindow(::IUnknown* _window)
{
PlatformData pd;
pd.ndt = NULL;
pd.nwh = _window;
pd.context = NULL;
pd.backBuffer = NULL;
pd.backBufferDS = NULL;
setPlatformData(pd);
}
} // namespace bgfx
#endif // BX_PLATFORM_
#endif // BGFX_PLATFORM_H_HEADER_GUARD