From 9f390e79676a85b9c7f03108e3fd76e2ab1221fb Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 28 Sep 2013 14:06:59 -0700 Subject: [PATCH] Moved SDL_Direct3D9GetAdapterIndex() to SDL_windowsvideo.c since it doesn't belong in the window code. --- src/render/direct3d/SDL_render_d3d.c | 5 +- src/video/windows/SDL_windowsvideo.c | 71 +++++++++++++++++++++++++ src/video/windows/SDL_windowsvideo.h | 4 ++ src/video/windows/SDL_windowswindow.c | 76 --------------------------- src/video/windows/SDL_windowswindow.h | 3 -- 5 files changed, 76 insertions(+), 83 deletions(-) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 865ac21c09b47..73a2c82cea633 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -30,10 +30,7 @@ #include "SDL_syswm.h" #include "SDL_system.h" #include "../SDL_sysrender.h" -#include - -#include "../../video/SDL_sysvideo.h" -#include "../../video/windows/SDL_windowswindow.h" +#include "../../video/windows/SDL_windowsvideo.h" #if SDL_VIDEO_RENDER_D3D #define D3D_DEBUG_INFO diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 77b63a21a95ac..8f708cf0d70fb 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -25,6 +25,7 @@ #include "SDL_main.h" #include "SDL_video.h" #include "SDL_mouse.h" +#include "SDL_system.h" #include "../SDL_sysvideo.h" #include "../SDL_pixels_c.h" @@ -174,6 +175,76 @@ WIN_VideoQuit(_THIS) WIN_QuitMouse(_this); } + +#define D3D_DEBUG_INFO +#include + +SDL_bool +D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface ) +{ + *pD3DDLL = SDL_LoadObject("D3D9.DLL"); + if (*pD3DDLL) { + IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); + + D3DCreate = + (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(*pD3DDLL, + "Direct3DCreate9"); + if (D3DCreate) { + *pDirect3D9Interface = D3DCreate(D3D_SDK_VERSION); + } + if (!*pDirect3D9Interface) { + SDL_UnloadObject(*pD3DDLL); + *pD3DDLL = NULL; + return SDL_FALSE; + } + + return SDL_TRUE; + } else { + *pDirect3D9Interface = NULL; + return SDL_FALSE; + } +} + + +int +SDL_Direct3D9GetAdapterIndex( int displayIndex ) +{ + void *pD3DDLL; + IDirect3D9 *pD3D; + if (!D3D_LoadDLL(&pD3DDLL, &pD3D)) { + SDL_SetError("Unable to create Direct3D interface"); + return D3DADAPTER_DEFAULT; + } else { + SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex); + int adapterIndex = D3DADAPTER_DEFAULT; + + if (!pData) { + SDL_SetError("Invalid display index"); + adapterIndex = -1; /* make sure we return something invalid */ + } else { + char *displayName = WIN_StringToUTF8(pData->DeviceName); + unsigned int count = IDirect3D9_GetAdapterCount(pD3D); + unsigned int i; + for (i=0; i - /* Windows CE compatibility */ #ifndef SWP_NOCOPYBITS #define SWP_NOCOPYBITS 0 @@ -691,74 +683,6 @@ void WIN_OnWindowEnter(_THIS, SDL_Window * window) #endif /* WM_MOUSELEAVE */ } -SDL_bool -D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface ) -{ - *pD3DDLL = SDL_LoadObject("D3D9.DLL"); - if (*pD3DDLL) { - IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); - - D3DCreate = - (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(*pD3DDLL, - "Direct3DCreate9"); - if (D3DCreate) { - *pDirect3D9Interface = D3DCreate(D3D_SDK_VERSION); - } - if (!*pDirect3D9Interface) { - SDL_UnloadObject(*pD3DDLL); - *pD3DDLL = NULL; - return SDL_FALSE; - } - - return SDL_TRUE; - } else { - *pDirect3D9Interface = NULL; - return SDL_FALSE; - } -} - - -int -SDL_Direct3D9GetAdapterIndex( int displayIndex ) -{ - void *pD3DDLL; - IDirect3D9 *pD3D; - if (!D3D_LoadDLL(&pD3DDLL, &pD3D)) { - SDL_SetError("Unable to create Direct3D interface"); - return D3DADAPTER_DEFAULT; - } else { - SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex); - int adapterIndex = D3DADAPTER_DEFAULT; - - if (!pData) { - SDL_SetError("Invalid display index"); - adapterIndex = -1; /* make sure we return something invalid */ - } else { - char *displayName = WIN_StringToUTF8(pData->DeviceName); - unsigned int count = IDirect3D9_GetAdapterCount(pD3D); - unsigned int i; - for (i=0; i