Fix build on Windows targets without dxgi.h, like MingW32.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 06 May 2014 00:13:07 -0400
changeset 8751e8c61640668d
parent 8750 5064096ddaf7
child 8752 44d31ae3d104
Fix build on Windows targets without dxgi.h, like MingW32.
CMakeLists.txt
configure.in
include/SDL_config.h.cmake
include/SDL_config.h.in
include/SDL_config_windows.h
include/SDL_config_winrt.h
src/video/windows/SDL_windowsvideo.c
     1.1 --- a/CMakeLists.txt	Fri May 02 12:39:26 2014 -0700
     1.2 +++ b/CMakeLists.txt	Tue May 06 00:13:07 2014 -0400
     1.3 @@ -804,6 +804,7 @@
     1.4      check_include_file(dsound.h HAVE_DSOUND_H)
     1.5      check_include_file(dinput.h HAVE_DINPUT_H)
     1.6      check_include_file(xaudio2.h HAVE_XAUDIO2_H)
     1.7 +    check_include_file(dxgi.h HAVE_DXGI_H)
     1.8      if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
     1.9        set(HAVE_DIRECTX TRUE)
    1.10        # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
     2.1 --- a/configure.in	Fri May 02 12:39:26 2014 -0700
     2.2 +++ b/configure.in	Tue May 06 00:13:07 2014 -0400
     2.3 @@ -2404,6 +2404,7 @@
     2.4          AC_CHECK_HEADER(dsound.h, have_dsound=yes)
     2.5          AC_CHECK_HEADER(dinput.h, have_dinput=yes)
     2.6          AC_CHECK_HEADER(xaudio2.h, have_xaudio2=yes)
     2.7 +        AC_CHECK_HEADER(dxgi.h, have_dxgi=yes)
     2.8  
     2.9          SUMMARY_video="${SUMMARY_video} directx"
    2.10          SUMMARY_audio="${SUMMARY_audio} directx"
    2.11 @@ -2830,6 +2831,9 @@
    2.12                  AC_DEFINE(SDL_VIDEO_RENDER_D3D11, 1, [ ])
    2.13              fi
    2.14          fi
    2.15 +        if test x$have_dxgi = xyes; then
    2.16 +            AC_DEFINE(HAVE_DXGI_H, 1, [ ])
    2.17 +        fi
    2.18          # Set up files for the audio library
    2.19          if test x$enable_audio = xyes; then
    2.20              AC_DEFINE(SDL_AUDIO_DRIVER_WINMM, 1, [ ])
     3.1 --- a/include/SDL_config.h.cmake	Fri May 02 12:39:26 2014 -0700
     3.2 +++ b/include/SDL_config.h.cmake	Tue May 06 00:13:07 2014 -0400
     3.3 @@ -48,6 +48,8 @@
     3.4  #cmakedefine HAVE_GCC_SYNC_LOCK_TEST_AND_SET @HAVE_GCC_SYNC_LOCK_TEST_AND_SET@
     3.5  #cmakedefine HAVE_PTHREAD_SPINLOCK @HAVE_PTHREAD_SPINLOCK@
     3.6  
     3.7 +#cmakedefine HAVE_DXGI_H @HAVE_DXGI_H@
     3.8 +
     3.9  /* Comment this if you want to build without any C library requirements */
    3.10  #cmakedefine HAVE_LIBC 1
    3.11  #if HAVE_LIBC
     4.1 --- a/include/SDL_config.h.in	Fri May 02 12:39:26 2014 -0700
     4.2 +++ b/include/SDL_config.h.in	Tue May 06 00:13:07 2014 -0400
     4.3 @@ -51,6 +51,8 @@
     4.4  #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET
     4.5  #undef HAVE_PTHREAD_SPINLOCK
     4.6  
     4.7 +#undef HAVE_DXGI_H
     4.8 +
     4.9  /* Comment this if you want to build without any C library requirements */
    4.10  #undef HAVE_LIBC
    4.11  #if HAVE_LIBC
     5.1 --- a/include/SDL_config_windows.h	Fri May 02 12:39:26 2014 -0700
     5.2 +++ b/include/SDL_config_windows.h	Tue May 06 00:13:07 2014 -0400
     5.3 @@ -76,6 +76,8 @@
     5.4  # define SIZEOF_VOIDP 4
     5.5  #endif
     5.6  
     5.7 +#define HAVE_DXGI_H 1
     5.8 +
     5.9  /* This is disabled by default to avoid C runtime dependencies and manifest requirements */
    5.10  #ifdef HAVE_LIBC
    5.11  /* Useful headers */
     6.1 --- a/include/SDL_config_winrt.h	Fri May 02 12:39:26 2014 -0700
     6.2 +++ b/include/SDL_config_winrt.h	Tue May 06 00:13:07 2014 -0400
     6.3 @@ -77,6 +77,7 @@
     6.4  #endif
     6.5  
     6.6  /* Useful headers */
     6.7 +#define HAVE_DXGI_H 1
     6.8  #define HAVE_LIBC 1
     6.9  #define HAVE_STDIO_H 1
    6.10  #define STDC_HEADERS 1
     7.1 --- a/src/video/windows/SDL_windowsvideo.c	Fri May 02 12:39:26 2014 -0700
     7.2 +++ b/src/video/windows/SDL_windowsvideo.c	Tue May 06 00:13:07 2014 -0400
     7.3 @@ -245,11 +245,12 @@
     7.4      }
     7.5  }
     7.6  
     7.7 +#if HAVE_DXGI_H
     7.8  #define CINTERFACE
     7.9  #define COBJMACROS
    7.10  #include <dxgi.h>
    7.11  
    7.12 -SDL_bool 
    7.13 +static SDL_bool
    7.14  DXGI_LoadDLL(void **pDXGIDLL, IDXGIFactory **pDXGIFactory)
    7.15  {
    7.16      *pDXGIDLL = SDL_LoadObject("DXGI.DLL");
    7.17 @@ -277,18 +278,25 @@
    7.18          return SDL_FALSE;
    7.19      }
    7.20  }
    7.21 +#endif
    7.22  
    7.23  
    7.24  SDL_bool
    7.25  SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex)
    7.26  {
    7.27 +#if !HAVE_DXGI_H
    7.28 +    if (adapterIndex) *adapterIndex = -1;
    7.29 +    if (outputIndex) *outputIndex = -1;
    7.30 +    SDL_SetError("SDL was compiled without DXGI support due to missing dxgi.h header");
    7.31 +    return SDL_FALSE;
    7.32 +#else
    7.33      SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex);
    7.34      void *pDXGIDLL;
    7.35 +    char *displayName;
    7.36 +    int nAdapter, nOutput;
    7.37      IDXGIFactory *pDXGIFactory;
    7.38      IDXGIAdapter *pDXGIAdapter;
    7.39      IDXGIOutput* pDXGIOutput;
    7.40 -    char *displayName;
    7.41 -    int nAdapter, nOutput;
    7.42  
    7.43      if (!adapterIndex) {
    7.44          SDL_InvalidParamError("adapterIndex");
    7.45 @@ -344,6 +352,7 @@
    7.46      } else {
    7.47          return SDL_TRUE;
    7.48      }
    7.49 +#endif
    7.50  }
    7.51  
    7.52  #endif /* SDL_VIDEO_DRIVER_WINDOWS */