diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d3544a21..9ecad3a6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -804,6 +804,7 @@ elseif(WINDOWS) check_include_file(dsound.h HAVE_DSOUND_H) check_include_file(dinput.h HAVE_DINPUT_H) check_include_file(xaudio2.h HAVE_XAUDIO2_H) + check_include_file(dxgi.h HAVE_DXGI_H) if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H) set(HAVE_DIRECTX TRUE) # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks diff --git a/configure.in b/configure.in index 97b57f316..be4ac9f29 100644 --- a/configure.in +++ b/configure.in @@ -2404,6 +2404,7 @@ AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[defaul AC_CHECK_HEADER(dsound.h, have_dsound=yes) AC_CHECK_HEADER(dinput.h, have_dinput=yes) AC_CHECK_HEADER(xaudio2.h, have_xaudio2=yes) + AC_CHECK_HEADER(dxgi.h, have_dxgi=yes) SUMMARY_video="${SUMMARY_video} directx" SUMMARY_audio="${SUMMARY_audio} directx" @@ -2830,6 +2831,9 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau AC_DEFINE(SDL_VIDEO_RENDER_D3D11, 1, [ ]) fi fi + if test x$have_dxgi = xyes; then + AC_DEFINE(HAVE_DXGI_H, 1, [ ]) + fi # Set up files for the audio library if test x$enable_audio = xyes; then AC_DEFINE(SDL_AUDIO_DRIVER_WINMM, 1, [ ]) diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index b6fb53aa2..9b394220e 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -48,6 +48,8 @@ #cmakedefine HAVE_GCC_SYNC_LOCK_TEST_AND_SET @HAVE_GCC_SYNC_LOCK_TEST_AND_SET@ #cmakedefine HAVE_PTHREAD_SPINLOCK @HAVE_PTHREAD_SPINLOCK@ +#cmakedefine HAVE_DXGI_H @HAVE_DXGI_H@ + /* Comment this if you want to build without any C library requirements */ #cmakedefine HAVE_LIBC 1 #if HAVE_LIBC diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index a15232990..884fd9bac 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -51,6 +51,8 @@ #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET #undef HAVE_PTHREAD_SPINLOCK +#undef HAVE_DXGI_H + /* Comment this if you want to build without any C library requirements */ #undef HAVE_LIBC #if HAVE_LIBC diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h index 35eda4653..1157270f7 100644 --- a/include/SDL_config_windows.h +++ b/include/SDL_config_windows.h @@ -76,6 +76,8 @@ typedef unsigned int uintptr_t; # define SIZEOF_VOIDP 4 #endif +#define HAVE_DXGI_H 1 + /* This is disabled by default to avoid C runtime dependencies and manifest requirements */ #ifdef HAVE_LIBC /* Useful headers */ diff --git a/include/SDL_config_winrt.h b/include/SDL_config_winrt.h index 78b43ab64..48d44ee55 100644 --- a/include/SDL_config_winrt.h +++ b/include/SDL_config_winrt.h @@ -77,6 +77,7 @@ typedef unsigned int uintptr_t; #endif /* Useful headers */ +#define HAVE_DXGI_H 1 #define HAVE_LIBC 1 #define HAVE_STDIO_H 1 #define STDC_HEADERS 1 diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index ea1595726..9ab1f4c1a 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -245,11 +245,12 @@ SDL_Direct3D9GetAdapterIndex( int displayIndex ) } } +#if HAVE_DXGI_H #define CINTERFACE #define COBJMACROS #include -SDL_bool +static SDL_bool DXGI_LoadDLL(void **pDXGIDLL, IDXGIFactory **pDXGIFactory) { *pDXGIDLL = SDL_LoadObject("DXGI.DLL"); @@ -277,18 +278,25 @@ DXGI_LoadDLL(void **pDXGIDLL, IDXGIFactory **pDXGIFactory) return SDL_FALSE; } } +#endif SDL_bool SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex) { +#if !HAVE_DXGI_H + if (adapterIndex) *adapterIndex = -1; + if (outputIndex) *outputIndex = -1; + SDL_SetError("SDL was compiled without DXGI support due to missing dxgi.h header"); + return SDL_FALSE; +#else SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex); void *pDXGIDLL; + char *displayName; + int nAdapter, nOutput; IDXGIFactory *pDXGIFactory; IDXGIAdapter *pDXGIAdapter; IDXGIOutput* pDXGIOutput; - char *displayName; - int nAdapter, nOutput; if (!adapterIndex) { SDL_InvalidParamError("adapterIndex"); @@ -344,6 +352,7 @@ SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex) } else { return SDL_TRUE; } +#endif } #endif /* SDL_VIDEO_DRIVER_WINDOWS */