Moved SDL_Direct3D9GetAdapterIndex() to SDL_windowsvideo.c since it doesn't belong in the window code.
authorSam Lantinga <slouken@libsdl.org>
Sat, 28 Sep 2013 14:06:59 -0700
changeset 7762 51abf7664304
parent 7761 bddbfca922cd
child 7763 fc802d707136
Moved SDL_Direct3D9GetAdapterIndex() to SDL_windowsvideo.c since it doesn't belong in the window code.
src/render/direct3d/SDL_render_d3d.c
src/video/windows/SDL_windowsvideo.c
src/video/windows/SDL_windowsvideo.h
src/video/windows/SDL_windowswindow.c
src/video/windows/SDL_windowswindow.h
--- a/src/render/direct3d/SDL_render_d3d.c	Sat Sep 28 14:06:55 2013 -0700
+++ b/src/render/direct3d/SDL_render_d3d.c	Sat Sep 28 14:06:59 2013 -0700
@@ -30,10 +30,7 @@
 #include "SDL_syswm.h"
 #include "SDL_system.h"
 #include "../SDL_sysrender.h"
-#include <stdio.h>
-
-#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
--- a/src/video/windows/SDL_windowsvideo.c	Sat Sep 28 14:06:55 2013 -0700
+++ b/src/video/windows/SDL_windowsvideo.c	Sat Sep 28 14:06:59 2013 -0700
@@ -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_QuitMouse(_this);
 }
 
+
+#define D3D_DEBUG_INFO
+#include <d3d9.h>
+
+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<count; i++) {
+				D3DADAPTER_IDENTIFIER9 id;
+				IDirect3D9_GetAdapterIdentifier(pD3D, i, 0, &id);
+
+				if (SDL_strcmp(id.DeviceName, displayName) == 0) {
+					adapterIndex = i;
+					break;
+				}
+			}
+			SDL_free(displayName);
+		}
+
+		/* free up the D3D stuff we inited */
+		IDirect3D9_Release(pD3D);
+		SDL_UnloadObject(pD3DDLL);
+
+		return adapterIndex;
+	}
+}
+
 #endif /* SDL_VIDEO_DRIVER_WINDOWS */
 
 /* vim: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_windowsvideo.h	Sat Sep 28 14:06:55 2013 -0700
+++ b/src/video/windows/SDL_windowsvideo.h	Sat Sep 28 14:06:59 2013 -0700
@@ -170,6 +170,10 @@
     TSFSink *ime_ippasink;
 } SDL_VideoData;
 
+
+typedef struct IDirect3D9 IDirect3D9;
+extern SDL_bool D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface );
+
 #endif /* _SDL_windowsvideo_h */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_windowswindow.c	Sat Sep 28 14:06:55 2013 -0700
+++ b/src/video/windows/SDL_windowswindow.c	Sat Sep 28 14:06:59 2013 -0700
@@ -22,15 +22,10 @@
 
 #if SDL_VIDEO_DRIVER_WINDOWS
 
-#include "../../core/windows/SDL_windows.h"
-
 #include "SDL_assert.h"
-#include "SDL_system.h"
 #include "../SDL_sysvideo.h"
 #include "../SDL_pixels_c.h"
 #include "../../events/SDL_keyboard_c.h"
-#include "../../video/SDL_sysvideo.h"
-#include "../../video/windows/SDL_windowsmodes.h"
 
 #include "SDL_windowsvideo.h"
 #include "SDL_windowswindow.h"
@@ -41,9 +36,6 @@
 /* This is included after SDL_windowsvideo.h, which includes windows.h */
 #include "SDL_syswm.h"
 
-#define D3D_DEBUG_INFO
-#include <d3d9.h>
-
 /* Windows CE compatibility */
 #ifndef SWP_NOCOPYBITS
 #define SWP_NOCOPYBITS 0
@@ -691,74 +683,6 @@
 #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<count; i++) {
-				D3DADAPTER_IDENTIFIER9 id;
-				IDirect3D9_GetAdapterIdentifier(pD3D, i, 0, &id);
-
-				if (SDL_strcmp(id.DeviceName, displayName) == 0) {
-					adapterIndex = i;
-					break;
-				}
-			}
-			SDL_free(displayName);
-		}
-
-		/* free up the D3D stuff we inited */
-		IDirect3D9_Release(pD3D);
-		SDL_UnloadObject(pD3DDLL);
-
-		return adapterIndex;
-	}
-}
-
-
-
 #endif /* SDL_VIDEO_DRIVER_WINDOWS */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_windowswindow.h	Sat Sep 28 14:06:55 2013 -0700
+++ b/src/video/windows/SDL_windowswindow.h	Sat Sep 28 14:06:59 2013 -0700
@@ -36,8 +36,6 @@
     struct SDL_VideoData *videodata;
 } SDL_WindowData;
 
-typedef struct IDirect3D9 IDirect3D9;
-
 extern int WIN_CreateWindow(_THIS, SDL_Window * window);
 extern int WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
 extern void WIN_SetWindowTitle(_THIS, SDL_Window * window);
@@ -59,7 +57,6 @@
 extern SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window * window,
                                     struct SDL_SysWMinfo *info);
 extern void WIN_OnWindowEnter(_THIS, SDL_Window * window);
-extern SDL_bool D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface );
 
 #endif /* _SDL_windowswindow_h */