Don't try to load d3dcompiler_46.dll on Windows XP
authorSam Lantinga <slouken@libsdl.org>
Wed, 23 Apr 2014 13:47:42 -0700
changeset 873302b7b0448811
parent 8732 c62baa0b8827
child 8734 cb61954403ca
Don't try to load d3dcompiler_46.dll on Windows XP
src/core/windows/SDL_windows.c
src/core/windows/SDL_windows.h
src/video/SDL_egl.c
     1.1 --- a/src/core/windows/SDL_windows.c	Wed Apr 23 13:47:35 2014 -0700
     1.2 +++ b/src/core/windows/SDL_windows.c	Wed Apr 23 13:47:42 2014 -0700
     1.3 @@ -88,6 +88,31 @@
     1.4  #endif
     1.5  }
     1.6  
     1.7 +static BOOL
     1.8 +IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
     1.9 +{
    1.10 +    OSVERSIONINFOEXW osvi;
    1.11 +    DWORDLONG const dwlConditionMask = VerSetConditionMask(
    1.12 +        VerSetConditionMask(
    1.13 +        VerSetConditionMask(
    1.14 +        0, VER_MAJORVERSION, VER_GREATER_EQUAL ),
    1.15 +        VER_MINORVERSION, VER_GREATER_EQUAL ),
    1.16 +        VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL );
    1.17 +
    1.18 +    SDL_zero(osvi);
    1.19 +    osvi.dwOSVersionInfoSize = sizeof(osvi);
    1.20 +    osvi.dwMajorVersion = wMajorVersion;
    1.21 +    osvi.dwMinorVersion = wMinorVersion;
    1.22 +    osvi.wServicePackMajor = wServicePackMajor;
    1.23 +
    1.24 +    return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
    1.25 +}
    1.26 +
    1.27 +BOOL WIN_IsWindowsVistaOrGreater()
    1.28 +{
    1.29 +    return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0);
    1.30 +}
    1.31 +
    1.32  #endif /* __WIN32__ */
    1.33  
    1.34  /* vi: set ts=4 sw=4 expandtab: */
     2.1 --- a/src/core/windows/SDL_windows.h	Wed Apr 23 13:47:35 2014 -0700
     2.2 +++ b/src/core/windows/SDL_windows.h	Wed Apr 23 13:47:42 2014 -0700
     2.3 @@ -56,6 +56,9 @@
     2.4  extern HRESULT WIN_CoInitialize(void);
     2.5  extern void WIN_CoUninitialize(void);
     2.6  
     2.7 +/* Returns SDL_TRUE if we're running on Windows Vista and newer */
     2.8 +extern BOOL WIN_IsWindowsVistaOrGreater();
     2.9 +
    2.10  #endif /* _INCLUDED_WINDOWS_H */
    2.11  
    2.12  /* vi: set ts=4 sw=4 expandtab: */
     3.1 --- a/src/video/SDL_egl.c	Wed Apr 23 13:47:35 2014 -0700
     3.2 +++ b/src/video/SDL_egl.c	Wed Apr 23 13:47:42 2014 -0700
     3.3 @@ -135,8 +135,11 @@
     3.4  #if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
     3.5      d3dcompiler = SDL_GetHint(SDL_HINT_VIDEO_WIN_D3DCOMPILER);
     3.6      if (!d3dcompiler) {
     3.7 -        /* By default we load the Vista+ compatible compiler */
     3.8 -        d3dcompiler = "d3dcompiler_46.dll";
     3.9 +        if (WIN_IsWindowsVistaOrGreater()) {
    3.10 +            d3dcompiler = "d3dcompiler_46.dll";
    3.11 +        } else {
    3.12 +            d3dcompiler = "none";
    3.13 +        }
    3.14      }
    3.15      if (SDL_strcasecmp(d3dcompiler, "none") != 0) {
    3.16          SDL_LoadObject(d3dcompiler);