Added GLFW3 support.

This commit is contained in:
bkaradzic 2013-08-10 23:22:40 -07:00
parent 5b6a42e5cd
commit 99f9cfd39f

View file

@ -73,9 +73,10 @@ namespace bgfx
#endif // BX_PLATFORM_ #endif // BX_PLATFORM_
#ifdef _SDL_H #if defined(_SDL_H)
// If SDL is included before bgfxplatform.h we can enable SDL window interop // If SDL.h is included before bgfxplatform.h we can enable SDL window interop
// convenience code. // convenience code.
# include <SDL_syswm.h> # include <SDL_syswm.h>
namespace bgfx namespace bgfx
@ -101,6 +102,42 @@ namespace bgfx
return true; return true;
} }
} // namespace bgfx } // namespace bgfx
#endif // _SDL_H
#elif defined(_glfw3_h_)
// If GLFW/glfw3.h is included before bgfxplatform.h we can enable GLFW3 window
// interop convenience code.
# if BX_PLATFORM_LINUX
# define GLFW_EXPOSE_NATIVE_X11
# define GLFW_EXPOSE_NATIVE_GLX
# elif BX_PLATFORM_OSX
# define GLFW_EXPOSE_NATIVE_COCOA
# define GLFW_EXPOSE_NATIVE_NSGL
# elif BX_PLATFORM_WINDOWS
# define GLFW_EXPOSE_NATIVE_WIN32
# define GLFW_EXPOSE_NATIVE_WGL
# endif //
# include <GLFW/glfw3native.h>
namespace bgfx
{
inline void glfwSetWindow(GLFWwindow* _window)
{
# if BX_PLATFORM_LINUX
::Display* display = glfwGetX11Display();
::Window window = glfwGetX11Window(_window);
x11SetDisplayWindow(display, window);
# elif BX_PLATFORM_OSX
void* id = glfwGetCocoaWindow(_window);
osxSetNSWindow(id);
# elif BX_PLATFORM_WINDOWS
HWND hwnd = glfwGetWin32Window(_window);
winSetHwnd(hwnd);
# endif BX_PLATFORM_WINDOWS
}
} // namespace bgfx
#endif // defined(_SDL_H)
#endif // __BGFXPLATFORM_H__ #endif // __BGFXPLATFORM_H__