Moved D3D_LoadDLL and SDL_Direct3D9GetAdapterIndex to SDL_windowswindow.c at Jorgen's insistence. That file is wrapped in a more appropriate define check so it will work if somebody builds a binary without D3D support.

Added a reference to SDL_Direct3D9GetAdapterIndex to SDL_test_common.c so SDL will fail to compile if the new symbol isn't included properly.

CR: Jorgen
This commit is contained in:
Sam Lantinga 2013-09-28 14:06:20 -07:00
parent a7429dfa22
commit a759ac24a1
4 changed files with 92 additions and 69 deletions

View file

@ -28,11 +28,13 @@
#include "SDL_hints.h"
#include "SDL_loadso.h"
#include "SDL_syswm.h"
#include "SDL_system.h"
#include "../SDL_sysrender.h"
#include "../../video/SDL_sysvideo.h"
#include "../../video/windows/SDL_windowsmodes.h"
#include <stdio.h>
#include "../../video/SDL_sysvideo.h"
#include "../../video/windows/SDL_windowswindow.h"
#if SDL_VIDEO_RENDER_D3D
#define D3D_DEBUG_INFO
#include <d3d9.h>
@ -533,72 +535,6 @@ D3D_ActivateRenderer(SDL_Renderer * renderer)
return 0;
}
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" );
} 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;
}
}
SDL_Renderer *
D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
{