2013-01-14 03:35:06 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2011-2013 Branimir Karadzic. All rights reserved.
|
|
|
|
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __BGFXPLATFORM_H__
|
|
|
|
#define __BGFXPLATFORM_H__
|
|
|
|
|
2013-01-14 10:44:04 +04:00
|
|
|
// NOTICE:
|
|
|
|
// This header file contains platform specific interfaces. It is only
|
|
|
|
// necessary to use this header in conjunction with creating windows.
|
|
|
|
|
2013-01-14 03:35:06 +04:00
|
|
|
#include <bx/bx.h>
|
|
|
|
|
2013-04-16 10:10:32 +04:00
|
|
|
#if BX_PLATFORM_ANDROID
|
2013-04-19 08:16:09 +04:00
|
|
|
# include <android/native_window.h>
|
2013-04-16 10:10:32 +04:00
|
|
|
|
|
|
|
namespace bgfx
|
|
|
|
{
|
2013-08-11 09:15:59 +04:00
|
|
|
///
|
2013-04-19 08:16:09 +04:00
|
|
|
void androidSetWindow(::ANativeWindow* _window);
|
2013-08-11 09:15:59 +04:00
|
|
|
|
2013-04-16 10:10:32 +04:00
|
|
|
} // namespace bgfx
|
|
|
|
|
2013-07-22 01:44:53 +04:00
|
|
|
#elif BX_PLATFORM_IOS
|
|
|
|
namespace bgfx
|
|
|
|
{
|
2013-08-11 09:15:59 +04:00
|
|
|
///
|
2013-07-22 02:38:44 +04:00
|
|
|
void iosSetEaglLayer(void* _layer);
|
2013-08-11 09:15:59 +04:00
|
|
|
|
2013-07-22 01:44:53 +04:00
|
|
|
} // namespace bgfx
|
|
|
|
|
2013-04-16 10:10:32 +04:00
|
|
|
#elif BX_PLATFORM_LINUX
|
2013-01-14 03:35:06 +04:00
|
|
|
# include <X11/Xlib.h>
|
|
|
|
|
|
|
|
namespace bgfx
|
|
|
|
{
|
2013-08-11 09:15:59 +04:00
|
|
|
///
|
2013-01-14 03:35:06 +04:00
|
|
|
void x11SetDisplayWindow(::Display* _display, ::Window _window);
|
2013-08-11 09:15:59 +04:00
|
|
|
|
2013-01-14 03:35:06 +04:00
|
|
|
} // namespace bgfx
|
|
|
|
|
|
|
|
#elif BX_PLATFORM_NACL
|
|
|
|
# include <ppapi/c/ppb_graphics_3d.h>
|
|
|
|
# include <ppapi/c/ppb_instance.h>
|
|
|
|
|
|
|
|
namespace bgfx
|
|
|
|
{
|
|
|
|
typedef void (*PostSwapBuffersFn)(uint32_t _width, uint32_t _height);
|
2013-08-11 09:15:59 +04:00
|
|
|
|
|
|
|
///
|
2013-01-14 03:35:06 +04:00
|
|
|
void naclSetIntefraces(::PP_Instance, const ::PPB_Instance*, const ::PPB_Graphics3D*, PostSwapBuffersFn);
|
2013-08-11 09:15:59 +04:00
|
|
|
|
2013-01-14 03:35:06 +04:00
|
|
|
} // namespace bgfx
|
|
|
|
|
2013-04-19 08:16:09 +04:00
|
|
|
#elif BX_PLATFORM_OSX
|
2013-01-14 03:35:06 +04:00
|
|
|
namespace bgfx
|
|
|
|
{
|
2013-08-11 09:15:59 +04:00
|
|
|
///
|
2013-04-19 10:32:12 +04:00
|
|
|
void osxSetNSWindow(void* _window);
|
2013-08-11 09:15:59 +04:00
|
|
|
|
2013-01-14 03:35:06 +04:00
|
|
|
} // namespace bgfx
|
|
|
|
|
2013-04-19 08:16:09 +04:00
|
|
|
#elif BX_PLATFORM_WINDOWS
|
|
|
|
# include <windows.h>
|
2013-01-16 08:37:07 +04:00
|
|
|
|
|
|
|
namespace bgfx
|
|
|
|
{
|
2013-08-11 09:15:59 +04:00
|
|
|
///
|
2013-04-19 10:32:12 +04:00
|
|
|
void winSetHwnd(::HWND _window);
|
2013-08-11 09:15:59 +04:00
|
|
|
|
2013-01-16 08:37:07 +04:00
|
|
|
} // namespace bgfx
|
|
|
|
|
2013-01-14 03:35:06 +04:00
|
|
|
#endif // BX_PLATFORM_
|
|
|
|
|
2013-08-11 09:15:59 +04:00
|
|
|
#ifdef _SDL_H
|
|
|
|
// If SDL is included before bgfxplatform.h we can enable SDL window interop
|
|
|
|
// convenience code.
|
|
|
|
# include <SDL_syswm.h>
|
|
|
|
|
|
|
|
namespace bgfx
|
|
|
|
{
|
|
|
|
///
|
|
|
|
inline bool sdlSetWindow(SDL_Window* _window)
|
|
|
|
{
|
|
|
|
SDL_SysWMinfo wmi;
|
|
|
|
SDL_VERSION(&wmi.version);
|
|
|
|
if (-1 == SDL_GetWindowWMInfo(_window, &wmi) )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_PLATFORM_LINUX
|
|
|
|
x11SetDisplayWindow(wmi.info.x11.display, wmi.info.x11.window);
|
|
|
|
#elif BX_PLATFORM_OSX
|
|
|
|
osxSetNSWindow(wmi.info.cocoa.window);
|
|
|
|
#elif BX_PLATFORM_WINDOWS
|
|
|
|
winSetHwnd(wmi.info.win.window);
|
|
|
|
#endif // BX_PLATFORM_
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} // namespace bgfx
|
|
|
|
#endif // _SDL_H
|
|
|
|
|
2013-01-14 03:35:06 +04:00
|
|
|
#endif // __BGFXPLATFORM_H__
|