From cc6649db0dc638d958dee38806d23e6ec2f1e999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 22 Apr 2015 09:30:28 -0700 Subject: [PATCH] Cleanup. --- examples/common/entry/entry_sdl.cpp | 1 + include/bgfxplatform.h | 40 +++++++++++++++++------------ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/examples/common/entry/entry_sdl.cpp b/examples/common/entry/entry_sdl.cpp index b9564339c..6329bef94 100644 --- a/examples/common/entry/entry_sdl.cpp +++ b/examples/common/entry/entry_sdl.cpp @@ -12,6 +12,7 @@ #endif // BX_PLATFORM_WINDOWS #include +#include #include #include diff --git a/include/bgfxplatform.h b/include/bgfxplatform.h index 68b8afe9b..416c37388 100644 --- a/include/bgfxplatform.h +++ b/include/bgfxplatform.h @@ -161,12 +161,10 @@ namespace bgfx #endif // BX_PLATFORM_ -#if defined(_SDL_H) -// If SDL.h is included before bgfxplatform.h we can enable SDL window +#if defined(_SDL_syswm_h) +// If SDL_syswm.h is included before bgfxplatform.h we can enable SDL window // interop convenience code. -# include - namespace bgfx { /// @@ -179,13 +177,20 @@ namespace bgfx return false; } + PlatformData pd; # if BX_PLATFORM_LINUX || BX_PLATFORM_FREEBSD - x11SetDisplayWindow(wmi.info.x11.display, wmi.info.x11.window); + pd.ndt = wmi.info.x11.display; + pd.nwh = (void*)(uintptr_t)wmi.info.x11.window; # elif BX_PLATFORM_OSX - osxSetNSWindow(wmi.info.cocoa.window); + pd.ndt = NULL; + pd.nwh = wmi.info.cocoa.window; # elif BX_PLATFORM_WINDOWS - winSetHwnd(wmi.info.win.window); + pd.ndt = NULL; + pd.nwh = wmi.info.win.window; # endif // BX_PLATFORM_ + pd.context = NULL; + pd.backbuffer = NULL; + setPlatformData(pd); return true; } @@ -212,19 +217,22 @@ namespace bgfx { inline void glfwSetWindow(GLFWwindow* _window) { + PlatformData pd; # if BX_PLATFORM_LINUX || BX_PLATFORM_FREEBSD - ::Display* display = glfwGetX11Display(); - ::Window window = glfwGetX11Window(_window); - void* glx = glfwGetGLXContext(_window); - x11SetDisplayWindow(display, window, glx); + pd.ndt = glfwGetX11Display(); + pd.nwh = (void*)(uintptr_t)glfwGetX11Window(_window); + pd.context = glfwGetGLXContext(_window); # elif BX_PLATFORM_OSX - void* window = glfwGetCocoaWindow(_window); - void* nsgl = glfwGetNSGLContext(_window); - osxSetNSWindow(window, nsgl); + pd.ndt = NULL; + pd.nwh = glfwGetCocoaWindow(_window); + pd.context = glfwGetNSGLContext(_window); # elif BX_PLATFORM_WINDOWS - HWND hwnd = glfwGetWin32Window(_window); - winSetHwnd(hwnd); + pd.ndt = NULL; + pd.nwh = glfwGetWin32Window(_window); + pd.context = NULL; # endif // BX_PLATFORM_WINDOWS + pd.backbuffer = NULL; + setPlatformData(pd); } } // namespace bgfx