From 4bf765d711a97c8fec9c749abc169718a554ef71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lasse=20=C3=96=C3=B6rni?= Date: Tue, 18 Mar 2014 19:37:18 +0200 Subject: [PATCH] Removed SDL hack to get window handle for Direct3D9. Instead use SDL builtin functionality. --- .../Graphics/Direct3D9/D3D9Graphics.cpp | 19 ++++++++++++++----- .../SDL/src/video/windows/SDL_windowswindow.c | 6 ------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Source/Engine/Graphics/Direct3D9/D3D9Graphics.cpp b/Source/Engine/Graphics/Direct3D9/D3D9Graphics.cpp index 2854456c3..e8eae2ac4 100644 --- a/Source/Engine/Graphics/Direct3D9/D3D9Graphics.cpp +++ b/Source/Engine/Graphics/Direct3D9/D3D9Graphics.cpp @@ -57,6 +57,8 @@ #include "VertexDeclaration.h" #include "Zone.h" +#include + #include "DebugNew.h" #ifdef _MSC_VER @@ -76,8 +78,6 @@ extern "C" { namespace Urho3D { -extern "C" HWND WIN_GetWindowHandle(SDL_Window* window); - static const D3DCMPFUNC d3dCmpFunc[] = { D3DCMP_ALWAYS, @@ -196,6 +196,15 @@ static unsigned GetD3DColor(const Color& color) return (((a) & 0xff) << 24) | (((r) & 0xff) << 16) | (((g) & 0xff) << 8) | ((b) & 0xff); } +static HWND GetWindowHandle(SDL_Window* window) +{ + SDL_SysWMinfo sysInfo; + + SDL_VERSION(&sysInfo.version); + SDL_GetWindowWMInfo(window, &sysInfo); + return sysInfo.info.win.window; +} + static unsigned depthStencilFormat = D3DFMT_D24S8; Graphics::Graphics(Context* context) : @@ -427,7 +436,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless, impl_->presentParams_.MultiSampleType = multiSample > 1 ? (D3DMULTISAMPLE_TYPE)multiSample : D3DMULTISAMPLE_NONE; impl_->presentParams_.MultiSampleQuality = 0; impl_->presentParams_.SwapEffect = D3DSWAPEFFECT_DISCARD; - impl_->presentParams_.hDeviceWindow = WIN_GetWindowHandle(impl_->window_); + impl_->presentParams_.hDeviceWindow = GetWindowHandle(impl_->window_); impl_->presentParams_.EnableAutoDepthStencil = TRUE; impl_->presentParams_.AutoDepthStencilFormat = D3DFMT_D24S8; impl_->presentParams_.Flags = D3DPRESENT_LINEAR_CONTENT; @@ -585,7 +594,7 @@ bool Graphics::TakeScreenShot(Image& destImage) } else { - HWND hwnd = WIN_GetWindowHandle(impl_->window_); + HWND hwnd = GetWindowHandle(impl_->window_); GetClientRect(hwnd, &sourceRect); ClientToScreen(hwnd, (LPPOINT)&sourceRect); } @@ -2464,7 +2473,7 @@ bool Graphics::CreateDevice(unsigned adapter, unsigned deviceType) if (FAILED(impl_->interface_->CreateDevice( adapter, (D3DDEVTYPE)deviceType, - WIN_GetWindowHandle(impl_->window_), + GetWindowHandle(impl_->window_), behaviorFlags, &impl_->presentParams_, &impl_->device_))) diff --git a/Source/ThirdParty/SDL/src/video/windows/SDL_windowswindow.c b/Source/ThirdParty/SDL/src/video/windows/SDL_windowswindow.c index d8becdb38..fdee11244 100644 --- a/Source/ThirdParty/SDL/src/video/windows/SDL_windowswindow.c +++ b/Source/ThirdParty/SDL/src/video/windows/SDL_windowswindow.c @@ -59,12 +59,6 @@ static ATOM SDL_HelperWindowClass = 0; #define STYLE_RESIZABLE (WS_THICKFRAME | WS_MAXIMIZEBOX) #define STYLE_MASK (STYLE_FULLSCREEN | STYLE_BORDERLESS | STYLE_NORMAL | STYLE_RESIZABLE) -// Urho3D: added function for Direct3D9 initialization -HWND WIN_GetWindowHandle(SDL_Window* window) -{ - return ((SDL_WindowData *)window->driverdata)->hwnd; -} - static DWORD GetWindowStyle(SDL_Window * window) {